Switch between ARM instruction set <-> Thumb instruction set

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hello,

can someone explain me how to switch between ARM instruction set
and Thumb insturction set. Can i do this on the fly, e.g. subroutine in
thumb
else in ARM ? Or is there a external pin used for this ?
Or is there a processor version for each mode ?

Greetings,

          Martin



Re: Switch between ARM instruction set <-> Thumb instruction set

Quoted text here. Click to load it

Look up the blx instruction.

--
- Mark ->
--

Re: Switch between ARM instruction set <-> Thumb instruction set

Quoted text here. Click to load it

You need to compile/assemble everything with the 'interwork'
switch.  The first instruction after an interrupt must be in ARM,
few people would ever get any thumb code to work if it weren't
simple

Quoted text here. Click to load it

It jumps to a 'veneer' which does the 'conversion' for you.
some debuggers hide this jump and some don't.

Quoted text here. Click to load it

There's a processor mode (I think), is this what you mean?

Tim



Quoted text here. Click to load it


Re: Switch between ARM instruction set <-> Thumb instruction set

Quoted text here. Click to load it

The usual way to enter Thumb mode is 'bx rN' command with LSB of rN set to
1.  There is also 'blx' command.


Quoted text here. Click to load it

Yes.  It is called interworking and is used widely.


Quoted text here. Click to load it

No.  Some ARM cores have Thumb mode in addition to ARM mode.  Others do not.


Visit http://www.arm.com , buy "ARM System Architecture" by Steve Furber
(ISBN 0-201-40352-8), subscribe to comp.sys.arm newsgroup, search for the
document "ARM Architecture Reference Manual" (ARM DDI0100E).  Have I missed
something? :)


  Vadim

Re: Switch between ARM instruction set <-> Thumb instruction set
Quoted text here. Click to load it

// The cores that use a "T" such as ARM7 "T"DMI support the Thumb mode. //
Quoted text here. Click to load it

Re: Switch between ARM instruction set <-> Thumb instruction set

Quoted text here. Click to load it

The key is the bx instruction. If the least significant bit of the target
address is an one, the processor will switch to Thumb mode. Similarly, if
the bit is a zero, the processor will switch to ARM mode.

The address saved in lr by the Thumb subroutine call (bl) has the least
significant bit on, so a subroutine return with a bx returns to the proper
mode.

In newer processors, there is also the blx instruction, which is a
combination of the bl and bx instructions: it saves the return address into
lr and then works just as the bx instruction.

If the processor does not support the blx instruction, it can be
functionally replaced by a subroutine consisting of the bx instruction only:
the subroutine call saves the return address and the bx instruction
dispatches to the proper address and mode.

The ARM family compilers support an ARM/Thumb interworking mode which makes
the inter-module transfers with bx instructions, so that a mode change is
done when needed. The interworking mode has some inherent overhead, so it's
not always recommended. With care it's possible to write code with both ARM
and Thumb modes without selecting interworking in the compiler command.

The GNU tool set supports an assembler directive (thumb_proc) to tell the
linker that a symbol is in Thumb code, so the linker is able to add the
Thumb bit at link time.

HTH

Tauno Voipio
tauno voipio @ iki fi





Re: Switch between ARM instruction set <-> Thumb instruction set
Quoted text here. Click to load it

.thumb_func not .thumb_proc. There is also .thumb (aka ".code 16")

Obviously you can just compile C code with the compiler option -mthumb
and, since GNU also supports interworking, optionally -mthumb-interwork.

Jifl
--
--["No sense being pessimistic, it wouldn't work anyway"]-- Opinions==mine

Site Timeline