EmbDev.net

Forum: ARM programming with GCC/GNU tools how to use arm and thumb


von marciano (Guest)


Rate this post
useful
not useful
I need use arm and thumb is same program , how to make this.

eg.

asm code startup :

                .text
    .arm

    .global _startup
    .func   _startup

_startup:
                ldr    sp,=value
                ldr    r10,=main
          adr    lr, __main_exit
                bx     r10
__main_exit:    B       __main_exit


    .size   _startup, . - _startup
    .endfunc


                .global Sub_func
                .func   Sub_func

Sub_func:
                code here

                .size   Sub_func, . - Sub_func
    .endfunc

.equ value , 0x01000000
.end

C code thumb :



int main(void)
{
 int x , y ;
 Sub_func();  <--- function in arm mode , how to call this function ?
 x = 10 ;
}

von Martin Thomas (Guest)


Rate this post
useful
not useful
marciano wrote:
> I need use arm and thumb is same program , how to make this.

Search the gcc documentation for -mthumb and -mthumb-interwork.


> C code thumb :
>
> int main(void)
> {
>  int x , y ;
>  Sub_func();  <--- function in arm mode , how to call this function ?
>  x = 10 ;
> }

With the versions of the toolchain I know it's not possible to write
code which should be compiled for ARM mode in the same source-file as
code which should be compiled for THUMB-mode. To call code compiled in
one code (i.e. ARM) from code compiled in another mode (i.e. Thumb)
compile and link with interworking enabled. Maybe the makefiles from my
WinARM example-collection can serve as examples. In short: compile the
source with the main()-code with -mthumb and -mthumb-interwork and
compile the source with Sub_func() only with -mthumb-interwork (not
special switch for ARM-mode needed - it's default).

Martin Thomas

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.