Disassembler on nes emulator

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Disassembler on nes emulator
by on (#195160)
hey people, i'm have some problems with disassembly some opcodes.
someone have any sugestions or online dissasembler, because i cant use then correctly.
thx!
Re: Disassembler on nes emulator
by on (#195165)
I have succesfully disassembled the whole ghostbusters rom into reassemblable code using disasm and asm6. There were minor edits and tweaks that had to be done.
Re: Disassembler on nes emulator
by on (#195169)
If the ROM is bigger than NROM, you probably need to split the ROM into smaller chunks, before disassembling with disasm.

I wrote a disassembler, but it's not as advanced as disasm, except that it breaks the ROM into smaller chunks for you. (requires Python 3). Also, requires a complete NES file, with correct header.

https://github.com/nesdoug/NES-DISASSEMBLER


That reminds me, I forgot about the pull request. Hmm.
Re: Disassembler on nes emulator
by on (#195743)
Thx for the help.
Re: Disassembler on nes emulator
by on (#195744)
I have one ask.
int numbers of 8 bits, are represent as: 0 - 255 or (-128(negative) to 127(positive)), because i'm have some problems to set negative flag.
Re: Disassembler on nes emulator
by on (#195745)
RomarioSilva wrote:
int numbers of 8 bits, are represent as: 0 - 255 or (-128(negative) to 127(positive))

To the 6502, values in memory and registers are simultaneously signed and unsigned - no matter what operation you do on them, the result is exactly the same, and the processor Flags will be set for both cases (e.g. ADC will update both C for unsigned Carry and V for signed Overflow).

In a disassembler you should pretty much always display numbers as unsigned, preferably in hexadecimal. It's up to the person reading the disassembly to interpret things further.
Re: Disassembler on nes emulator
by on (#195748)
Negative Flag = bit 7

$80 N = 1
$7F N = 0

There is no "logic" behind it.
Re: Disassembler on nes emulator
by on (#195804)
Thx guys. :D
Re: Disassembler on nes emulator
by on (#196309)
Well, in fact there *is* logic behind it. 80-FF are negative numbers because of the used notation, two's complement. One of the main advantages about it is that you can consider a byte value unsigned or signed depending on the context; arithmetic operations will always make sense. If you substract 04 from 01, the result is FD ('cause past 0, you start over: 1->0->FF->FE->FD), which, in two's complement, is -3.

The N flag is just an aid to the programmer, and it is kind of copied from bit 7 of the value in the accumulator after certain instructions (as negative numbers, 80-FF, all have bit 7 set).
Re: Disassembler on nes emulator
by on (#196483)
Sorry, by Logic I was refereeing to Logic Gates. I.E the N is just a mirror of the 7th bit, there are no AND/OR/NOR/NAND logic involved in determining its value. Although as you point out there is a gate to enable the copy as it only happens on some instructions.