14.1.3 Symbols and Conditional Assembly
The following standard CEF symbols are defined by the master assembler:
Symbol Name |
Meaning |
. |
Current position. |
VER26 |
Master assembler version is 2.6. |
VER20_UP |
Master assembler version is 2.0 or later. |
VER21_UP |
Master assembler version is 2.1 or later. |
VER22_UP |
Master assembler version is 2.2 or later. |
VER23_UP |
Master assembler version is 2.3 or later. |
VER24_UP |
Master assembler version is 2.4 or later. |
VER25_UP |
Master assembler version is 2.5 or later. |
VER26_UP |
Master assembler version is 2.6 or later. |
CPU_VERn |
CPU component's version is n. For instance, CPU_VER20 indicates a CPU component of version 2.0. If there is no CPU for the assembler, this symbol is not defined. |
Numeric literals are assumed to be in the default radix unless their radix is overriden with one of the following suffixes:
Suffix |
Radix |
B |
2 |
D |
10 |
H |
16 |
O |
8 |
Q |
8 |
Note that a hexadecimal value may also be indicated by preceding the value with a dollar sign ($). For instance, “$FF” would indicate the decimal value 255. The assembler will check for a defined symbol with this name first. If such a symbol is defined, then the value is interpreted as that symbol name. Otherwise it is interpreted as a hexadecimal value.
Any symbol followed by a colon is defined as a local address equivalent to its location. Any symbol followed by a double colon (::) is defined as a global address equivalent to its location.
Special characters:
Comments begin with a semicolon (;) and run to the end of the line. However, semicolons within quotes (' or “) are treated as literals and do not start comments.
White space is ignored by the assembler except that it terminates tokens, such as instruction mnemonics, and symbol names. White space is any one, or combination of the following characters occurring outside of quotes (' or “): space (ASCII 32), tab (ASCII 9), and new line. New lines cannot be quoted as literals, thus all quoted literals end at the end of the line they begin on if they are not ended before. The assembler may generate a warning about an unterminated literal in this case. This is recommended, but not required by this specification.
The assembler processes data by token, so (unless otherwise stated), multiple instructions can appear on a line or a single instruction can be split across lines. For ease of reading, the backslash character (\) can be used to visually delimit multiple instructions on a single line. Unless otherwise noted, the backslash is treated as white-space.
Conditional assembly:
Conditional assembly is accomplished via the .IIF and .IF directives. The .IF directive begins a conditional block which is terminated with the .ENDC directive. .IF and .IIF use condition tests to determine if the conditional block is assembled. The valid conditional tests are as follows:
Conditional |
Synonym |
Complement |
Complement |
Description |
EQUAL |
EQ |
NOT_EQUAL |
NE |
Expression is equal to 0/not equal to 0. |
GREATER |
GT |
LESS_EQUAL |
LE |
Expression is greater than 0/less than or equal to 0. |
LESS_THAN |
LT |
GREATER_EQUAL |
GE |
Expression is less than 0/ greater than or equal to 0. |
DEFINED |
DF |
NOT_DEFINED |
NDF |
Symbol is defined/not defined. |
BLANK |
B |
NOT_BLANK |
NB |
Argument is blank/non blank. This is intended for use in macro definitions. |
IDENTICAL |
IDN |
DIFFERENT |
DIF |
Arguments are different/identical. This is intended for use in macro definitions. This uses two arguments instead of 1. |
Between the .IF and .ENDC directives, one or more conditional modifier directives can be used. The conditional modifier directives are .ELSE, .IF_TRUE, .IF_FALSE, and .IF_TRUE_FALSE. the .ELSE directive can be used to complement (invert) the conditional check. Also, the .IF_TRUE, .IF_FALSE, and .IF_TRUE_FALSE directives can be used to change what code gets assembled. The effect of a conditional modifier directive lasts until the next conditional modifier directive (or .ENDC) is encountered. Examples:
.IF DEFINED TEST
.BYTE 0
.ELSE
.BYTE 23
.IF EQUAL A
.INCLUDE special.asm
.ENDC
.IF_FALSE
.INCLUDE myfile.asm
.ENDC
.ENDC