Assume that h in $t5, base address of array A in $s4, what is the corresponding
ID: 3834086 • Letter: A
Question
Assume that h in $t5, base address of array A in $s4, what is the corresponding MIPS code for the C statement? A [10] = h + A[3]; Assume the base address of array A is in register $s4, and variable b, c, and i are in $s1, $s2, and $s3, respectively. What is the MIPS assembly code for the C statement? c = A[i] - b All about the branch Instruction For MIPS conditional branch instruction, bne $s1, $s2, LI, it will compare the contents from register $s1 and $s2, and jump to a new target address if they are not equal. Its instruction format is as follows: Suppose the instruction bne $s1, $s2, LI, is stored in memory location with address 2000, and the 16 bit offset is denoted using 2" complement. Please briefly explain how to calculate the 32-bit target address when it takes the branch? and based on the instruction format, what is the range of the target address (branch distance)?
Explanation / Answer
Given h is in $t5 location and the base address of array A is $s4
So given A[10]=h+A[3];
Mips code for that is
Given base address of A means A[0]=$s4
So A[10]=$s14 and A[3]=$s7
Now the answer is add $t0 $t5, $s7
Mov $s14, $t0
2)given base address A[0]=$s4
b=$t1
C=$t2
i=$s3
Now mips. Code for c=A[i] - b
Load $s4, $s3
Sub $p0 $s4, $t1
Mve $t2, $p0
First loading the indexes then subtracting the values from. Those indexes then storing that result into another register