Hardware Reference
In-Depth Information
16-bit
16-bit
16-bit
16-bit
Partial product M L N L
Upper half Lower half
Partial product M H N L
Upper half Lower half
Partial product M L N H
Upper half Lower half
Partial product M H N H
Upper half Lower half
Final product M × N
Address
P , P+1
P+2 , P+3 P+4 , P+5 P+6 , P+7
msb
lsb
Note: msb stands for most significant byte and lsb for least significant byte
Figure 2.3 Unsigned 32-bit by 32-bit multiplication
Example 2.12
Write a program to multiply the 32-bit unsigned integers stored at M,M13 and N,N13,
respectively, and store the product at memory locations P,P17.
Solution: The following program is a direct translation of the previous multiplication
algorithm:
org
$1000
M
rmb
4
; multiplicand
N
rmb
4
; multiplier
P
rmb
8
; product
org $1500
………………......... ; some other instructions
ldd M 1 2 ; place M L in D
ldy N 1 2 ; place N L in Y
emul ; compute M L N L
sty P 1 4 ; save the upper 16 bits of the partial product M L N L
std P 1 6 ; save the lower 16 bits of the partial product M L N L
ldd M ; place M H in D
ldy N ; place N H in Y
emul ; compute M H N H
sty P ; save the upper 16 bits of the partial product M H N H
std P 1 2 ; save the lower 16 bits of the partial product M H N H
ldd M ; place M H in D
ldy N 1 2 ; place N L in Y
emul ; compute M H N L
; the following seven instructions add M H N L to memory locations P 1 2 , P 1 5
addd
P 1 4
; add the lower half of M H N L to P 1 4 , P 1 5
std
P 1 4
;
 
Search WWH ::




Custom Search