Translate one array operation from C to ASM: a = b * X[Y[2]], where assume X[] is from the memory address $s0; Y[] is from the memory address $s1; (ASM will use the least number of registers as needed)
Please find the answer below.
Please do comments in case of any issue. Also, don't forget to rate
the question. Thank You So Much.
#address of X is in $s0
#address of Y is in $s1
#also s2 is representing a
#also s3 is representing b
lw $t0,8($s1) #load Y[2]
mul $t0,$t0,4 #get address of Y[2]
add $t0,$t0,$s0 #get address of X[Y[2]]
mul $s0,$1,$t0 # a = b*X[Y[2]]
Get Answers For Free
Most questions answered within 1 hours.