32.7k views
5 votes
Given x’s address = 5000, what C statement does the following assembly carry out?

addi $t0, $zero, 5000
addi $t1, $zero, -4
sw $t1, 0($t0)

a. x=−4
b. x=0
c. x=4996
d. x=5000

User Sydelle
by
7.5k points

1 Answer

5 votes

Final answer:

The given C statement x = −4.

Step-by-step explanation:

The given C statement is x = −4.

The assembly instructions are:

  1. addi $t0, $zero, 5000: This instruction adds the immediate value 5000 to the $zero register and stores the result in $t0.
  2. addi $t1, $zero, -4: This instruction adds the immediate value -4 to the $zero register and stores the result in $t1.
  3. sw $t1, 0($t0): This instruction stores the value in $t1 (which is -4) at the address specified by $t0 (which is 5000).

Therefore, the value of x after executing these instructions is -4.

User Michael Sandino
by
7.8k points