Zilog Z08470 User Manual
Page 45

UM008007-0715
Instruction Types
Z80 CPU
User Manual
33
An example of an arithmetic operation is adding the Accumulator to the contents of an
external memory location. The results of the addition are placed in the Accumulator. This
group also includes 16-bit addition and subtraction between 16-bit CPU registers.
The rotate and shift group allows any register or any memory location to be rotated right
or left, with or without carry, and either arithmetic or logical. Additionally, a digit in the
Accumulator can be rotated right or left with two digits in any memory location.
The bit manipulation instructions allow any bit in the Accumulator, any general-purpose
register, or any external memory location to be set, reset, or tested with a single instruc-
tion. For example, the most-significant bit of Register H can be reset. This group is espe-
cially useful in control applications and for controlling software flags in general-purpose
programming.
The JUMP, CALL, and RETURN instructions are used to transfer between multiple loca-
tions in the user’s program. This group uses several different techniques for obtaining the
new program counter address from specific external memory locations. A unique type of
call is the RESTART instruction. This instruction actually contains the new address as a
part of the 8-bit op code. This instruction is possible because only eight separate addresses
located in Page 0 of external memory can be specified. Program jumps can also be
achieved by loading Register HL, IX, or IY directly into the Program Counter, which
allows the jump address to be a complex function of the routine being executed.
The input/output group of instructions in the Z80 CPU allow for a wide range of transfers
between external memory locations or the general-purpose CPU registers, and the external
I/O devices. In each case, the port number is provided on the lower eight bits of the
address bus during any I/O transaction. One instruction allows this port number to be
specified by the second byte of the instruction while other Z80 instructions allow it to be
specified as the contents of the C Register. One major advantage of using the C register as
a pointer to the I/O device is that it allows multiple I/O ports to share common software
driver routines. This advantage is not possible when the address is part of the op code if
the routines are stored in ROM. Another feature of these input instructions is the auto-
matic setting of the Flag Register, making additional operations unnecessary to determine
the state of the input data. The parity state is one example.
The Z80 CPU includes single instructions that can move blocks of data (up to 256 bytes)
automatically to or from any I/O port directly to any memory location. In conjunction with
the dual set of general-purpose registers, these instructions provide fast I/O block transfer
rates. The power of this I/O instruction set is demonstrated by the Z80 CPU providing all
required floppy disk formatting on double-density floppy disk drives on an interrupt-
driven basis. For example, the CPU provides the preamble, address, data, and enables the
CRC codes.
Finally, the basic CPU control instructions allow multiple options and modes. This group
includes instructions such as setting or resetting the interrupt enable flip-flop or setting the
mode of interrupt response.