Reputation: 4421
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.
Upvotes: 2
Views: 3056
Reputation: 19981
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.
Upvotes: 1
Reputation: 38442
According to http://en.wikibooks.org/wiki/MIPS_Assembly/Instruction_Formats, immediate values are a maximum of 16 bits.
Upvotes: 1