Question

Write MIPS codes to compute the following sums:    (a) 1^2 - 2^3 + 3^2 -4^3...

Write MIPS codes to compute the following sums:
   (a) 1^2 - 2^3 + 3^2 -4^3 (b) 5^3 -6^2 + 7^3 - 8^2

Homework Answers

Answer #1

solution:

given data:

MIPS codes:

A)

.text
li $t0,1
li $t1,2
jal getPower
move $s0,$t2 #get 1^2

li $t0,2
li $t1,3
jal getPower
move $s1,$t2 #get 2^3

li $t0,3
li $t1,2
jal getPower
move $s2,$t2 #get 3^2

li $t0,4
li $t1,3
jal getPower
move $s3,$t2 #get 4^3


sub $t7,$s0,$s1
add $t7,$t7,$s2
sub $t7,$t7,$s3

li $v0,1
move $a0,$t7
syscall


li $v0,10
syscall

getPower: # return power $t0 ^ $t1 and return in $t2
li $t2,1
loop :
mul $t2,$t2,$t0 #loop for the value of s2
subi $t1,$t1,1
bgtz $t1,loop
jr $ra

B)

.text
li $t0,5
li $t1,3
jal getPower
move $s0,$t2 #get 5^3

li $t0,6
li $t1,2
jal getPower
move $s1,$t2 #get 6^2

li $t0,7
li $t1,3
jal getPower
move $s2,$t2 #get 7^3

li $t0,8
li $t1,2
jal getPower
move $s3,$t2 #get 8^2


sub $t7,$s0,$s1
add $t7,$t7,$s2
sub $t7,$t7,$s3

li $v0,1
move $a0,$t7
syscall


li $v0,10
syscall

getPower: # return power $t0 ^ $t1 and return in $t2
li $t2,1
loop :
mul $t2,$t2,$t0 #loop for the value of s2
subi $t1,$t1,1
bgtz $t1,loop
jr $ra

please give me thumb up

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Compute the following product. 6 -2 5 4 4 5 9 -5 -4 -1 -7 -5...
Compute the following product. 6 -2 5 4 4 5 9 -5 -4 -1 -7 -5 -5 8 1 -3 5 10 10 7 6 -9 -4 -10
Given the following data: Year 1 2 3 4 5 Housing Starts (in Thousands) 3 6...
Given the following data: Year 1 2 3 4 5 Housing Starts (in Thousands) 3 6 2 5 4 Refrigerator Sales (in Millions) 6 7 4 10 8 Year 1 2 3 4 5 Housing Starts (in Thousands) 3 6 2 5 4 Refrigerator Sales (in Millions) 6 7 4 10 8 a) Use the Sum of Squares or Total Variation equation discussed in class to compute the Coefficient of Determination. b) Interpret your answer in part(a).
Compute the indicated operation involving the following permutations in S6: δ = ( 1 2 3...
Compute the indicated operation involving the following permutations in S6: δ = ( 1 2 3 4 5 6 3 1 4 5 6 2 ) σ = ( 1 2 3 4 5 6 2 4 5 1 6 3 ) µ = ( 1 2 3 4 5 6 5 2 4 3 1 6 ) a. δ2σ-2 b. µ23 c. Find the order of µ, |〈µ〉|. d. Write σ as product of disjoint cycles, and as product...
Part A: Compute the derivative of ℎ(?)=(?^2 − 5)(9?^5 − 4? −4) Part B: Compute the...
Part A: Compute the derivative of ℎ(?)=(?^2 − 5)(9?^5 − 4? −4) Part B: Compute the derivative of ?(?)= (x^5 + 4x + 6)/(x^7 - 7) Part C: Compute the derivative of ?(?)=(?^8 − 8?)(1/x^4)
Compute the order of the permutation (1 6 3 9 4)(1 7 9)(2 8 7 4)....
Compute the order of the permutation (1 6 3 9 4)(1 7 9)(2 8 7 4). [Note: These cycles are not disjoint.]
Following is a preview of the matrix x: Code: [,1] [,2] [,3] [1,] 1 3 5...
Following is a preview of the matrix x: Code: [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 Write the code that return the output: [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6 [3,] 7 8 9
2. Write the output matrix “v” t = [2:4]; k = [1:3]; v = t.*k –...
2. Write the output matrix “v” t = [2:4]; k = [1:3]; v = t.*k – k.^2 4. Given: D = [1 2 3 4 5 6 7 8 9] (3x3) . Which command will extract the submatrix [1 2 3 4 5 6] (2x3) ? a. D[1:2,1:3] b. D(1,2 ;1,3) c. [D(1:2),D(1:3)] d. D(1:2,1:3) 14. What will be the dimension of matrix B? B=[ones(3) zeros(3) rand(3); 2*eye(9)] 18. Find the value of “C” A=1:2:10; B=linspace(1,5,5); C = length(A)*B(2)+A(5)*B(3); 19....
Prompt: Write a code in MARS MIPS that uses a stack to recursively compute the series...
Prompt: Write a code in MARS MIPS that uses a stack to recursively compute the series from 1 to 10.
write a java code. Write a program using loops to compute the sum of the 30...
write a java code. Write a program using loops to compute the sum of the 30 terms of the series below. 91/(3 + 2 + 2) + 92/(4 - 4 + 5) + 93/(5 + 6 - 8) + 94/(6 - 8 + 11) + 95/(7 + 10 + 14) + 96/(8 - 12 - 17) + . . . . Output: Term Ratio Sum 1 13 13 2 18.4 31.4 etc etc
Subject # Honesty Satisfaction 1 5 9 2 3 2 3 7 10 4 2 6...
Subject # Honesty Satisfaction 1 5 9 2 3 2 3 7 10 4 2 6 5 4 4 6 6 7 1)Given the data illustrated in the table above, compute the equation for the linear regression line (i.e. y = mx+b) (7--pts) 2)Based on the regression line you computed, what is the likely level of satisfaction if a person were to have an honesty level a.2.5 b.8? c.3.5?