ZiLOG Z80-CPU Technical Manual page 32

Table of Contents

Advertisement

The POP instruction is the exact reverse of a PUSH. Notice that all PUSH and POP instructions utilize a
16-bit operand and the high order byte is always pushed first and popped last. That is a:
PUSH BC is PUSH B then C
PUSH DE is PUSH D then E
PUSH HL is PUSH H then.L
POP HL is POP
L then H
The instruction using extended immediate addressing for the source obviously requires 2 bytes of data
following the OP code. For example:
LD DE,0659H
will
be:
Address A
~1
OP Code
A+ 1
59
Low order operand to register E
A+2 06
High order operand to register D
In all extended immediate or extended addressing modes, the low order byte always appears first after the
OP code.
Table 5.3-3 lists the 16-bit exchange instructions implemented in the Z-80. OP code 08H allows the
programmer to switch between the two pairs of accumulator flag registers while D9H allows the pro-
grammer to switch between the duplicate set of six general purpose registers. These OP codes are only one
byte in length to absolutely minimize the time necessary to perform the exchange so that the duplicate
banks can be used to effect very fast interrupt response times.
BLOCK TRANSFER AND SEARCH
Table 5.3-4 lists the extremely powerful block transfer instructions.
All
of these instructions operate
with three registers.
HL points to the source location.
DE points to the destination location.
BC is a byte counter.
After the programmer has initialized these three registers, any of these four instructions may be used. The
LDI (Load and Increment) instruction moves one byte from the location pointed to by HL to the location
pointed to by DE. Register pairs HL and DE are then automatically incremented and are ready to point to
the following locations. The byte counter (register pair BC) is also decremented at this time. This instruc-
tion is valuable when blocks of data must be moved but other types of processing are required between each
move. The LDIR (Load, increment and repeat) instruction is an extension of the LDI instruction. The same
load and increment operation is repeated until the byte counter reaches the count of zero. Thus, this single
instruction can move any block of data from one location to any other.
Note that since 16-bit registers are used, the size of the block can be up to 64K bytes (I K
=
1024)
long and it can be moved from any location in memory to any other location. Furthermore the blocks can
be overlapping since there are absolutely no constraints on the data that is used in the three register pairs.
The LDD and LDDR instructions are very similar to the LDI and LDIR. The only difference is that
register pairs HL and DE are decremented after every move so that a block transfer starts from the highest
address of the designated block rather than the lowest.
26

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Z80-CPU and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Z80a-cpu

Table of Contents