User`s manual

Dynamic C Users Manual digi.com 175
11.2.3 Multiline Macros
The Dynamic C preprocessor has a special feature to allow multiline macros in assembly code. The pre-
processor expands macros before the assembler parses any text. Putting a $\ at the end of a line inserts a
new line in the text. This only works in assembly code. Labels and comments are not allowed in multiline
macros.
11.2.4 Labels
A label is a name followed by one or two colons. A label followed by a single colon is local, whereas one
followed by two colons is global. A local label is not visible to the code out of the current embedded
assembly segment (i.e., code before the #asm or after the #endasm directive is outside of that embbeded
assembly segment).
Unless it is followed immediately by the assembly language keyword equ, the label identifies the current
code segment address. If the label is followed by equ, the label “equates” to the value of the expression
after the keyword equ.
Because C preprocessor macros are expanded in embedded assembly code, Rabbit recommends that pre-
processor macros be used instead of equ whenever possible.
11.2.5 Special Symbols
This table lists special symbols that can be used in an assembly language expression.
#define SAVEFLAG $\
ld a,b $\
push af $\
pop bc
#asm
...
ld b,0x32
SAVEFLAG
...
#endasm
Table 11-2. Special Assembly Language Symbols
Symbol Description
@SP
Indicates the amount of stack space (in bytes) used for stack-based
variables. This does not include arguments.
@PC
Constant for the current code location. For example:
ld hl, @PC
loads the code address of the instruction. ld hl,@PC+3 loads the address
after the instruction since it is a 3 byte instruction.
@RETVAL
Evaluates the offset from the frame reference point to the stack space
reserved for the struct function returns. See Section 11.4.1.2 for
more information on the frame reference point.
@LENGTH Determines the next reference address of a variable plus its size.