#310 - sgeos - Mon Jan 06, 2003 4:23 am
Let's say I have three tilesets that I want to start at 0801:0000, 0802:0000 and 0803:0000 in the ROM after it is compiled. How should I go about doing this? I'd be happy to see solutions for ASM and C if they exist.
-Brendan
#313 - Touchstone - Mon Jan 06, 2003 5:06 am
In asm you have the .ORG directive (origin perhaps?) that let you set the location of whatever comes after the directive. I think this mess up objcopy though so you'll end up with a 92MB bin file. :)
If you are using a linker script you can create a new section (like text, bss or data) and then assign your variable to that new section.
Specify a new section in your linkerscript like so:
Code: |
.my_section :
{
__my_section_start = 0x08010000;
*(.my_section)
*(.my_section.*)
} = 0xff
__my_section_end = .; |
Then in your C code, in order to assign your variable to that specific section you do:
Code: |
char MyDeluxeData[0x100] __attribute__ ((section ("my_section"))) = { 0, .. }; |
The variable have to be initialized for the __attribute__ to take effect.
To have an assembler symbol in a specific section I think you do: Code: |
.section .my_section
MyDeluxeData:
.word 0
... |
I'm not sure that my snippet of linker script works but it gives you the general idea anyways.
#315 - sgeos - Mon Jan 06, 2003 5:25 am
Thanks. I'm sure I'll figure it out. Just needed to be pointed in the right direction. I've used C for years and I've never seen anything like that. Then again I always coding for a PC where nobody (at least me) cares what exact address anything is at.
-Brendan
#318 - Touchstone - Mon Jan 06, 2003 5:47 am
Both the linker script and variable attribute are GNU specific so if you haven't used gcc before then that might be the reason why you haven't seen it. :) And like you say, nowadays it's not that important where things end up.
To be honest I can't figure out why you would want your data to be in a specific location in the ROM either unless you where to access the data via an absolut adress instead of a symbol. Unless of course you where to enter the source adress of tiledata in a script file for instance but since no data on the agb will change once you've done your build you can have the level designers write little c-files that use the c symbols instead of hardcoded adresses. That's what I do anyways and it works like a charm.
#343 - sgeos - Mon Jan 06, 2003 6:07 pm
I don't recall using anything other than gcc, but I've never needed to use a linker script. I guess now is the time to learn about them. =) Where might I find good documentation on them?
As for why do I want my data to be in a specific location? I'm designing a combo map/tile/palette/font editor. The idea is that the stuff you make can be saved to SRAM, binary dumped and converted into c/asm files and then recompiled into the ROM so that the SRAM can be used to make new stuff. I want the data in ROM to be in easy to remember locations just in case anybody wants to dump it. It will probably be made in ASM- less programs can mess things up that way.
I'll start coding after the interface/design is complete and I figure out how I want to slice up SRAM.
-Brendan
#356 - Touchstone - Mon Jan 06, 2003 8:28 pm
Oh, ok. Here you have the complete linker documentation http://www.gnu.org/manual/ld-2.9.1/, I'm sure you can find something usefull on linkerscripts there.
#367 - sgeos - Mon Jan 06, 2003 9:58 pm
Thanks!
-Brendan