Keil Logo

C166: IN-LINE ASSEMBLER: INVALID EXPRESSION TOKEN


Information in this article applies to:

  • C166 Version 5.00 or higher

QUESTION

I have written the following small C program:

int enterdata (void);

void main (void)  {
  int variable = 0;
  variable = enterdata ();

  __asm   {
      MOV R1,#variable
      MOV adr,R1
  }
}

When I translate it I get:

*** ERROR C195: inline-asm: invalid expression token

What is the reason for this error and how can I avoid it?

ANSWER

Not all addressing modes are valid for automatic variables. For example it is not possible to get the memory address of an automatic variable if it is located to CPU registers or the User Stack.

You have two options:

  1. Use static int variable = 0; to define a static variable that is located to a memory address. Then it is valid to use MOV R1,#variable for getting the memory address.
  2. Use MOV R1,variable to load the content of the variable. This instruction is translated into a CPU register or User Stack memory access and loads the content of the memory rather than the memory address.

MORE INFORMATION

Last Reviewed: Friday, July 15, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.