Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to use thumb mode ?

Status
Not open for further replies.
Just use Branch instruction to switch from ARM mode to Thumb mode.

This example shows how ARM and THUMB can be used to switch state and assemble both ARM and Thumb instructions in a single area.
Code:
 AREA ToThumb, CODE, READONLY    ; Name this block of code
        ENTRY                           ; Mark first instruction to execute
        ARM                             ; Subsequent instructions are ARM 
start
        ADR     r0, into_thumb + 1      ; Processor starts in ARM state 
        BX      r0                      ; Inline switch to Thumb state
        THUMB                           ; Subsequent instructions are Thumb
into_thumb
        MOVS    r0, #10                 ; New-style Thumb instructions

The above code is taken from Here.
 

hi sir i am using embedded c but whatever you posted here looks like assembly .... is it possible to use above instructions in embedded c program?
 

ARM state can be set deliberately. Inline assembly language can be included in a source file that contains code to be compiled for Thumb in ARMv6 and lower, by enclosing the functions containing inline assembler code between #pragma arm and #pragma thumb statements. For example:

Code:
...         // Thumb code
#pragma arm // ARM code. Switch code generation to the ARM instruction set so
            // that the inline assembler is available for Thumb in ARMv6 and lower.

int add(int i, int j)
{
    int res;
    __asm
    {
        ADD   res, i, j   // add here
    }
    return res;
}
#pragma thumb   // Thumb code. Switch back to the Thumb instruction set.
                // The inline assembler is no longer available for Thumb in ARMv6 and
                // lower.

This above code is copied from here
 

It is to indicate that the inline assembly is not supporting Thumb mode for processor version before ARM7.

For ARMv6 and lower architectures, the inline assembler does not assemble any Thumb instructions.
 

Thumb-2 is the superset of Thumb instruction. Thumb2 instructions are 32-bit, but don't confuse it with ARM instructions.

The most important difference between the Thumb-2 instruction set and the ARM instruction set is that most Thumb-2 instructions are unconditional, where as almost all ARM instructions can be conditional. However, Thumb-2 introduces a new conditional execution instruction, IT, that is a logical if-then-else function.
Thumb-2 has the performance close to or better than that of the ARM instruction set and has the code density of the original Thumb ISA.

Check out this link for some Details.


LPC1768 wrks on this Thumb-2 instruction set,
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top