#129586 - Noda - Wed May 23, 2007 11:44 pm
well, I need some to use some arm instructions in my code (like smull), how can I switch to arm mode only for those part and compile the rest with thumb mode?
is there a gcc pragma or so?
thanks
#129595 - tepples - Thu May 24, 2007 1:59 am
In C, you give arm-eabi-gcc the compiler flags -marm -mthumb-interwork. No, I don't know how to force this in wintermute's automagic makefile.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#129600 - Dwedit - Thu May 24, 2007 2:39 am
If you want to hand-code it, you can just use an ASM block containing bx, .arm, then a bunch of ARM code, be sure to .thumb before the block ends.
Otherwise, you'd probably need to make a separate C file for ARM code. Just use -marm when you compile it.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#129609 - Lick - Thu May 24, 2007 8:43 am
I think nowadays you leave out -mthumb and it will automatically be compiled as ARM.
_________________
http://licklick.wordpress.com
#129611 - Noda - Thu May 24, 2007 9:09 am
Thanks, but I already knew that.
My problem is that I'd like to have for example one function to be compiled in ARM mode as it contains inline ARM asm, then the rest in thumb mode.
I tried searching for GCC pragma, but it's seems there's no one for my needs.
I'll try dwedit idea, by inserting asm(".arm") & .thumb asm instructions where it's needed, and compile with .thumb.
#129613 - kusma - Thu May 24, 2007 9:17 am
GCC can't mix ARM and THUMB within the same compilation unit. GAS should be able to, but then you'd need to write the code in question in assembly.
#129626 - tepples - Thu May 24, 2007 1:18 pm
Noda wrote: |
My problem is that I'd like to have for example one function to be compiled in ARM mode as it contains inline ARM asm, then the rest in thumb mode. |
Is it too hard for that one function that uses ARM inline assembly to be put into its own file?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#129628 - silent_code - Thu May 24, 2007 1:26 pm
just make a "container" function that wraps around the inline asm block and put that into a seperate .c file. or simply write that wrapper directly into an asembler .s file.
#129636 - Noda - Thu May 24, 2007 2:18 pm
tepples wrote: |
Noda wrote: | My problem is that I'd like to have for example one function to be compiled in ARM mode as it contains inline ARM asm, then the rest in thumb mode. |
Is it too hard for that one function that uses ARM inline assembly to be put into its own file? |
Indeed, yes, as it's not a full asm function, but a one that use some inline assembly mixed with c code, where the assembly part are defined by macros defined somewhere else... Yes it's quite compicated but it's not my code (it's the helix mp3 fixed point decoder)
#129651 - Dwedit - Thu May 24, 2007 5:51 pm
Inline ASM? That's really easy to change to ARM mode.
__asm__ volatile (
"adr r3,jumphere\n\t"
"bx r3\n\t"
".code 32\n"
"jumphere:\n\t"
"@arm code goes here\n\t"
"adr r3,jumpout+1\n\t"
"bx r3\n\t"
".code 16\n"
"jumpout:",...,...,...);
Only thing though, when using labels in inline ASM, you must mark the function as noinline, otherwise it will try to inline it several times, and complain about duplicate labels.
This example won't work for the times when you need a small amount of ASM code as arm though, just use a separate c file.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."