2008/8/27 Aaron P. D'Souza <[EMAIL PROTECTED]> > > hello: > > one small question regarding use of ARM inline assembly code in a > C file that has been compiled for Thumb mode. > > is it possible to use ARM assembly code from within a C file that > has been compiled for Thumb and Thumb interworking?
The easiest way would be to just write an assembler file with: .global function_f .arm function_f: mrs r0, cpsr msr cpsr_c, r0 bx lr ... if you provide the correct cpu and interwork flags during the assemble/link phases, this will get interworking veeners and thus will be called correctly from both arm and thumb code. If that's not an option, then you probably would need to do something like this: void function_f(void) { register int x; #ifdef __thumb__ register int y; #endif asm volatile ( #ifdef __thumb__ ".align 2\n" "bx pc\n" "nop\n" ".arm\n" #endif "mrs %0, cpsr \n\t" "msr cpsr_c, %0 \n\t" #ifdef __thumb__ "add %1, pc, #1\n" "bx %1\n" #endif : "=r" (x) #ifdef __thumb__ , "=r" (y) #endif ); }