mips - 查找代码片段的偏移量

标签 mips cpu-architecture mips32

我对以下问题有点困惑,

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/

相关文章:

assembly - 如何在循环中访问数组的各个元素?

assembly - 引导加载程序参数通过参数寄存器传递到 Linux 内核 (MIPS 24KEc)

ios - Xcode - 缺少架构(库链接)

memory - 处理器是否使用Intel QuickPath Interconnect(QPI)来访问内存?

assembly - 关于否定 mips 中的符号整数?

d - 是否可以为 MIPS 交叉编译 D 源代码?

substring - Mips中的子串

C:malloc()、free() 和 malloc() 是否总是一样工作?

linux - usbip 不适用于 OpenWRT