Inline assembly problem.

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
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?