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

Consider two registers Ss0 and Ssl holding the values 0x00000002 and 0x80000003.

ID: 3722681 • Letter: C

Question

Consider two registers Ss0 and Ssl holding the values 0x00000002 and 0x80000003. Multiplication of two 32 bit values result in a 64-bit product. Write a MIPS code using 'mult' to multiply the above given values and to hold the upper 32 bits of the product in Ss2 and the lower 32 bits of the product in Ss3. Write a MIPS code using 'multu' to multiply the above given values and to hold the upper 32 bits of the product in Sa0 and the lower 32 bits of the product in Sal Write a MIPS code using shift instructions to multiply the contents of Ss2 with 4, storing the result in Sv0 and divide the contents of Ss3 with 2 and store the results in Sv1 Write down the contents of registers Ss2, Ss3, Sa0, Sal, Sv0 and Sv. a. b. c.

Explanation / Answer

Consider two registers $s0 and $s1 holding the values 0x00000002 and 0x80000003.

(a)

li $s0, 0x00000002  

li $s1, 0x80000003

mult $s0, $s1

mfhi $s2 # 32 most significant bits of multiplication to $s2

mflo $s3 # 32 least significant bits of multiplication to $s3

(b)

li $s0, 0x00000002

li $s1, 0x80000003

multu $s0, $s1

mfhi $a0 # 32 most significant bits of multiplication to $a0

mflo $a1 # 32 least significant bits of multiplication to $a1

(c)

li $s0, 0x00000002

li $s1, 0x80000003

mult $s0, $s1

mfhi $s2 # 32 most significant bits of multiplication to $s2

mflo $s3 # 32 least significant bits of multiplication to $s3

multu $s0, $s1

mfhi $a0 # 32 most significant bits of multiplication to $a0

mflo $a1 # 32 least significant bits of multiplication to $a1

sll $v0,$s2,2 # multiply the contents of $s2 with 4

sra $v1,$s3,1 # divide the contents of $s3 with 2

# Write down the contents of registers $s2, $s3, $a0, $al, $v0 # and $v1

li $v0,1

move $a0, $s2

syscall            

li $v0,1

move $a0, $s3      

syscall

li $v0,1

move $a0, $a0

syscall  

li $v0,1

move $a0, $a1      

syscall

li $v0,1

move $a0, $v0

syscall  

li $v0,1

move $a0, $v1      

syscall            

    

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