EmbDev.net

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


Author: marciano (Guest)
Posted on:

Rate this post
0 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 ;
}

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 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

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.