EasyManua.ls Logo

Intel 8080 - B1_Page_44

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
2.
Assembly
Language
Concepts
2·8
The processor forms the two's complement
of
a binary value simply
by
reversing the value
of
each bit and then
adding one to the result. Any carry
out
of
the high order b!t
is
ignored when the complement
is
formed. Thu"
the subtraction shown previously
is
pel'formed
as
follows:
35
= 0010 0011
-12
= 0000
11
00 = 1111 0011
23
+
1111
01
00
0010 0011
+1111
01
00
1 0001 0111 =
23
Again,
by
disregarding the carry
out
of the high order position, the subtraction
is
performed through a form
of
addition. However,
if
this operation were performed
by
the 8080 or the 8085, the carry flag would be set
OFF
at the end
of
the subtraction. This
is
because the processors complement the carry flag at the end
of
a subtract
operation
so
that
it
can be u,ed
as
a
'borrow'
flag
in
multibyte subtractions.
In
the example shown, no borrow
is
required,
so
the carry
flag
is
set OFF. By contrast, the carry flag
is
set
ON
if
we
subtract 35 from 12:
1 2
= 0000
11
00
-35 = 0010 0011
11
01
11
00
0000
1100
+1101 1101
+
11101001=2330r105
1 1
01
1 1
01
In
this case, the absence
of
a carry indicates that a borrow
is
required from the next higher order byte,
if
any.
Therefore, the processor sets the carry flag
ON. Notice also that the result
is
stored
in
a complemented form.
If
you want to interpret this result
as
a decimal value, you must again form its two's complement:
1110 1001
=0
0001 0110
,.
1
0001 0111 = 23
Two's complement
number, may also
be
sig:led.
When
a byte
is
interpreted
as
a signed two's complement number,
the high order bit indicates the sign. A zero
in
this bit indicate, a positive number, a one d negative number. The
seven low order bits
pmvide the magnitude .)f the number. Thus, 0111
1111
equal, + 127.
At
the beginning
of
this description
of
two\
complement arithmetic, it
was
stated that any 8·bit byte may con·
tain one
of
the 256 possible combinations of zews and ones.
It
must also be stated
that
the proper interpretation
of
data
is
a progrdmming responsibility.
As
an example, consider the compJre instru:tion. The compare logic cOIhiders only the
LIW
bit values
of
the
items being compared. Therefore, a negative two's complement number
alway, compMes higher than a positive
number, because the negative number's
high
order bit
is
always ON. A, a result, the meanings of the flags set by
the compare instruction
Me
reversed. Your program must account for this condition.

Table of Contents

Related product manuals