如何将MIPS指令转换为具有大数字的十六进制?
如何转换 MIPS 指令,例如 addi $1,$2,90000
如果我以操作码 001 000、函数字段 10 0000 以及相应的寄存器“rs”、“rt”开始“字段,90000 到十六进制是 5 位数字,而不是 4 位......所以我的总十六进制表示不适合 8 位数字。
实际上,我更感兴趣的是当有大量数字扰乱十六进制表示时如何从十六进制转换为 MIPS。
How do I convert a MIPS instruction such as addi $1,$2,90000
If I start with an opcode of 001 000, funct field of 10 0000, and the corresponding registers for the "rs", "rt" fields, the 90000 to hex is 5 digits and not 4.... so my total hex representation does not fit into 8 digits.
Actually, I'm more interested in how to go from hex to MIPS when there's a huge number that is messing up the hex representation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 http://en.wikibooks.org/wiki/MIPS_Assembly/Instruction_Formats,立即值最多为 16 位。
According to http://en.wikibooks.org/wiki/MIPS_Assembly/Instruction_Formats, immediate values are a maximum of 16 bits.
MIPS 汇编器通常会实现“合成指令”,将其转换为多个实际指令。例如,具有 32 位立即数操作数的
addi
合成指令可以变成lui
(将立即数的前 16 位加载到目标寄存器中),然后由一个addi
(在立即常量的底部16位中添加),然后是一个add
(在源寄存器中添加)。因此,没有一条指令与
addi $1,$2,90000
相对应。如果您的汇编器接受这一点,您会发现在反汇编它生成的内容(或检查列表文件,如果它生成一个)时,它实际上为该单行汇编生成了多个机器指令。It is common for MIPS assemblers to implement "synthetic instructions" that get turned into multiple real instructions. For instance, an
addi
synthetic instruction with a 32-bit immediate operand can turn into anlui
(load the top 16 bits of the immediate constant into the destination register), followed by anaddi
(add in the bottom 16 bits of the immediate constant) followed by anadd
(add in the source register).So, there is no single instruction that corresponds to
addi $1,$2,90000
. If your assembler accepts that, you'll find on disassembling what it produces (or inspecting the listing file if it produces one) that it's actually generated multiple machine instructions for that single line of assembly.