I got this question on a midterm, and I want to know what the right answer is.
Here is the question:
Let x[] be an array of integers and k be an integer. suppose that the memory address of x and k are specified by the two labels "x" and "k" respectively. implement the following statement in the mips assembly language x[4] = x[5] +k
Here is my attempt of answering, and i only got half mark:
//addresses of x, k, 4, and 5
la $s0, x
la $s1, k
li $s2, 4
li $s3, 5
//assume $s1 = x[4] and $s2 = x[5]
la $s3, k
add $s1, $s2, $s3 //x[4] = x[5] + k
the feedback said i should have lw and sw but i'm not sure what to do with them.