Addresses of Variables

A constant expression may also be the address of a global variable or the offset of a local variable.

AddrOfVar = "#"<Variable.

As examples:

  LD X, #g ; Load X with address of global variable  
  LD Y, #l ; Load Y with frame offset of local variable or parameter  

It is also possible to access the fields of a struct or a union by using the normal

  ANSI-C notation.  
  LD D0 r.f ; Load D0 with content of field f.  

The inline assembler enables you to specify an offset from the address of a variable in order to access the low word of a long or a float variable:

Offset = "+" ConstExpr.

Variable = Ident {"." Ident}.

Below are some examples (assuming all variables are long):

  LD Y,  #g+2  ; Load Y with ((address of g) + 2)  

  LD X,  g+2   ; Load X with the value stored there 

  LD D0, r.f+2 ; Load D0 with low word of field f.
  

This feature may also be used to access array elements with a constant index:

  int a[30]   ;

  LD  D2, a+24 ; Load a[12] into D