Download Print this page

ZiLOG Z80 Handbook page 69

Hide thumbs Also See for Z80:

Advertisement

CPL and NEG operate on the contents of the A register. CPL ones-
complements the contents of the A register, changing all zeros to
ones and all ones to zeros, as shown in Fig. 5-12. NEG negates the
contents of the A register changing all zeros to ones and all ones
to zeros and adding one as shown in the figure. The effect of CPL
is to find the value - [ (A) +1 ] and NEG to find the value -A, where
(A) is the previous contents of the A register. Condition codes are
set as shown in Table 5-4.
ADD A, B
T 8-BIT RESULT
ALU
(ADD)
CPU B REG
ADC A,IHLI
SBC A,(IX+DI
Fig. 5-10. Add and Subtract instruction examples.
Two of the instructions in this group operate on the carry (CY)
flag of the condition codes. SCF sets the carry flag to a 1; CCF com-
plements the current state of the carry - a 1 is set to a 0, and a 0
is set to a 1. These instructions are useful in setting the carry prior to
arithmetic or shifting operations.
The NOP instruction does nothing and is used to "pad" a pro-
gram area or is implemented automatically by the Z-80 during a
HALT state to guarantee dynamic-memory refresh.
72

Advertisement

loading