1/ You are required to write a MARIE assembly program to implement unsigned inte
ID: 3544073 • Letter: 1
Question
1/ You are required to write a MARIE assembly program to implement unsigned integer multiplication (you are free to decide in which memory locations the 2 numbers are stored and where to store the result). You should evaluate the correctness of your program testing it with at least 3 pairs of numbers covering at least the cases: A*B=B*A (remember that the multiplication is commutative) and 1*A=A.
- Change your program to perform signed integer multiplication, test it with at least 3 pairs of numbers covering the cases: ++; +-;
Explanation / Answer
org $800
M rmb 4 ; reserved to hold the multiplicand
N rmb 4 ; reserved to hold the multiplier
P rmb 8 ; reserved to hold the product
org $1000
ldd M+2 ; place ML in D
ldy N+2 ; place NL in Y
emul ; compute MLNL
sty P+4 ; save the upper 16 bits of the partial product MLNL
std P+6 ; save the lower 16 bits of the partial product MLNL
ldd M ; place MH in D
ldy N ; place NH in Y
emul ; compute MHNH
sty P ; save the upper 16 bits of the partial product MHNH
std P+2 ; save the lower 16 bits of the partial product MHNH
ldd M ; place MH in D
ldy N+2 ; place NL in Y
emul ; compute MHNL
; the following seven instructions add MHNL to memory locations P+2~P+5
addd P+4 ; add the lower half of MHNL to P+4~P+5
std P+4 ;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.