how to use thumb mode ?

Status
Not open for further replies.

manoharn

Junior Member level 2
Joined
Jun 5, 2012
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Bangalore,India
Activity points
1,429
I am using LPC2148 please tell me how to enable thumb mode in embedded C and keil compiler.
 

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
 

ok sir thank you i will check once..

sir what is the meaning of this

Inline assembler Thumb instruction set restrictions in C and C++ code ....


is it means thumb instructions are not allowed in c and c++?



**broken link removed**
 

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.
 

thank u sir... i programed for this and executed but same changes will not allow in lpc1768?
 

sir then what is thumb-2 then? is it thumb and thumb 2 are same in cortex lpc1768?


please guide.
 

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


Check out this link for some Details.


LPC1768 wrks on this Thumb-2 instruction set,
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…