1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Switch between ARM instruction set <-> Thumb instruction set

Discussion in 'Embedded' started by Martin Maurer, Sep 4, 2003.

  1. 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
    else in ARM ? Or is there a external pin used for this ?
    Or is there a processor version for each mode ?


    Martin Maurer, Sep 4, 2003
    1. Advertisements

  2. Look up the blx instruction.
    Mark A. Odell, Sep 4, 2003
    1. Advertisements

  3. Martin Maurer

    tim Guest

    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
    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?

    tim, Sep 4, 2003
  4. The usual way to enter Thumb mode is 'bx rN' command with LSB of rN set to
    1. 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 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 Borshchev, Sep 4, 2003
  5. Martin Maurer

    Tauno Voipio Guest

    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

    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.


    Tauno Voipio
    tauno voipio @ iki fi
    Tauno Voipio, Sep 5, 2003
  6. Martin Maurer

    Schwob Guest

    // The cores that use a "T" such as ARM7 "T"DMI support the Thumb mode. //
    Schwob, Sep 5, 2003
  7. ..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.

    Jonathan Larmour, Sep 6, 2003
  8. Martin Maurer


    May 10, 2014
    Likes Received:
    switching from arm to thumb and vice versa

    You can use BX and BLX commands to switch between ARM and Thumb state.
    mov lr,pc; //arm state
    BX loop;

    loop add r0,#1; //thumb state
    BX lr;
    divyasijo, May 10, 2014
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.