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 ?
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
It jumps to a 'veneer' which does the 'conversion' for you. some debuggers hide this jump and some don't.
There's a processor mode (I think), is this what you mean?
The usual way to enter Thumb mode is 'bx rN' command with LSB of rN set to
There is also 'blx' command.
Yes. It is called interworking and is used widely.
No. Some ARM cores have Thumb mode in addition to ARM mode. Others do not.
Visit
formatting link
, 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? :)
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.
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.