Hi there
I've recently started writing an NES disassembler. Recently as in... today!
I have a decent (I hope) surface-level knowledge of the 6502, but not enough to do any serious game development. I was hoping you could give me some help regarding the decoding/processing of opcodes.
I'm working through Dougeff's python code. which utilises a large case-statement:
I'm assuming byte1 is the opcode/operator itself, as it's being used as the switch value. Could someone please let me know what bytes 2 and 3 represent? I assume byte 2 is the operand. The parts I'm most unsure about are the cases which use the count2 variable:
The common denominator here is that all of these (count2 cases) are branch instructions. Is byte2 the offset for the branch? I'm assuming (again) that the range-checking of y is to do with page-boundaries? I'm still unsure about the rest of the code in this excerpt though. There's some array slicing and zero padding going on, but it's fairly impenetrable with my current level of knowledge. i get the feeling I'm going to kick myself though, because I know it's a slice of something from the second index onwards, padded with zeros, and converted to hex...
Thanks in advance. Any wisdom bestowed is greatly appreciated!
I've recently started writing an NES disassembler. Recently as in... today!
I have a decent (I hope) surface-level knowledge of the 6502, but not enough to do any serious game development. I was hoping you could give me some help regarding the decoding/processing of opcodes.
I'm working through Dougeff's python code. which utilises a large case-statement:
Code:
def ToASM(byte1,byte2,byte3):
global count
global currentBank
count2 = 0
if byte1 == "00":
return ("\tbrk\t\t\t\t; 00") # none
global count
global currentBank
count2 = 0
if byte1 == "00":
return ("\tbrk\t\t\t\t; 00") # none
I'm assuming byte1 is the opcode/operator itself, as it's being used as the switch value. Could someone please let me know what bytes 2 and 3 represent? I assume byte 2 is the operand. The parts I'm most unsure about are the cases which use the count2 variable:
Code:
elif byte1 == "10":
y = int(byte2, 16)
if y > 127:
y -= 256
count2 = count + y + 2
z = str(hex(count2))
z = z[2:]
z = z.zfill(4)
count += 1
return ("\tbpl B" +currentBank+"_"+ z + " ; 10 " + byte2) # Relative
y = int(byte2, 16)
if y > 127:
y -= 256
count2 = count + y + 2
z = str(hex(count2))
z = z[2:]
z = z.zfill(4)
count += 1
return ("\tbpl B" +currentBank+"_"+ z + " ; 10 " + byte2) # Relative
The common denominator here is that all of these (count2 cases) are branch instructions. Is byte2 the offset for the branch? I'm assuming (again) that the range-checking of y is to do with page-boundaries? I'm still unsure about the rest of the code in this excerpt though. There's some array slicing and zero padding going on, but it's fairly impenetrable with my current level of knowledge. i get the feeling I'm going to kick myself though, because I know it's a slice of something from the second index onwards, padded with zeros, and converted to hex...
Thanks in advance. Any wisdom bestowed is greatly appreciated!