Snes game debugging/disassembling question. (memory address)

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Post Reply
ittyBittyByte
Posts: 24
Joined: Sun Dec 18, 2016 1:11 pm

Snes game debugging/disassembling question. (memory address)

Post by ittyBittyByte »

I was trying to debug a SNES game to figure out how it worked, I set a breakpoint for the when $000BAA is read or written. When the breakpoint happened this is what I got:

Code: Select all

$81/99D7 A5 02       LDA $02    [$00:0BAA]   A:0000 X:00FF Y:0040 P:envMXdiZc
I'm a bit confused; how does A5 02 / LDA $02 relate to the memory address $000BAA being read from or written to? It's not in A X or Y either... the only thing related to the memory address I specified is inside the [] square brackets, and I'm not sure what exactly that's supposed to mean.

I'm using a random snes9x debugger ( that I found at http://geigercount.net/crypt/ ), the debugger works fine though I'm just confused about this part. Can someone tell me what the square brackets mean and how that line could relate to the memory address I set a read/write breakpoint for? Thanks.

Image
lidnariq
Posts: 11429
Joined: Sun Apr 13, 2008 11:12 am

Re: Snes game debugging/disassembling question. (memory addr

Post by lidnariq »

The SNES has a 16-bit register "D" which is added to every single-byte address.

IF D is $0BA8 at the moment that the breakpoint is triggered, that would explain what you see.

On the other hand, setting D to a value with the lower 8 bits nonzero makes it slower, so I'd be a little surprised if they did that.
ittyBittyByte
Posts: 24
Joined: Sun Dec 18, 2016 1:11 pm

Re: Snes game debugging/disassembling question. (memory addr

Post by ittyBittyByte »

Yes, that was it, thank you! I'm guessing the [] means "final memory address" or something like that. I didn't know SNES had a D register as I mostly just know ASM carried over from NES...
niconii
Posts: 219
Joined: Sun Mar 27, 2016 7:56 pm

Re: Snes game debugging/disassembling question. (memory addr

Post by niconii »

lidnariq wrote:On the other hand, setting D to a value with the lower 8 bits nonzero makes it slower, so I'd be a little surprised if they did that.
If it was written in C, it could be using D as a frame pointer or something.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Snes game debugging/disassembling question. (memory addr

Post by tepples »

Or D as a third index register, pointing to the current actor/entity/object's properties.
adam_smasher
Posts: 271
Joined: Sun Mar 27, 2011 10:49 am
Location: Victoria, BC

Re: Snes game debugging/disassembling question. (memory addr

Post by adam_smasher »

Still a little surprising (maybe, I guess) that, if they took that strategy, they didn't ensure that those structures were page-aligned.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Snes game debugging/disassembling question. (memory addr

Post by tepples »

There are 32 pages in low RAM. If an object's state takes (say) 32 bytes, what is done with the other 224 bytes in the page?
Optiroc
Posts: 129
Joined: Thu Feb 07, 2013 1:15 am
Location: Sweden

Re: Snes game debugging/disassembling question. (memory addr

Post by Optiroc »

Stack relative addressing takes the same number of cycles as non-aligned DP addressing, IIRC – so that's a good alternative since then you also get fast access to scratchpad RAM. But for "heap object" access, DP-relative addressing is quite elegant.

Also, stack relative access is rather starved on available instructions.
adam_smasher
Posts: 271
Joined: Sun Mar 27, 2011 10:49 am
Location: Victoria, BC

Re: Snes game debugging/disassembling question. (memory addr

Post by adam_smasher »

tepples wrote:There are 32 pages in low RAM. If an object's state takes (say) 32 bytes, what is done with the other 224 bytes in the page?
Whatever you want, so long as it doesn't need to be page-aligned :)
Post Reply