gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Memory address changes during a method call

#136180 - koryspansel - Sun Jul 29, 2007 10:18 pm

Hello all,

I'm hoping someone can provide some insight into a problem that caught me off guard. I have the following code:

Code:

void TileBackground::setTileSet(TileSetInstance* tileSet)
{
   iprintf("setTileSet %0X8\n", tileSet);
   ...
}


Which I then call like this:

Code:

iprintf("tileSet %08X\n", tileSet);
tileBg->setTileSet(tileSet);


I don't believe the creation/initialization of the objects matters much, it's the memory location of the tileSet object. What I've been seeing in the emulator is a memory address of 0x02019508 before the call to setTileSet, but an address of 0x20195088 during the call. I thought that it might be a mirrored address, but it looks like the variables contained in the tileSet object are also different during the call, and these variable should never change.

Any ideas on what might be going on here? Some weird alignment issue? Stack corruption? Lack of knowing what the hell I'm doing? Any help appreciated. Thanks.

--
Kory

#136188 - tepples - Sun Jul 29, 2007 11:02 pm

koryspansel wrote:
I have the following code:

Code:

   iprintf("setTileSet %0X8\n", tileSet);

[...]
Code:

iprintf("tileSet %08X\n", tileSet);

[...]
What I've been seeing in the emulator is a memory address of 0x02019508 before the call to setTileSet, but an address of 0x20195088 during the call.

In the two format strings, does the 8 come before or after the X?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#136198 - koryspansel - Mon Jul 30, 2007 1:01 am

Wow! Do I feel like an idiot. Thanks for the catch on that one. The funny thing is that it's only debugging code, but the results I was seeing made it look like this could be the problem. Oh well, more hunting i guess...

Thanks again!

--
Kory