Chapter
4.
Assembler
Directives
In
the examples, the
LXI
instructions load the address
of
the desired data into the
Band
C registers. The
LDAX
instructions then load the accumulator with one byte of data from the address specified
in
the
Band
C registers.
The assernbler neither knows nor cares that only one character from the three-character
field ALPHA
has
been
accessed. The program must account for the characters at
ALPHA+l and ALPHA+2,
as
in
the following coding
sequence:
ALPHA:
DB
'ABC'
;DEFINE ALPHA
LXI
B,ALPHA ;LOAD ADDRESS OF ALPHA
LDAX
B ;FETCH 1
ST
ALPHA CHAR
INX
B
;SET B TO ALPHA+l
LDAX
B
;FETCH
2ND
ALPHA CHAR
INX
B ;SET B TO ALPHA+2
LDAX
B
;FETCH 3RD ALPHA CHAR
The coding above
is
acceptable for short data fields like ALPHA. For longer fields, you can conserve memory
by
setting up
an
instruction sequence that
is
executed repeatedly until the source data
is
exhausted.
Add
Symbols for Data Access
The following example was
presented earlier
as
an illu5tration of the
OS
directive:
Label Opcode Operand
Comment
TTYBUF:
OS
72
;RESERVE TTY BUFFER
To access data
in
this buffer using only expressions such
as
TTYBUF+l, TTYBUF+2,
...
TTYBUF+72 can
be
a laborious and confusing chore, especially when you want only selected fields from the buffer. You can simplify
this task
by
subdividing the buffer with the
EQU
directive:
Label Opcode
Operand
Comment
TIYBUF:
OS
72
;RESERVE TTY BUFFER
10
EQU
TTYBUF ;RECORD IDENTIFIER
NAME
EQU
TTYBUF+6 ;20-CHAR
NAME
FIELD
NUMBER
EQU
TTYBUF+26
;10-0-lAR EMPLOYEE NUMBER
DEPT
EQU
TTYBUF+36 ;5-CHAR DEPARTMENT NUMBER
SSNO
EQU
TTYBUF+41 ;SOCIAL SEC. NUMBER
DOH
EQU
TTYBUF+50
;DATE
OF HIRE
DESC
EQU
TTYBUF+56 ;)OB DESCRIPTION
4-7