Panasonic MN1030 Laptop User Manual


 
Chapter 9 Writing Machine Language Instructions and Directive Statements
Writing Directive Statements 171
9.4.14 equ
Syntax
label operation operand
name equ expression
Functional description
This directive defines the name to be the value of the expression coded in the operand. When that
name is coded in the operand of machine language instructions or directive instructions, the assembler
will reference the name's value.
System constants often used in programs (memory size, clock frequency, etc.) can be assigned to
names that describe those values.
MEMORY equ 0x20
MOTOR equ 10
STOP equ 0b00001000
BASE equ 0x1000
This allows numbers used in programs to be coded as descriptive names instead, making programs
easier to read. Furthermore, values can be changed just by modifying the equ directive, which in turn
changes the data wherever it is used. This makes programs easier to maintain.
Operand coding rules
The expression coded in the operand must result in the attribute abs (absolute). Refer to Section 8.7.4,
"Expression Attributes", regarding attributes of expressions.
If the attributes of expressions are not the attribute abs (absolute), #define of the assembler control state-
ment should be used, instead of the equ of the directive statement..
Names defined in other programs cannot be specified within expression.
Names defined once with the equ directive cannot be defined again.
No memory area is reserved when an equ directive statement is executed.
NOTE: Symbols with unresolved values cannot be coded in the operand. In the
following example, the value of ram1 is not resolved at the point where the value
of ram2 is to be resolved, so the assembler will generate an error.
Error example:
ram2 equ ram1+0x1
ram1 equ 0x10
By changing the order such that the value of ram1 is resolved first, no error will
occur.
No error example:
ram1 equ 0x10
ram2 equ ram1+0x1