Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi ! I need help finding the error in my MIPS code. The error is shown in image four highlighted in yellow. I think it

Hi! I need help finding the error in my MIPS code. The error is shown in image four highlighted in yellow. I think it might have to do with the concatnation code. Here is my code with explanation:
# Start step 1
lw $t0,0($s0) #Store A[0] in $t0
lw $t1,4($s0) #Store A[1] in $t1
# Start step 2
mult $t0, $t1 #Multiply A[0]* A[1]
mflo $t2
mfhi $t3
sw $t2,8($s0) #Store in A[2]
sw $t3,12($s0) #Store in A[3]
# Start step 3
addi $t4, $zero, 230
div $t2, $t4 #Divide A[2] by 230
mflo $t5 #Store the quotient in $t5
mfhi $s1 #Store remainder as variable a (this is step 4)
sw $t5,16($s0) #Store quotient in A[4]
# Start step 5
srl $s2, $s1,16 #Shift $s1(a)16 bits to the right and store in $s2(b)
# Start step 6
andi $s3, $s1,8 #Perform bitwise AND of $s1(a) and 8, store result in $s3(c)
# Start step 7
sll $s4, $s1,2 #Shift $s1(a)2 bits to the left and store results in $s4(d)
# Start step 8
or $s2, $s2, $s3 #Combine b($s2) and c($s3)
or $s2, $s2, $s4 #Combine with d($s4)
sw $s2,20($s0) #Store result in A[5]
# Write comments explaining your code and all the registers and memory used
# Step 1: Load A[0] into $t0 and A[1] into $t1
# Step 2: Calculate {A[3], A[2]}= A[1]* A[0]
# Step 3: Calculate A[4]= A[2]/230 by storing constant 230 $t4
# Step 4: Caluclate a = A[2]%230 where a will be $s1
# Step 5: Calculate b = a >>16 which is a '>>'= right shift where b is $s2
# Step 6: Calculate c = a & 8 where '&'= bit-wise and and c is $s3
# Step 7: Calculate d = a 2 where ''= left shift and d is $s4
# Step 8: Calculate A[5]={b, c, d} where {}= concatenation and b is $s2, c is $s3, and d is $s4
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

More Books

Students also viewed these Databases questions