This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

inline assembly for cortex m3

Hi
I want to use uc/Probe for LPC1768 and I have difficulty porting this function to cortex.

static CPU_INT32U ProbeDCC_RdCtrl (void)
{ __asm{ mrc P14,0,R0,C0,C0}
}

The compiler generate this error

probe_dcc.c(140): error: #1113: Inline assembler not permitted when generating Thumb code

And when I include #pragma arm and #pragma thumb it will generate this error

probe_dcc.c(137): error: #1114-D: this feature not supported on target architecture/processor

Do you have any idea how to implement the above function?
Regards

  • Hi Ali
    Hope by this time you have solved it.

    This valid for Cortex M3.
    #pragma is not supported by Cortex as it only supports thumb-2 instruction set.
    ARM and Thumb instruction set are not valid.

    This can be done by a function"__asm int aks(void);"

    A demo code is given below:

    
    #include <stm32f10x_lib.h>
    #include "stm32_Init.h"
    
    __asm int fn_add(void);          // prototype declaration
    
    int main (void)
    {
    fn_add();                         // Function call
    }
    
    __asm int fn_add(void)            // Function defination
    {
     MOV R2,#0x0000ffff;
     MOV R3,#0x0000ffff;
     ADD r0,r2,r3;      The data has to be shifted as r0 is modified after this instruction.
     }