MIPS架构移动VS添加/阿迪0存储值? [英] MIPS instruction set move vs add/addi 0 for storing values?

查看:184
本文介绍了MIPS架构移动VS添加/阿迪0存储值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前采取这一主要采用MIPS指令集教汇编语言计算机组织与汇编语言课程。

I'm currently taking a Computer Organization and Assembly Language course that mainly uses the MIPS instruction set to teach assembly language.

我注意到,许多与教授已经在网上发布使用添加或阿迪移动一个值到$ A0寄存器参数调用打印服务像下面的例子...

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

或...

# 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

时使用pferred超过只需在这种情况下使用移动的添加或ADDI指令$ P $?如果是的话,为什么?是否有性能差异或这仅仅是一个品味的问题?

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?

推荐答案

移动指令是不是一个真正的指令 - 这是一个的伪指令被翻译成由汇编添加指令。

The move instruction is not a real instruction - it is a pseudo instruction that is translated into an add instruction by the assembler.

有一大堆的这些伪指令,例如见<一href=\"https://en.wikipedia.org/wiki/MIPS_architecture#Pseudo_instructions\">https://en.wikipedia.org/wiki/MIPS_architecture#Pseudo_instructions

There are a whole bunch of these pseudo instructions, see e.g. https://en.wikipedia.org/wiki/MIPS_architecture#Pseudo_instructions

这类型的事情是很常见的RISC处理器,在那里你想有一个最小的指令集,和一个特定的指令可以被用于多个目的。

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.

这篇关于MIPS架构移动VS添加/阿迪0存储值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆