MIPS“;洛杉矶”;伪指令
有人能给我解释一下为什么MARS把伪指令翻译成两条指令:lui和ori?是否存在只翻译一条指令的情况 这个简单的程序MIPS“;洛杉矶”;伪指令,mips,Mips,有人能给我解释一下为什么MARS把伪指令翻译成两条指令:lui和ori?是否存在只翻译一条指令的情况 这个简单的程序 .data msg: .asciiz "This is a string" .text la $a0, msg # pseudo-instruction to load the address of the label str 翻译成指令 Address Code Basic
.data
msg: .asciiz "This is a string"
.text
la $a0, msg # pseudo-instruction to load the address of the label str
翻译成指令
Address Code Basic Source
0x00400000 0x3c011001 lui $1,0x00001001 4 la $a0, msg # pseudo-instruction to load the address of the label str
0x00400004 0x34240000 ori $4,$1,0x00000000
这两个指令总是很好。
lui指令使立即数向左移位16位并存储在寄存器中。低16位为零
通过这种方式,您可以使用32位指令加载32位地址(在mips32中)。您可能知道,每种类型的命令都有一个“类似”的结构。命令的结构如下: 为值保存的大小实际上是他们将其拆分为两个不同命令的问题/原因 您可以在图中看到,value的最大类型(I-type,最低类型)只有26位。地址有一个32位的值,因为您知道32位的值不能放入26位的命令中。因此他们将其分为两个步骤:
- 第一步:使用r-type命令(LUI)load upper immediate(图中的第二种结构)将地址加载到寄存器的上16位。只需将上16位复制到寄存器的上16位
- 第二步:使用or指令复制地址的低16位。因此,它只会将地址的较低部分“复制”到寄存器的较低部分