偏移值是多少,beq 指令的地址是什么?
What will be the offset value and what will be the address of beq instruciton?
第一条指令在指令内存中的“0”位置。
Label:
lw $t0,8($t1)
add $t3,$t2,$t0
beq $t3,$t4,Label
jump Label
假设reg $t3和reg $t4的值相等,则跳转到Label地址。
那么,我想问一下Label的偏移值是多少,beq指令的地址是多少?
beq
指令是Label(地址为0000)之后的3条指令。所以 beq 在 4*3 = 12 + 0000 = 0012 地址。
你说 $t3 == $t4,所以 offset 告诉汇编程序返回 4 条指令,所以:
PCnew = (PCold + 4) + Label * 4
PCold 是 0016 并且 Label 是 -4 ,所以 PCnew 等于 0000 并返回到 Label:
在指令 j Label
Imm26(26 位)中,标签的地址除以 4 ... 所以技术上是 0000。在跳转指令之后:
PCnew = (Label*4) = (0000)*4 = 0000
第一条指令在指令内存中的“0”位置。
Label:
lw $t0,8($t1)
add $t3,$t2,$t0
beq $t3,$t4,Label
jump Label
假设reg $t3和reg $t4的值相等,则跳转到Label地址。 那么,我想问一下Label的偏移值是多少,beq指令的地址是多少?
beq
指令是Label(地址为0000)之后的3条指令。所以 beq 在 4*3 = 12 + 0000 = 0012 地址。
你说 $t3 == $t4,所以 offset 告诉汇编程序返回 4 条指令,所以:
PCnew = (PCold + 4) + Label * 4
PCold 是 0016 并且 Label 是 -4 ,所以 PCnew 等于 0000 并返回到 Label:
在指令 j Label
Imm26(26 位)中,标签的地址除以 4 ... 所以技术上是 0000。在跳转指令之后:
PCnew = (Label*4) = (0000)*4 = 0000