Snes game debugging/disassembling question. (memory address)

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Snes game debugging/disassembling question. (memory address)
by on (#200974)
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:
$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
Re: Snes game debugging/disassembling question. (memory addr
by on (#200975)
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.
Re: Snes game debugging/disassembling question. (memory addr
by on (#200978)
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...
Re: Snes game debugging/disassembling question. (memory addr
by on (#200983)
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.
Re: Snes game debugging/disassembling question. (memory addr
by on (#201002)
Or D as a third index register, pointing to the current actor/entity/object's properties.
Re: Snes game debugging/disassembling question. (memory addr
by on (#201013)
Still a little surprising (maybe, I guess) that, if they took that strategy, they didn't ensure that those structures were page-aligned.
Re: Snes game debugging/disassembling question. (memory addr
by on (#201014)
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?
Re: Snes game debugging/disassembling question. (memory addr
by on (#201017)
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.
Re: Snes game debugging/disassembling question. (memory addr
by on (#201029)
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 :)