简体   繁体   English

具有真实指令助记符的伪指令

[英]Pseudoinstructions with real instruction mnemonics

str9 is a label for a byte allocated in a .data section, and the address of this byte is 0x1001_58e4 . str9.data节中分配的字节的标签,该字节的地址为0x1001_58e4 Determine the machine code that would be generated as a result of this pseudo instruction: 确定此伪指令的结果将生成的机器代码

lbu $t1, str9

I don't understand why this is a pseudo instruction at all and why 0x1001_58e4 can not just simply be loaded in to the $t1 GPR with the given instruction. 我根本不明白为什么这是一条伪指令,以及为什么不能仅使用给定指令将0x1001_58e4简单地加载到$t1 GPR中。 Can someone please explain to me why this does not work in this case. 有人可以告诉我为什么在这种情况下不起作用。 What real instructions does the assembler do when dealing with this case? 汇编程序在处理这种情况时会执行哪些实际指令? I know how to translate the instruction to machine code once I find the real instructions but just don't understand the need for real instructions as my professor has said it needs to be broken down into 2. 一旦找到真正的指令,我就知道如何将指令转换为机器代码,但由于我的教授曾说过需要将其分解为2,所以只是不了解实际指令的必要性。

Have you tried to turn this into a single instruction? 您是否尝试过将其变成一条指令? Have you succeeded? 你成功了吗? :) :)

Hint: the address itself is a 32 bit value ( 0x1001_58e4 ) and mips instructions are 32 bit, so if you wanted to encode this there would be no place left for the opcode and the destination register. 提示:地址本身是一个32位值( 0x1001_58e4 ),而mips指令是32位,因此,如果要对其进行编码,则操作码和目标寄存器将没有剩余空间。

So, you need to do it in 2 instructions. 因此,您需要按照2条说明进行操作。 First, you load the top 16 bits of the address into $t1 , then use a true lbu giving the low 16 bits as offset to the top 16: 首先,您将地址的高16位加载到$t1 ,然后使用真实的lbu给出低16位作为高16位的偏移量:

lui $t1, 0x1001
lbu $t1, 0x58e4($t1)

What real instructions does the assembler do when dealing with this case? 汇编程序在处理这种情况时会执行哪些实际指令?

You can always just assemble and disassemble: 您始终可以组装和拆卸:

Disassembly of section .text:

00000000 <.text>:
   0:   3c091001        lui     t1,0x1001
   4:   912958e4        lbu     t1,22756(t1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM