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

Pass in an immediate value to an inline assembly function

Note: This was originally posted on 6th March 2009 at http://forums.arm.com

Hi,

I would like to pass in an immediate value to an inline assembly function, such as in this example:

inline int foo(int a, int b, const int immed)
{
   register int result;
   __asm
   {
      add   result, a, b, lsl #immed
   };
   return(result);
}

I am calling foo() with values of 5 or 6 for the immed operand, such as
z = foo(a, b, 5);

For the RVCT 3.0 armcc compiler, I get this error message for the immed operand: "Operand should be constant"

Is there any way to pass in the immediate value, which is known at compile time?


Note the analogous GCC version for the foo() definition has the additional syntax of "i"(immed) for the immediate operand, which allows for successful compilation.  That is, I don't have the problem for GCC.

Thanks