EasyManua.ls Logo

Intel 8080 - CMC, CMP

Intel 8080
224 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter
3.
Instruction
Set
CMC
CMP
3ยท12
COMPLEMENT
CARRY
If
the
carry flag equal,> zero, CMC
set'>
it
to
one.
If the
carr"y
flag
is
one,
CMC resets
it
to zero.
All
other
flags
remain unchanged.
Opcode
Operand
CMe
Operdnd~
Me
not
permitted
with the CMC in'>truction.
Cycle'>:
States:
4
Flags:
CY
only
Example:
Assume thdt d program
u'>es
bit 7
of
d
byte
to
control
whether" a ,>ubroutine i, called.
To
test
the
bit, the pro-
gram loads the
byte
into
the
dccumulator,
rotates
bit 7
into
the
Cdrry
flag, and
execute,
a
CC
(Call if Carry)
instruction.
Before
returning
to the calling program, the
subroutine
reiniti,difes the flag
byte
u,>ing
the following
code:
CMC
RAR
RET
;SET BIT 7
OFF
;ROTATE BIT 7 INTO ACCUMULATOR
;RETURN
COMPARE
WITH
ACCUMULATOR
CMP compar-e'> the ,>pecified
byte
with the content'>
of
the
accumulator
,ltlel
indicate'> the
rC'>Lllt
by '>etling the
carry dnd
fero
fidgS.
The
valuc~
being compdred remain unchanged.
The
zero
flag indicates
equality.
No
carry indicates
that
the
accumulator
i'>
greater
than
the specified byte; a
carry indicates
that
the
accumulator
is
leS'>
than the byte. However, the meaning
of
the
CMrv
flag
is
rever'>cd
when
the
values have different signs or one
of
the
values i,
complemented.
The
program tests the
condition
flag'>
using one
of
the conditional
Jump,
Cdl,
m Return in<,lruction'>. For
example,
JZ
(jump
if Zero) tcst', for equdlity.
Functional Description:
Compari.,ons are
performed
by
subtracting
the specified
byte
from the
contents
of
the accumulator", which
is
why the zero ,md cMry flags indicate the result. This
subuaction
uses the processor", interndl registers
so
that
source
data
is
preserved. Because
subtraction
uscs
two's
complement
addition,
the
CMP
instruction
recomplements
the carry flag generated by
the
subtraction.

Table of Contents

Related product manuals