Consider the following MIPS code (don\'t worry about what it does): loop: beq $s
ID: 3785306 • Letter: C
Question
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.Explanation / Answer
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
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.