An expression consists of a "constant", "symbol", "label reference", "operator", and "parentheses".It indicates a value consisting of these elements. The expression distinguishes between Absolute expression and Relative expressions.
An expression indicating a constant is called an "absolute expression". An absolute expression can be used when an operand is specified for an instruction or when a value etc. is specified for a directive. An absolute expression usually consists of a constant or symbol. The following format is treated as an absolute expression.
If a reference to a previously defined symbol is specified, assumes that the constant of the value defined for the symbol has been specified. Therefore, a defined symbol reference can be used in a constant expression.
SYM1 .set 0x100 --Define symbol SYM1 mov SYM1, r10 --SYM1, already defined, is treated as a constant expression. |
The expressions related to symbols are the following ("+" is either "+" or "-").
A "symbol" here means a reference to a symbol defined as a constant with a symbol definition directive in the same file, although undefined at that point. If a reference to a previously defined symbol is specified, assumes that the "constant" of the value defined for the symbol has been specified.
The following expressions are related to label reference ("+" is either "+" or "-").
Here is an example of an expression related to a label reference.
A "reference to two labels" as shown in this example must be referenced as follows.
When not meeting these conditions, a message is output, and assembly is canceled.
The .DW directive can be assembled if two label accesses are absolute address references, even if the definitions are in different sections of different files.
An expression indicating an offset from a specific addressNote 1 is called a "relative expression". A relative expression is used to specify an operand by an instruction or to specify a value by data definition directive. A relative expression usually consists of a label reference. The following formatNote 2 is treated as an relative expression.
This address is determined when the optimizing linker is executed. Therefore, the value of this offset may also be determined when the optimizing linker is executed. |
The absolute value system and the relative value system can regard an expression in the format of "-symbol + label reference", as being an expression in the format of "label reference - symbol," but it cannot regard an expression in the format of "label reference - (+symbol)" as being an expression in the format of "label reference - symbol". Therefore, use parentheses "( )" only in constant expressions. |
The following expressions are related to label reference ("+" is either "+" or "-").
Here is an example of an expression related to a label reference.