Chapter 4 Assembly Language and Cross Assembler
Comment
Comments are the descriptions of codes. They are used for documentation only and are ignored
by the Cross Assembler. Any text following a semicolon is considered a comment.
Assembly Directives
Directives give direction to the Cross Assembler, specifying the manner in which the Cross Assem-
bler generates object code at assembly time. Directives can be further classified according to their
behavior as described below.
Conditional Assembly Directives
The conditional block has the following form:
IF
statements
[ELSE
statements]
ENDIF
Syntax
IF
expression
IFE
expression
·
Description
The directives
IF
and
IFE
test the
expression
following them.
The
IF
directive grants assembly if the value of the
expression
is true, i.e. non-zero.
The
IFE
directive grants assembly if the value of the
expression
is false, i.e. zero.
·
Example
IF debugcase
ACC1
equ 5
extern username: byte
ENDIF
In this example, the value of the variable
ACC1
is set to 5 and the
username
is declared as an
external variable if the symbol
debugcase
is evaluated as true, i.e. nonzero.
Syntax
IFDEF
name
IFNDEF
name
·
Description
The directives
IFDEF
and
IFNDEF
test whether or not the given
name
has been defined. The
IFDEF
directive grants assembly only if the
name
is a label, a variable or a symbol. The
IFNDEF
di-
rective grants assembly only if the
name
has not yet been defined. The conditional assembly direc-
tives support a nesting structure, with a maximum nesting level of 7.
·
Example
IFDEF
ENDIF
In this example, the
buffer
is allocated only if the
buf_flag
has been previously defined.
139
buf_flag
buffer DB
20 dup(?)
Home Index Bookmark Pages Text
Previous Next
Pages: Home Index