Page 1 of 1
Snes game debugging/disassembling question. (memory address)
Posted: Wed Jul 26, 2017 5:05 pm
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.

Re: Snes game debugging/disassembling question. (memory addr
Posted: Wed Jul 26, 2017 5:13 pm
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.
Re: Snes game debugging/disassembling question. (memory addr
Posted: Wed Jul 26, 2017 5:28 pm
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...
Re: Snes game debugging/disassembling question. (memory addr
Posted: Wed Jul 26, 2017 7:51 pm
by Nicole
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
Posted: Thu Jul 27, 2017 7:16 am
by tepples
Or D as a third index register, pointing to the current actor/entity/object's properties.
Re: Snes game debugging/disassembling question. (memory addr
Posted: Thu Jul 27, 2017 9:46 am
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.
Re: Snes game debugging/disassembling question. (memory addr
Posted: Thu Jul 27, 2017 9:52 am
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?
Re: Snes game debugging/disassembling question. (memory addr
Posted: Thu Jul 27, 2017 10:47 am
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.
Re: Snes game debugging/disassembling question. (memory addr
Posted: Thu Jul 27, 2017 12:37 pm
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
