Everything
5.1.11 Restrictions on operations

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.

(1)

Absolute expression

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.

(a)

Constant 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.

Example

SYM1    .set    0x100       --Define symbol SYM1
        mov     SYM1, r10   --SYM1, already defined, is treated as a constant
                              expression.

(b)

Symbol

The expressions related to symbols are the following ("+" is either "+" or "-").

-

Symbol

-

Symbol + constant expression

-

Symbol - symbol

-

Symbol - symbol + constant expression

 

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.

Example

        add     SYM1 + 0x100, r11   --SYM1 is an undefined symbol at this point
SYM1    .set    0x10                --Defines SYM1

(c)

Label reference

The following expressions are related to label reference ("+" is either "+" or "-").

-

Label reference - label reference

-

Label reference - label reference + constant expression

 

Here is an example of an expression related to a label reference.

Example

mov     $label1 - $label2, r11

 

A "reference to two labels" as shown in this example must be referenced as follows.

-

The same section has a definition in the specified file.

-

Same reference method (such as $label and $label, and #label and #label)

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.

(2)

Relative expressions

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.

Note 1.

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.

Note 2.

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.

(a)

Label reference

The following expressions are related to label reference ("+" is either "+" or "-").

-

Label reference

-

Label reference + constant expression

-

Label reference - symbol

-

Label reference - symbol + constant expression

 

Here is an example of an expression related to a label reference.

Example

SIZE    .set    0x10
        add     #label1, r10
        add     #label1 + 0x10, r10
        add     #label2 - SIZE, r10
        add     #label2 - SIZE + 0x10, r10