Chapter
6. Programming
Techniques
Zero carry
and
then rotate
B:
B
C
D
Then rotate C to complete the shift:
B
C
D
Register D holds the multiplicand,
and
register C originally holds the multiplier.
MULT:
MVI
B,O
;INITIALIZE
MOST
SIGNIFICANT
BYTE
;OF
RESULT
MVI
E,9 ;BIT COUNTE R
MULTO: MOV
A,C
;ROTATE LEAST
SIGNIFICANT
BIT OF
RAR
;MULTIPLIER
TO
CARRY
AND SHIFT
MOV
C,A ;LOW-ORDER BYTE OF RESULT
DCR
E
jZ
DONE
;EXIT
IF COMPLETE
MOV
A,B
jNC
MULTl
ADD D ;ADD
MULTIPLICAND
TO HIGH-
;ORDER BYTE OF
RESULT IF BIT
;WAS
A ONE
MULT1:
RAR ;CARRY=O HERE SHIFT HIGH-
;ORDER BYTE OF RESULT
MOV
B,A
jMP
MULTO
DONE:
An
analogous procedure
is
used
to divide
an
unsigned 16-bit number by
an
unsigned 16-bit number. Here, the
process
involves subtraction rather than addition,
and
rotate-left instructions instead
of
rotate-right instructions.
6-9