ARM Technical Support Knowledge Articles

IN-LINE ASSEMBLER: INVALID EXPRESSION TOKEN

Applies to: C166 C Compiler

Answer


Information in this article applies to:


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

Article last edited on: 2005-07-15 09:58:03

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential