Disassembler on nes emulator

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
RomarioSilva
Posts: 7
Joined: Sat Nov 12, 2016 6:03 am

Disassembler on nes emulator

Post by RomarioSilva »

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!
User avatar
nesrocks
Posts: 563
Joined: Thu Aug 13, 2015 4:40 pm
Location: Rio de Janeiro - Brazil
Contact:

Re: Disassembler on nes emulator

Post by nesrocks »

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.
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!
https://www.patreon.com/bitinkstudios <- Support me on Patreon!
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: Disassembler on nes emulator

Post by dougeff »

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.
nesdoug.com -- blog/tutorial on programming for the NES
RomarioSilva
Posts: 7
Joined: Sat Nov 12, 2016 6:03 am

Re: Disassembler on nes emulator

Post by RomarioSilva »

Thx for the help.
RomarioSilva
Posts: 7
Joined: Sat Nov 12, 2016 6:03 am

Re: Disassembler on nes emulator

Post by RomarioSilva »

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.
User avatar
Quietust
Posts: 1918
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: Disassembler on nes emulator

Post by Quietust »

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.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Disassembler on nes emulator

Post by Oziphantom »

Negative Flag = bit 7

$80 N = 1
$7F N = 0

There is no "logic" behind it.
RomarioSilva
Posts: 7
Joined: Sat Nov 12, 2016 6:03 am

Re: Disassembler on nes emulator

Post by RomarioSilva »

Thx guys. :D
na_th_an
Posts: 558
Joined: Mon May 27, 2013 9:40 am

Re: Disassembler on nes emulator

Post by na_th_an »

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).
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: Disassembler on nes emulator

Post by Oziphantom »

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.
Post Reply