It is currently Sat Sep 23, 2017 8:22 pm

All times are UTC - 7 hours



Forum rules


Related:



Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Wed Jul 26, 2017 5:05 pm 
Offline

Joined: Sun Dec 18, 2016 1:11 pm
Posts: 22
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


Top
 Profile  
 
PostPosted: Wed Jul 26, 2017 5:13 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6178
Location: Seattle
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.


Top
 Profile  
 
PostPosted: Wed Jul 26, 2017 5:28 pm 
Offline

Joined: Sun Dec 18, 2016 1:11 pm
Posts: 22
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...


Top
 Profile  
 
PostPosted: Wed Jul 26, 2017 7:51 pm 
Offline

Joined: Sun Mar 27, 2016 7:56 pm
Posts: 136
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.


Top
 Profile  
 
PostPosted: Thu Jul 27, 2017 7:16 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19004
Location: NE Indiana, USA (NTSC)
Or D as a third index register, pointing to the current actor/entity/object's properties.


Top
 Profile  
 
PostPosted: Thu Jul 27, 2017 9:46 am 
Online

Joined: Sun Mar 27, 2011 10:49 am
Posts: 186
Still a little surprising (maybe, I guess) that, if they took that strategy, they didn't ensure that those structures were page-aligned.


Top
 Profile  
 
PostPosted: Thu Jul 27, 2017 9:52 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19004
Location: NE Indiana, USA (NTSC)
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?


Top
 Profile  
 
PostPosted: Thu Jul 27, 2017 10:47 am 
Offline

Joined: Thu Feb 07, 2013 1:15 am
Posts: 94
Location: Sweden
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.


Top
 Profile  
 
PostPosted: Thu Jul 27, 2017 12:37 pm 
Online

Joined: Sun Mar 27, 2011 10:49 am
Posts: 186
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 :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: adam_smasher, nicklausw and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group