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.

C/C++ > C code to IWRAM

#90188 - Schultz - Wed Jun 28, 2006 9:19 pm

I am compiling my C code with the gcc compiler.
The code lies within the cartridge. I would, however, like to displace it so that it remains within the internal SRAM at address 0x03000000.
I do not wish to merge assembly routines within my code, although I know the ARM assembly.
What I need is to place the code in IWRAM making use solely of the C language and then run such code.
I am not looking foward to placing all the code in IWRAM. Only a few routines shall be placed.

Thanks in advance for your help.

#90202 - col - Wed Jun 28, 2006 10:08 pm

are you using one of the devkits? if so, which one?

#90208 - tepples - Wed Jun 28, 2006 10:48 pm

Put the files in a separate source code module (that is, separate .c file) and then compile them to an object file whose suffix is ".iwram.o". For example, compile mixer.c to mixer.iwram.o.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#90274 - Ant6n - Thu Jun 29, 2006 5:29 am

http://www.devrs.com/gba/files/gbadevfaqs.php#IntRamCode

#90323 - Schultz - Thu Jun 29, 2006 6:34 pm

I am using the standard DevKitAdv.
I acknolowdge the labelling of the object file as "*.iwram.o".
I, however, wish to, in addition, know how shall my code be setup in IWRAM. Shall it be put there by DMA or by normal copying?
Moreover, I really wish to have another option, such as a modifier in the prototype of a function or a command to do so.

Thanks in advance.

#90327 - tepples - Thu Jun 29, 2006 6:58 pm

Schultz wrote:
I am using the standard DevKitAdv.
I acknolowdge the labelling of the object file as "*.iwram.o".
I, however, wish to, in addition, know how shall my code be setup in IWRAM. Shall it be put there by DMA or by normal copying?

The init code (crt0.s) handles this for you.

Quote:
Moreover, I really wish to have another option, such as a modifier in the prototype of a function or a command to do so.

There are keywords to specify which section a particular function's object code will be placed in. But those keywords aren't very useful because GCC does not support switching instruction sets within a module. In general, you want all code in IWRAM to use the ARM instruction set, and you want all code outside of IWRAM to use the Thumb instruction set. So you might as well compile everything *.iwram.o as ARM and everything else as Thumb. In fact my makefiles have a rule to do just that.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#90477 - Schultz - Fri Jun 30, 2006 11:46 am

I have compiled the code as indicated.
My object files to be placed in the IWRAM have been compiled with the -arm option and have been output to a *.iwram.o file.
Nevertheless, when I compiled the main module with the option -mthumb,
several errors raised indicating an ARM code calling a THUMB code.
Futhermore, after compiling the main module with -marm, I checked the code linked by the *.iwram.o has been placed in the cartridge ROM instead of the IWRAM via VBA's disassemble tool.
Why have the code not been placed in IWRAM?
How shall I link ARM code with THUMB code?
Please help.

Thanks in advance.

#90482 - chishm - Fri Jun 30, 2006 1:09 pm

If you are using the arm-elf-* versions of the devkitpro tools, you need to specify -interwork for arm code and -thumb-interwork (or something similar, I can't remember the exact syntax) for thumb code when compiling, instead of -arm or -thumb. For arm-eabi-*, I think it shouldn't need interworking specified.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com

#90786 - yuriks - Sun Jul 02, 2006 1:04 pm

You are using devkitAdv, upgrade to devkitPro (devkitARM)
_________________
---yuriks---