我对以下问题有点困惑,
Consider the following MIPS code and answer the questions that follow.
addi $t1, $s0, 400
loop: lw $s1, 0($s0)
add $s2, $s2, $s1
lw $s1, 4($s0)
add $s2, $s2, $s1
addi $s0, $s0, 8
bne $t1, $s0, loop
What value is the label loop translated to in the conditional branch instruction?
现在我知道了分支目标地址的数学公式。但这里由于内存寻址没有完成,所以我通过计算目标地址和PC之间的行来找出偏移量。答案为 7(字偏移)。我的这种方法正确吗?
最佳答案
使用 MARS 模拟器进行快速实验 http://courses.missouristate.edu/KenVollmar/MARS/download.htm给了我答案-6,-5表示行数差异,另一个-1,因为PC在指令后增加了1。
关于mips - 查找代码片段的偏移量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8048192/