Chapter 6. Programming
Techniques
6·8
Step
4: Test multiplier 3-bit; it
is
1, so add 2AH
to
high-order
byte
of
result and shift 16-bit
result right
one
bit.
Step 5: Test
multiplier 4-bit; it
is
1, so add 2AH
to
high-order
byte
of
result
and
shift 16-bit
result right one bit.
Step
6: Test multiplier S-bit; it
is
1, so add 2AH
to
high-order
oyte
of
result and shift 16-bit
result right
one
bit.
Step 7: Test
multiplier 6-bit; it
is
0, so shift 16-bit result right one bit.
Step
8:
Test
multiplier 7-bit; it
is
0, so shift 16-bit result right
one
bit.
The
result produced
is
0908.
MULTIPLIER MULTIPLICAND
Start
00111100(3C)
00101
01
0(2A)
Step 1 a
..............................
.
b
Step 2 a
..............................
.
b
Step 3 a
..............................
.
b
Step 4 a
..............................
.
b
Step
5 a
..............................
.
b
Step
6 a
..............................
.
b
Step
7 a
..............................
.
b
Step
8 a
..............................
.
b
HIGH-ORDER BYTE
OF
RESULT
100000000
00000000
100000000
00101010
100010101
00111111
00011111
101001001
00100100
101001110
00100111
00010011
00001001
LOW-ORDER
BYTE
OF
RESULT
00000000
00000000
00000000
00000000
00000000
00000000
10000000
10000000
11000000
11000000
01100000
10110000
11011000(908)
Since the multiplication
routine
described above uses a number
of
important
programming techniques, a sample
program
is
given with
comments.
The program uses
the
B register to hold the most significant
byte
of
the result, and the C register
to
hold the
least significant
byte
of
the result. The 16-bit right shift
of
the
result
is
performed
in
the
accumulator
by
two
rotate-right-through-carry i nstruc tions.