cancel
Showing results for 
Search instead for 
Did you mean: 

How to access local C variables in Inline-Assembly?

Muzahir Hussain
Associate III
Posted on November 27, 2017 at 21:46

How do I access local C variables in Keil using ARM inline Assembly?

#arm #keil #assembly
2 REPLIES 2
Posted on November 27, 2017 at 22:30

Don't have tools to hand, but wouldn't these work?

unsigned int foo = 1234;

  LDR R0, =&foo

  LDR R0,[R0]

 MOV R4, param1

If not, try reading the docs.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on November 28, 2017 at 02:37

unsigned int bar(unsigned int r0)

{

  unsigned int r1;

  unsigned int r4 = 1234;

    

    __asm

    {

        mov r1, r0

        add r1, r4

    }

    

  return(r1);

}
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..