POP BC
# OF BYTES TO MOVE + LENT
SBC HL,BC
OR
A
SBC HL, DE # OF BYTES TO MOVE + 1
DEC HL # OF BYTES TO MOVE
PUSH BC
PUSH HL
POP BC TRANSFER TO BC
DESTA POP DE DESTINATION ADDRESS
LD HL, LENT
# OF BYTES PER ENTRY
ADD HL , DE SOURCE ADDRESS
LDIR MOVE DATA
DONE
In the above routine, a search was first made to find the entry. If
found, the remainder of the routine is concerned with setting up the
parameters for the move. The HL register points to the destination
address + one at this point, so it is decremented and saved in the
stack, eventually (at DESTA) to be put into DE. The number of
bytes to move is then given by LASTW - HL - LENT, and this
value is computed and put into BC. The source address is provided
by HL + LENT; this is computed and loaded into HL for the
LDIR. The actions of this move are shown in Fig. 13-3.
AFTER
DELETE
TABLE
2
LENT
#OF BYTES
PER ENTRY
TABLE+N
ENTRY 1
ENTRY TO DELETE
NEW
LOCATION
NOT
USED
ENTRY N
Fig. 13-3. Delete table entry actions.
The next routine inserts an entry into a table . Here, a search is not
made on the basis of finding a value equal to a key value, but on
finding the two adjacent entries that are less than and greater than
the key value ( or less than or equal , or greater than or equal ). All of
the search instructions set the sign flag on each iteration of the
200
Need help?
Do you have a question about the Z80 and is the answer not in the manual?
Questions and answers