MIPS 指令集 move 与 add/addi 0 用于存储值?
我目前正在修读计算机组织和汇编语言课程,主要使用MIPS指令集来教授汇编语言。
我注意到教授在线发布的许多示例都使用 add 或 addi 将值移动到 $a0 参数寄存器中以调用打印服务,如下所示...
# store the first integer in $a0 and print
add $a0, $zero, $t0
li $v0, 1
syscall
或者...
# store the first integer in $a0 and print
addi $a0, $t0, 0
li $v0, 1
syscall
我还注意到一些在线示例,其中其他人只是使用 move 指令来完成相同的事情,如下所示...
# store the first integer in $a0 and print
move $a0, $t0
li $v0, 1
syscall
在这种情况下,使用 add 或 addi 指令是否优于仅使用 move ?如果是这样那为什么?是否存在性能差异或者这只是品味问题?
I'm currently taking a Computer Organization and Assembly Language course that mainly uses the MIPS instruction set to teach assembly language.
I noticed that many of the examples that the professor has posted online use add or addi to move a value into the $a0 argument register for calling print services like the following...
# store the first integer in $a0 and print
add $a0, $zero, $t0
li $v0, 1
syscall
or...
# store the first integer in $a0 and print
addi $a0, $t0, 0
li $v0, 1
syscall
I've also noticed some examples online where others just use the move instruction to accomplish the same thing like the following...
# store the first integer in $a0 and print
move $a0, $t0
li $v0, 1
syscall
Is using the add or addi instruction preferred over simply using move in this scenario? If so then why? Is there a performance difference or is this just a matter of taste?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
move
指令不是真正的指令 - 它是一条伪指令,由汇编器转换为add
指令。有一大堆这些伪指令,请参见 https://en.wikipedia.org/wiki /MIPS_architecture#Pseudo_instructions
这种类型的事情在 RISC 处理器上很常见,您需要一个最小的指令集,并且一条特定的指令可能用于多个目的。
The
move
instruction is not a real instruction - it is a pseudo instruction that is translated into anadd
instruction by the assembler.There are a whole bunch of these pseudo instructions, see e.g. https://en.wikipedia.org/wiki/MIPS_architecture#Pseudo_instructions
This type of thing is very common on RISC processors, where you want a minimal instruction set, and a particular instruction may be used for more than one purpose.