Consider the following MIPS code dont worry about what it do
Consider the following MIPS code (don\'t worry about what it does): loop: beq $s0, $s1, done addi $t0, $t0, 7 addi St1, St2, 4 addi $s0, $s0, 1 j loop done: beq St1, $15, skip addi $t0, $t0, 1 add $t1, $t2, $t0 skip addi $t5, $0, 10 beq $t1, $t5, done j end Compute the branch offset for each beq in number of words away from the branch (e.g., \"branch offset is 2\"). Assume label loop is at location 0 times 00114214 and label end is at location 0 times 00032794. Compute the correct value to place in the jump address field for each jump instruction in the MIPS code above.
Solution
a) In loop:
beq offset is 4
In done:
beq offset is 3
In skip:
beq offset is 4
b)
address of Loop = 0x00114124=0b00000000000100010100000100100100
divided by 4 ,we get, address = 0b00000000000001000101000001001001
address of end =0x00032794=0b00000000000000110010011110010100
divided by 4 , we get,address = 0b00000000000000001100100111100101
Therefore ,Correct value to be placed in the jump address:
a) j loop , the correct value to be placed is 0b00000000000001000101000001001001
b) j end , the correct value to be placed is 0b00000000000000001100100111100101
