Ask Question
5 December, 03:10

Write a program to do the following: Load $t0 with 12 and call it x. Load 21 in $t1 and denote it as y. Finally, load 32 in $t2 and refer to it as z. Now, compute 3x2 + 10y+5z. Output the result using syscall 1 (remember the result has to be in $a0). Write down the output number on your answer sheet.

+5
Answers (1)
  1. 5 December, 03:21
    0
    Complete code is given below:

    Explanation:

    addi $t0, $zero, 12 # x = 12

    addi $t1, $zero, 21 # y = 21

    addi $t2, $zero, 32 # z = 32

    addi $t3, $zero, 3

    mul $t3, $t3, $t0

    mul $t3, $t3, $t0 # $t3 = 3x^2

    addi $t4, $zero, 10

    mul $t4, $t4, $t1 # $t4 = 10y

    addi $t5, $zero, 5

    mul $t5, $t5, $t2 # $t5 = 5z

    add $a0, $t3, $t4

    add $a0, $a0, $t5 # $a0 = 3x^2 + 10y + 5z

    addi $v0, $zero, 1

    syscall
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a program to do the following: Load $t0 with 12 and call it x. Load 21 in $t1 and denote it as y. Finally, load 32 in $t2 and refer ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers