Chapter
1.
Assembly
Language
and
Processors
1-10
odd) instruction immediately following the
IN
(input) instruction produces false results since the
IN
instruction
does
not
affect the
condition
flags. The jump executed
by
your program reflects the
outcome
of
some previous
operation
unrelated to the
IN
instruction. For the operation to work correctly, you must include some instruc·
tion
that
alters the parity flag after the
IN
instruction,
but
before the jump instruction. For example, you can
add zero to the accumulator. This sets the parity flag
without
altering the data
in
the accumulator.
In
other
cases, you
will
want to set a flag with one instruction,
but
then have a number
of
intervening instruc-
tions before you use it.
In
these cases, you must
be
certain
that
the intervening instructions do not affect the
desired flag.
The flags set by each instruction
are detailed
In
the individual instruction descriptions
in
Chapter 3
of
thi,
manual.
Carry Flag
NOTE
When a flag
is
'set'
it
is
set
ON
(has the value one);
when
a flag
is
'reset' it
is
re,et
OFF
(ha, the value
zero) .
As
its name implies, the carry flag i, commonly u,ed to indicate whether
an
addition causes a
'carry'
into the
next higher order digit. The ca'rry
flag
is
also used
as
a
'borrow'
flag
in
subtractiom,
as
expl,lined under 'Two's
Complement
Representation
of
Data'
in
Chdpter 2
of
this manual. The
G.my
fidg
i,
<11,0
affected
by
the logical
AND,
OR, and exclusive OR instruction,. These instructions set
ON
or
OFF
rarticuldT bits
of
the dccumulator.
See the description>
of
the
ANA, ANI, ORA, ORI, XRA, and XRI instructioll'i
in
Charter
3.
The
rotate
instructions, which move the
contents
of
the accumulator one position to the Ielt or right, tredt the
carry bit
as
though
it
were a ninth bit
of
the ,lccumulator. See the descliption,
of
the RAL, RAR, RLC, and RRC
instructions
in
Chapter 3
of
this manual.
Example:
Addition
of
two one-byte number., can produce a carry
out
of
the high·order bit:
Bit Number:
AE=
+74=
7654
3210
1010 1110
0111
0 I
00
00100010
= 22 carry flag =
An
addition
that
causes a carry
out
of
thc high order bit
,ets
the carry
fI,lg
to I;
an
dddition that
duc,
not cause
a carry resets the flag to zero.
Sign Flag
As
explained under
'Two's
Complement
Representation
of
Data'
in
Chap!er 2, bit 7
of
a result
in
the accumulator
can
be
interpreted
as
a sign. Instructions
that
affect the sign flag set the flag equal to bit 7. A zero
in
bit 7