Ask Question
18 July, 19:07

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.

+2
Answers (1)
  1. 18 July, 20:28
    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?
Get 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 there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers