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

keil uvision 5.22 inline assembly and main cpu register access

Hello
How to write inline assembly code in c file and access cpu R0-R31 registers?
I write something like:
__asm{

STRB R0,[R2,0#02]

}

but i face errors: expected [ or ].
Thanks.

Parents Reply Children
  • Hello
    I'm facing some new problem, when i write inline assembly code in my c code, the compiler removes it, and if i define volatile variables before assembly, compiler compiles again the assembly segment and generates more assembly code than i expect.

    c code:
    volatile uint32_t r0;
    . .
    __asm
    { mov r0,#0x50000008
    } .
    . .

    assembles to (inline assembly segment):
    STR ..
    LDR ..
    STR ..

    i didn't face this issue before. how should i fix this?
    Thanks.