III.6 Pseudo Instructions
In the subsequent paragraphs, all ASEM-51 pseudo instructions are
described. Lexical symbols are written in lower case letters, while assembler
keywords are written in upper case.
Instruction arguments are represented by <arg>, <arg1> or something like
that. Numeric expressions are represented by <expr>, <expr1> and so on.
Syntax elements enclosed in brackets are optional.
The ellipsis “...” means always “a list with any number of elements”.
DB <arg1> [,<arg2> [,<arg3> ... ]]
| define bytes
|
The DB instruction reserves and initializes a number of bytes with
the values defined by the arguments. The arguments may either be
expressions (which must evaluate to 8-bit values) or character
strings of any length. DB is only allowed in the CODE segment!
Example: DB 19,'January',98,(3*7+12)/11
DW <expr1> [,<expr2> [,<expr3> ... ]]
| define words
|
The DW instruction reserves and initializes a number of words with
the values defined by the arguments. Every argument may be an
arbitrary expression and requires two bytes of space.
DW is only allowed in the CODE segment!
Example: DW 0,0C800H,1999,4711
Reserves a number of uninitialized bytes in the current segment.
The value of <expr> must be known on pass 1!
DS is allowed in every segment, except in the BIT segment!
Example: DS 200H
Reserves a number of uninitialized bits.
The value of <expr> must be known on pass 1!
DBIT is only allowed in the BIT segment!
Example: DBIT 16
NAME <symbol>
| define module name
|
Defines a module name for the OMF-51 object file.
If no module name is defined, the module name is derived from the
source file name.
When generating Intel-HEX file output, the NAME instruction
has no effect. The module name must be a legal assembler symbol.
Only one NAME instruction is allowed within the program. The symbol
however, may be redefined in the subsequent program.
Example: NAME My_1st_Program
ORG <expr>
| origin of segment location
|
Sets the location counter of the current segment to the value <expr>.
The value of <expr> must be known on pass 1!
It must be greater or equal to the segment base address.
The default value of all location counters at program start is 0.
Example: ORG 08000H
USING <expr>
| using register bank
|
Sets the register bank used to <expr>, which must be in the range
of 0...3. The USING instruction only affects the values of the
special assembler symbols AR0, ... , AR7 representing the direct
addresses of registers R0, ... , R7 in the current register bank.
The value of <expr> must be known on pass 1!
The default value for the register bank is 0.
Example: USING 1
This must be the last statement in the source file. After the END
statement only commentary and blank lines are allowed!
Example: END ;end of program
<symbol> EQU <expr>
| define numeric constant
|
<symbol> EQU <reg>
| define invariant register
|
<symbol> SET <expr>
| define numeric variable
|
<symbol> SET <reg>
| define variable register
|
The EQU instruction defines a symbol for a numeric constant or a
register. If a numeric expression <expr> is assigned to the symbol,
it will be of the type NUMBER. If a register <reg> is assigned to
the symbol, it will be of the type REGISTER. <reg> may be one of the
special assembler symbols A, R0, R1, R2, R3, R3, R4, R5, R6, or R7.
A symbol once defined with EQU can never be changed!
The SET instruction is working quite similar to EQU. However, symbols
defined with SET can be redefined with subsequent SET instructions!
The values of <expr> and <reg> must be known on pass 1!
A symbol that has been SET, cannot be redefined with EQU!
A symbol that has been EQU'd cannot be reSET!
On pass 2, forward references to a SET symbol always evaluate
to the last value, the symbol has been SET to on pass 1.
Register symbols can be used as instruction operands within the
whole program instead of the corresponding registers.
Forward references to register symbols are not allowed!
Examples:
MAXMONTH EQU 12
OCTOBER EQU MAXMONTH-2
COUNTREG EQU R5
CHAPTER SET 1
CHAPTER SET CHAPTER+1
CHAPTER SET A
<symbol> CODE <expr>
| define ROM address
|
<symbol> DATA <expr>
| define direct RAM address
|
<symbol> IDATA <expr>
| define indirect RAM address
|
<symbol> BIT <expr>
| define bit address
|
<symbol> XDATA <expr>
| define external RAM address
|
These instructions define symbolic addresses for the five 8051
memory segments (address spaces). For DATA, IDATA and BIT type
symbols, the value of <expr> must not exceed 0FFH!
The value of <expr> must be known on pass 1!
Once defined with one of the above instructions, the symbols cannot
be redefined.
Examples:
EPROM CODE 08000H
STACK DATA 7
V24BUF IDATA 080H
REDLED BIT P1.5
SAMPLER XDATA 0100H
CSEG [AT <expr>]
| switch to CODE segment [at address]
|
DSEG [AT <expr>]
| switch to DATA segment [at address]
|
ISEG [AT <expr>]
| switch to IDATA segment [at address]
|
BSEG [AT <expr>]
| switch to BIT segment [at address]
|
XSEG [AT <expr>]
| switch to XDATA segment [at address]
|
These instructions switch to one of the five 8051 address spaces.
If a segment base address is specified with “AT <expr>”, a new
absolute segment is started, and the location counter is set to
<expr>. If “AT <expr>” is omitted, the location counter keeps the
previous value of the particular segment.
The value of <expr> must be known on pass 1!
At program start, the default segment is CODE and the base addresses
and location counters of all segments are set to zero.
Examples:
DSEG ;switch to previous DATA segment
CSEG AT 8000h ;start a new CODE segment at address 8000H
XSEG at 0 ;start a new XDATA segment at address 0