开发者

How to convert MIPS instructions to hex with large numbers?

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" fi开发者_开发知识库elds, 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.


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 an lui (load the top 16 bits of the immediate constant into the destination register), followed by an addi (add in the bottom 16 bits of the immediate constant) followed by an add (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.


According to http://en.wikibooks.org/wiki/MIPS_Assembly/Instruction_Formats, immediate values are a maximum of 16 bits.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜