how to use arm and thumb

Guest #1172081
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 ;
}
Guest #1172082
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

A question of your own? This thread is over 19 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.