@@ -210,16 +210,17 @@ def decode_chunk(self):
210
210
template = instr_lookup_tbl [opcode ]
211
211
instruction = Instruction (template .type , template .name )
212
212
213
+ # i read the lopcodes.h file to get these bit position and sizes.
213
214
instruction .opcode = opcode
214
- instruction .A = _get_bits (data , 6 , 8 )
215
+ instruction .A = _get_bits (data , 6 , 8 ) # starts after POS_OP + SIZE_OP (6), with a size of 8
215
216
216
217
if instruction .type == InstructionType .ABC :
217
- instruction .B = _get_bits (data , 23 , 9 )
218
- instruction .C = _get_bits (data , 14 , 9 )
218
+ instruction .B = _get_bits (data , 23 , 9 ) # starts after POS_C + SIZE_C (23), with a size of 9
219
+ instruction .C = _get_bits (data , 14 , 9 ) # starts after POS_A + SIZE_A (14), with a size of 9
219
220
elif instruction .type == InstructionType .ABx :
220
- instruction .B = _get_bits (data , 14 , 18 )
221
+ instruction .B = _get_bits (data , 14 , 18 ) # starts after POS_A + SIZE_A (14), with a size of 18
221
222
elif instruction .type == InstructionType .AsBx :
222
- instruction .B = _get_bits (data , 14 , 18 ) - 131071
223
+ instruction .B = _get_bits (data , 14 , 18 ) - 131071 # Bx is now signed, so just sub half of the MAX_UINT for 18 bits
223
224
224
225
chunk .appendInstruction (instruction )
225
226
@@ -247,7 +248,8 @@ def decode_chunk(self):
247
248
for i in range (num ):
248
249
chunk .appendProto (self .decode_chunk ())
249
250
250
- # debug stuff
251
+ # debug stuff, maybe i'll add this to chunks to have better disassembly annotation in the future?
252
+ # eh, for now just consume the bytes.
251
253
252
254
# line numbers
253
255
num = self .get_int ()
0 commit comments