Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an assembly program to multiply two 31 bit binary numbers (A & B), using t

ID: 3810881 • Letter: W

Question

Write an assembly program to multiply two 31 bit binary numbers (A & B), using the “shift and add” algorithm, which historically is used in computers. The numbers A and B are read through the keyboard and are saved into $t0 and $t1 registers. The MIPS processor will store these numbers in binary automatically. Then, you will then need to use AND, ADD, Shift logical instructions to implement the multiplication of these two numbers. The final result of the multiplication is saved into $t2 and $t3 registers representing (C and D). Your program will print out the values of $t2 and $t3 registers (in decimal - You do not need to convert the result to decimal since MIPS automatically does that for you).

Sample input A: 1143330295 (Decimal)

Sample input B: 999999223 (Decimal)

Do not use the multor multU

Do not use any other multiplication algorithm.

This program will be run using MARS. Please make sure that the code works using this platform before submitting an answer!

Explanation / Answer

Answer:

t1 dd 1143330295H
t2 dd 999999223H
temp dq ?
data ends
assume cs:code, ds:data
start:
mov a, data
mov ds, a
mov a, word ptr t1
mul word ptr t2
mov word ptr temp, a
mov c, d
mov a, word ptr t1+2
mul word ptr t2
add c, a
mov b, d
jnc move
add b,0001H
move: mov a,word ptr t1
mul word ptr t2+2
add c, a
mov word ptr temp+2, c
mov c,d
jnc ma
add b, 0001H
ma: mov a, word ptr t1+2
mul word ptr t2+2
add c, a
jnc mb
add d, 0001H
mb: add c, b
mov word ptr temp+4, c
jnc mc
add d, 0001H
mc: mov word ptr temp+6, d
code ends
end start

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote