[英]MIPS BNE Machine Code Conversion
I am attempting to convert about 25 lines of a MIPS program from machine code into instructions.我试图将大约 25 行 MIPS 程序从机器代码转换为指令。
When I convert the machine code of 0x1620fff9
, it yields the following: 000101 10001 00000 1111 1111 1111 1001
当我转换0x1620fff9
,它会产生以下结果: 000101 10001 00000 1111 1111 1111 1001
I understand this is I-format, and the instruction is BNE
with a target register of $17
and a source of $0
, however the immediate/address is what I am confused about.我知道这是 I 格式,指令是BNE
,目标寄存器为$17
,源为$0
,但是立即数/地址是我感到困惑的。
As 1111 1111 1111 1001
is a signed number, its two's complement yields a result of -7
.由于1111 1111 1111 1001
是有符号数,其二进制补码产生-7
的结果。 I just dont know what to do with that result.我只是不知道该怎么处理这个结果。 The MARS simulator needs a label for where it should branch to, but I am unclear as to what to do. MARS 模拟器需要一个标签,说明它应该分支到哪里,但我不清楚要做什么。 The program I am converting only has a main function and a print function.我正在转换的程序只有一个主要功能和一个打印功能。
Thanks谢谢
So it turns out that MARS and QTSpim handle those instructions differently:所以结果是 MARS 和 QTSpim 处理这些指令的方式不同:
MARS always jumps from the instruction after the branch instruction which is exactly what a pipelined machine is supposed to do; MARS 总是从分支指令之后的指令跳转,这正是流水线机器应该做的;
QtSPIM jumps from the branch instruction, which is easier to understand. QtSPIM从分支指令跳转,比较容易理解。
Under MARS, bne instruction is 0x1620fff8, while under QtSPIM, it is 0x1620fff9. MARS下bne指令为0x1620fff8,QtSPIM下为0x1620fff9。
Our professor made concessions for the differing results, but I thought that this may be useful to someone in the future.我们的教授对不同的结果做出了让步,但我认为这可能对将来的某人有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.