220k views
2 votes
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.

1 Answer

1 vote

Answer:

addi $t0, $zero, 12

addi $t1, $zero, 21

addi $t2, $zero, 32

addi $t3, $zero, 3

mul $t3, $t3, $t0

mul $t3, $t3, $t0

addi $v, $zero, 10

mul $v, $v, $t1

addi $w, $zero, 5

mul $w, $w, $t2

add $a0, $t3, $v

add $a0, $a0, $w

addi $v0, $zero, 1

syscall

Step-by-step explanation:

  • Use the addi statement to initialize the t0, t1 and t2 variables with a 0 value.
  • Use the mul statement to multiply the t0 with t3 and then multiply variable v with t1.
  • Use the add statement to add the variable v with t3 and assign the result to a0 variable.
  • Use the add statement to add the variable w with a0 and assign the result to a0 variable.

User GRoutar
by
3.9k points