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.

Beginners > Where is my data located?

#10189 - Aizz - Fri Aug 29, 2003 8:37 am

I think this problem should be a little easy for you, but I still hope you can help me out.
In a programme, I define the variables in different ways:
Code:

  const UCHAR var_1[3]={1,2,3}; //  UCHAR=u8
  UCHAR var_2[3]={1,2,3};
  void main()
  {
    UCHAR var_3[3]={1,2,3};
    ...
  }
 

I think var_3[] should be located somewhere in WRAM, cause it will be constructed in runtime. But:
1. What about var_1[] and var_2[]? Are they located in WRAM or ROM or somewhere else?
2. If I want to place my data in ROM(NOT RAM), how should I do? And how can I get it from ROM?

(I write my programme in C, so if you have some code segment, leave it in C/C++ may be great helpful to me, please.)

Great thanks to anyone reply this topic.

===================
Parden me for my poor English...

#10190 - Lupin - Fri Aug 29, 2003 8:59 am

const UCHAR var_1[3]={1,2,3}; // ROM
UCHAR var_2[3]={1,2,3}; // WRAM (I think it's put in EWRAM)
void main()
{
UCHAR var_3[3]={1,2,3}; //Stack space
...
}

I think this is correct, but it always depends on your linker script though.

#10195 - Aizz - Fri Aug 29, 2003 10:46 am

To Lupin:
So you means that if I want to put some data in ROM, I just need to set the data to const, right? If so, that should be very convnience...

Linker script? I have no idea about it, though I've seen it somewhere, maybe someone can give me a clear explaination or a link is also OK.

==================
Parden me for my poor English...

#10202 - Lupin - Fri Aug 29, 2003 1:35 pm

Basically you don't need to modify something in the linker script, it just does it job and put all the code where it should go.

The linker script provided with GCC is all you need, because it doesn't manipulate the actual code...

#10264 - Aizz - Mon Sep 01, 2003 2:03 am

>>The linker script provided with GCC is all you need, because it doesn't
>>manipulate the actual code...

Hehe, still in a mess... Anyway, thanks a lot.