The pseudo-ops DEFB and DEFW define constants and variables
in the program. The argument for the DEFB is a numeric or sym-
bolic expression that can be resolved in eight bits. The argument
for DEFW must be resolved in sixteen bits. Both pseudo-ops are
necessary because without them, the assembler could not generate
tables of data, constants, or locations for variables. The following
source lines generate a table of ten bytes, each byte representing
data from 1 to 10.
0100
01
TABLE
DEFB
1
0101
02
DEFB
2
0102
03
DEFB
3
0103
0405
DEFW
0405H
0105
06
DEFB
6
0106
0708
DEFW
0708H
0108
09
DEFB
1001B
0109
OA
DEFB
AH
010A
DEFS is a pseudo-op that reserves a number of bytes. In many
cases, it is necessary to set aside a block of memory without actually
filling it with meaningful data, as in allocation of I/O buffers and
working storage areas. The effect of DEFS is to increment the as-
sembler location counter by the argument, which represents the
number of bytes to be reserved. When the assembled object module
is loaded by the loader program after assembly, the block of storage
allocated by the DEFS will not be affected and will retain the mean-
ingless data in the memory area before the load. An alternative way
to reserve storage is to use an ORG pseudo-op. Both of the state-
ments below reserve 22H bytes starting at location 1234H.
1234H
1234H
1256H
BUFFER
NEXTI
EQU
DEFS
LDD
c
$
22H
1234H
BUFFER
EQU
$
1256H
ORG
$ + 22H
1256H
NEXTI
LDD
c
The last pseudo - op discussed here, TXT, is similar to the DEFB
and DEFW in that it generates data for use by the program. The
data in this case is ASCII text data. ASCII representation is used
for most I/O devices and is shown in Appendix E. Alphabetic,
numeric, and special characters must be encoded in ASCII format
before being transferred to the I/O device for printing , display, or
punching. The TXT pseudo- op generates one ASCII character for
each text character in the argument string. The argument string is
143
Need help?
Do you have a question about the Z80 and is the answer not in the manual?
Questions and answers