Inline assembly problem.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Inline assembly problem.

227 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by micrio on Sun Sep 11 08:20:06 MST 2011
I am working on a piece of inline assembly code. I thought that I understood the syntax but I am wrong. I want to understand the % operands; %0, %1, etc.

My belief was that they were symbolic representations of registers. The compiler would assign then to actual registers at compile time and do it without disturbing any directly specified registers. Thus, if the assembly code refered to "r5" the compiler would never assign any % operand to "r5". Also, the compiler would never write to "r5" unless an assembly op code told it to do so.

My pervious inline assembly had only 3 passed in parameters and I assigned them to % operands as such;
"ldr %0, %[variable1]\n\t"
"ldr %1, %[variable2]\n\t"
This always worked OK.

My new code has 5 passed in parameters and I am having problems. Some passed in parameters that I load into registers using % operands get over-written by compiler generated assembly code!

Some documentation says that the % operands are positional with the listing of the parameters in the input list after the second ":". If so then why is it necessary to explicetly load the parameter with a "ldr" opcode?

I know that there is some issue with going over 4 passed in parameters and there is supposed to be a work-around. I can't find it!

Can I use all 8 normal registers using the symbolic reference method, %0, %1, etc, and have no explicit register references? Will the compiler sort this out?

Thanks,
Pete.
0 Kudos
2 Replies

210 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by monnoliv on Thu Aug 23 04:12:28 MST 2012
TheFallGuy: That's definitively THE document for ARM inline assembly.
Thanks :)
0 Kudos

210 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Sun Sep 11 11:09:51 MST 2011
Have you seen this - invaluable for inline assembly!

http://www.ethernut.de/en/documents/arm-inline-asm.html
0 Kudos