mirror of
https://github.com/CPunch/LuaPytecode.git
synced 2024-12-22 14:10:07 +00:00
Added some comments that explain some '???' moments
This commit is contained in:
parent
efb4ef5035
commit
3eecd3a8b0
14
luac.py
14
luac.py
@ -210,16 +210,17 @@ class LuaUndump:
|
|||||||
template = instr_lookup_tbl[opcode]
|
template = instr_lookup_tbl[opcode]
|
||||||
instruction = Instruction(template.type, template.name)
|
instruction = Instruction(template.type, template.name)
|
||||||
|
|
||||||
|
# i read the lopcodes.h file to get these bit position and sizes.
|
||||||
instruction.opcode = opcode
|
instruction.opcode = opcode
|
||||||
instruction.A = _get_bits(data, 6, 8)
|
instruction.A = _get_bits(data, 6, 8) # starts after POS_OP + SIZE_OP (6), with a size of 8
|
||||||
|
|
||||||
if instruction.type == InstructionType.ABC:
|
if instruction.type == InstructionType.ABC:
|
||||||
instruction.B = _get_bits(data, 23, 9)
|
instruction.B = _get_bits(data, 23, 9) # starts after POS_C + SIZE_C (23), with a size of 9
|
||||||
instruction.C = _get_bits(data, 14, 9)
|
instruction.C = _get_bits(data, 14, 9) # starts after POS_A + SIZE_A (14), with a size of 9
|
||||||
elif instruction.type == InstructionType.ABx:
|
elif instruction.type == InstructionType.ABx:
|
||||||
instruction.B = _get_bits(data, 14, 18)
|
instruction.B = _get_bits(data, 14, 18) # starts after POS_A + SIZE_A (14), with a size of 18
|
||||||
elif instruction.type == InstructionType.AsBx:
|
elif instruction.type == InstructionType.AsBx:
|
||||||
instruction.B = _get_bits(data, 14, 18) - 131071
|
instruction.B = _get_bits(data, 14, 18) - 131071 # Bx is now signed, so just sub half of the MAX_UINT for 18 bits
|
||||||
|
|
||||||
chunk.appendInstruction(instruction)
|
chunk.appendInstruction(instruction)
|
||||||
|
|
||||||
@ -247,7 +248,8 @@ class LuaUndump:
|
|||||||
for i in range(num):
|
for i in range(num):
|
||||||
chunk.appendProto(self.decode_chunk())
|
chunk.appendProto(self.decode_chunk())
|
||||||
|
|
||||||
# debug stuff
|
# debug stuff, maybe i'll add this to chunks to have better disassembly annotation in the future?
|
||||||
|
# eh, for now just consume the bytes.
|
||||||
|
|
||||||
# line numbers
|
# line numbers
|
||||||
num = self.get_int()
|
num = self.get_int()
|
||||||
|
Loading…
Reference in New Issue
Block a user