Hi this is what I need to do
- Declare a word array A with 2 elements with initialized values.
- Declare a word variable B with initialized value as 0.
- Calculate the cvalue of B with the following expression: B= A[0] + A[1] -6.
- Make sure B's value is saved back into memory.
This is what I have so far.
#Program to read a number and print its square
.data #variable used follow this line
A: .word 4,8
B: .word 0
.text #program's code after this line
main:
add A[0], A[1], $t1 #Move the integer into $t1
sub $t1, 6, $t1 #Multiply the contents of $t1 with itself
move $a0, $t1 #Load $a0 with the value in $t1
end:
li $v0, 10 #System call code to Exit
syscall #call OS to Exit the program
I initialized the values, but I'm not sure how or where I need to store them. I was thinking of using a load address, but am unsure how to use it at this point. Also I can't do the math, like add because I don't know where the values are being stored. I'm also not sure what to do about the -6, like if I should somehow store that value as well. Finally I'm not sure how to check to make sure the value was stored in B. Any ideas or any help will be greatly apprecitated.