nesdev.com
http://forums.nesdev.com/

Snes game debugging/disassembling question. (memory address)
http://forums.nesdev.com/viewtopic.php?f=12&t=16263
Page 1 of 1

Author:  ittyBittyByte [ Wed Jul 26, 2017 5:05 pm ]
Post subject:  Snes game debugging/disassembling question. (memory address)

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

Author:  lidnariq [ Wed Jul 26, 2017 5:13 pm ]
Post subject:  Re: Snes game debugging/disassembling question. (memory addr

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.

Author:  ittyBittyByte [ Wed Jul 26, 2017 5:28 pm ]
Post subject:  Re: Snes game debugging/disassembling question. (memory addr

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

Author:  Nicole [ Wed Jul 26, 2017 7:51 pm ]
Post subject:  Re: Snes game debugging/disassembling question. (memory addr

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.

Author:  tepples [ Thu Jul 27, 2017 7:16 am ]
Post subject:  Re: Snes game debugging/disassembling question. (memory addr

Or D as a third index register, pointing to the current actor/entity/object's properties.

Author:  adam_smasher [ Thu Jul 27, 2017 9:46 am ]
Post subject:  Re: Snes game debugging/disassembling question. (memory addr

Still a little surprising (maybe, I guess) that, if they took that strategy, they didn't ensure that those structures were page-aligned.

Author:  tepples [ Thu Jul 27, 2017 9:52 am ]
Post subject:  Re: Snes game debugging/disassembling question. (memory addr

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?

Author:  Optiroc [ Thu Jul 27, 2017 10:47 am ]
Post subject:  Re: Snes game debugging/disassembling question. (memory addr

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.

Author:  adam_smasher [ Thu Jul 27, 2017 12:37 pm ]
Post subject:  Re: Snes game debugging/disassembling question. (memory addr

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 :)

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/