[英]Calculate target address of mips assembly control instruction
Given the assembly instruction: 给定组装指令:
bne $s0, $s1, DONE
The address of the instruction is 500
bytes. 指令的地址为
500
字节。 If the offset field contains the following value: 如果offset字段包含以下值:
1111111111110100
what is the target address? 目标地址是什么? Explain your answer.
解释你的答案。
Is the answer to this question : 494
? 这个问题的答案是:
494
吗? My reasoning is that the offset field in decimal is -10
but i am not sure about it :( and the address of pc at this point is 500+4
so: 我的理由是,十进制的偏移量字段是
-10
但我不确定:(而此时pc的地址是500+4
因此:
target address = pc address + (offset)= 504+(-10) = 494.
I wanted to know if i am doing it correct or not. 我想知道我是否做对了。
Thanks 谢谢
You are correct, except that 1111111111110100
is not -10 in decimal, it's -12. 您是正确的,除了
1111111111110100
十进制数不是-10,而是-12。 Thus, the target address is 504-12 = 492. 因此,目标地址是504-12 = 492。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.