The operation of an expression is performed by connecting terms with operator(s). Elements that can be described as terms are constants, names and labels. Each term has a relocation attribute.
Depending on the types of relocation attribute inherent in each term, operators that can work on the term are limited. Therefore, when describing an expression it is important to pay attention to the relocation attribute of each term constituting the expression.
Each term constituting an expression has a relocation attribute.
If terms are categorized by relocation attribute, they can be divided into 2 types: absolute terms and relocatable terms.
The following table shows the types of relocation attributes and their properties, and also the corresponding terms.
The following tables categorize combinations of operators and terms which can be used in expressions by relocation attribute.
R : Result is relocatable term
Operation is possible when X is not relocatable terms operated on by MIRHW, MIRLW, SMRLW, or DATAPOS. |
Operation is possible when X is not relocatable terms operated on by HIGH, LOW, HIGHW, LOWW, MIRHW, MIRLW, SMRLW, or DATAPOS. |
The HIGH, HIGHW, LOW, and LOWW operators can be specified in a nested manner.
Expressions are classified into absolute and relative expressions, which are handled separately.
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, it is assumed 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.
However, a symbol that is not defined or whose value is not determined when the symbol is referenced is not handled as a constant expression
SYM1 .EQU 0x10 ;Define symbol SYM1 MOV A, #SYM1 ;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 symbol that is an absolute term (a name for which a constant is defined somewhere in the module) but that is not defined or whose value is not determined yet when it is referenced.. If a reference to a previously defined symbol is specified, it is assumed that the "constant" of the value defined for the symbol has been specified.
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 symbol (label and external reference name).
The following formatNote 2 is treated as an relative expression("" is either "+" or "-").
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. |
It 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. |
When any of the specified symbols is a relocatable term, the expression is handled as a relative expression. Here is an example of a relative expression.