User`s manual

176 digi.com Using Assembly Language
11.2.6 C Variables
C variable names may be used in assembly language. What a variable name represents (the value associ-
ated with the name) depends on the variable. For a global or static local variable, the name represents the
address of the variable in root memory. For an auto variable or formal argument, the variable name rep-
resents its own offset from the frame reference point.
The following list of processor register names are reserved and may not be used as C variable names in
assembly: A, B, C, D, E, F, H, L, AF, HL, DE, BC, IX, IY, SP, PC, XPC, IP, IIR and EIR.
The name of a structure element represents the offset of the element from the beginning of the structure. In
the following structure, for example, for the following structure
struct s {
int x;
int y;
int z;
};
the embedded assembly expression s+x evaluates to 0, s+y evaluates to 2, and s+z evaluates to 4,
regardless of where structure “s” may be.
In nested structures, offsets can be composite, as shown here.
struct s{ // offset into s
int x; // 0
struct a { // 2 (i.e., sizeof(x))
int b; // 2, offset is 0 relative to a
int c; // 4, offset is 2 relative to a
};
};
Just like in the first definition of structure “s”, the assembly expression s+x evaluates to 0; s+a evaluates to
2 and s+b evaluates to 2 (both expressions evaluate to the same value because both “a” and “b” are offset
“0” from “a”); and finally, s+c evaluates to 4 because s+a evaluates to 2 and a+c evaluates to 2.