Expressions

When a numeric value is expected as an argument for an instruction or directive, a constant expression may be used containing the operators and values described below. Note that all expressions are evaluated during assembly, and so always represent constant values. An arbitrary amount of whitespace can be between the operators and the operands.

Literal Values: Numeric constants must begin with a decimal digit (thus hexadecimal values that begin with a letter must be prefixed with '0' unless the '$' prefix is used). Numbers can be specified in binary, octal, decimal, or hexadecimal. The base is determined by a prefix or suffix. If no prefix or suffix is used, the number is assumed to be decimal.

Base Prefix Suffix
Binary (base 2)%B or b
Octal (base 8)@O or o
Decimal (base 10)D or d (or none)
Hexadecimal (base 16)$H or h

Character values can also be used as a numeric constant, by surrounding a single character in single quotes. The ASCII value of the specified character is used.

Labels: A label is a symbol used by the assembler that is assigned a numeric value and acts as a constant in expressions. The most common use of labels is to name a location in a program, so that the location can be referenced by name when using a jump of call. Labels defined elsewhere in the program can be included in expressions.

Location counter symbol: The current value of the Instruction Pointer (PC) can be used in expressions by using the '$' symbol. The '$' symbol acts like a constant and is allowed anywhere that a numeric constant is. Note: the '*' symbol is not supported as the location counter.

Back to the Main Page