MIPS Instruction Formats are sometimes called MIPS instruction encoding formats. Instruction encoding means the MIPS instruction are translated into binary numbers and then bring back to original format for human understanding(decoding). Encoding should be done in a way that decoding is easy. MIPS ISA has a 32-bit fixed instruction encoding. MIPS instruction formats include:
- I-Format
- J-Format
- J-Format
- FI-Format
- FR Format
MIPS Instruction Format Table
Let's discuss MIPS instruction formats in details with tables:
NAME | TOTAL 32-BITS | DESCRIPTION | |||||
---|---|---|---|---|---|---|---|
Field Size | 6-bits | 5-bits | 5-bits | 5-bits | 5-bits | 6-bits | total 32-bits |
R-Format | opcode | rs | rt | rd | shamt | funct | Arithematic and Logic Instructions |
I-Format | opcode | rs | rt | immediate value | Branches, Immediate, Data Transfer | ||
J-Format | opcode | Target Address | Jump Instructions | ||||
FR-Format | opcode | fmt | ft | fs | fd | funct | Floating Point (R) Instructions |
FI-Format | opcode | fmt | ft | immediate value | Floating Point (I) Instructions |
MIPS R-Format
General R-type instruction has the following form:
[code]opcode $rd, $rs, $rt[/code]MIPS Instruction R-Format is used for arithmetic and logical instruction. Encoding format used for
MIPS R-Formate is given below:
TOTAL 32-BITS | |||||
---|---|---|---|---|---|
6-bits | 5-bits | 5-bits | 5-bits | 5-bits | 6-bits |
opcode | rs | rt | rd | shamt | funct |
Opcode (bit 31-bit 26)
Opcode stands for "operational code". It is the machine representation of instructions. It's is 6-bit long.
rs (bit 25-bit 21)
The first source register is rs. The source register contains a value for the operation. It's is 5-bit long.
rt (bit 20-bit 16)
This is the second source register. It's is 5-bit long.
rd (bit 15-bit 11)
The destination register is rd. It stores the result of operations performed or rs and rt. It's is 5-bit long.
shamt (bit 10-bit 6)
Shamt stands for shift amount. It shows how many bits rs is shifted. It's is 5-bit long.
funct (bit 5-bit 0)
The function is used in addition to opcode to specify the operation. Its size is 6-bits.
R Type Instruction Format Example
Consider the following subtraction example to understand the use of R-type:
[code]sub $t1, $t2, $t3
Where SUB is the opcode, $t1 is the destination register $rd, $t2 is the first source and $t3 is the second source register.
[/code]MIPS I-Format
I stands for "immediate value". An immediate is a 16-bit value. The General form of an I-Type instruction is as follows:
[code]opcode $rt, $rs, immediate value[/code]Encoding format used for MIPS I-Formate is given below:
TOTAL 32-BITS | |||||
---|---|---|---|---|---|
6-bits | 5-bits | 5-bits | 5-bits | 5-bits | 6-bits |
opcode | rs | rt | immediate value |
Opcode (bit 31-bit 26)
It is operational code. It is the machine representation of instructions. It's is 6-bit long. i.e. add, sub
rs (bit 25-bit 21)
The first source register is rs. The source register contains a value for the operation. It's is 5-bit long.
rt (bit 20-bit 16)
Rt is the destination register. It contains the results.
immediate value(bit 15-bit 0)
Immediate value is a 16-bit value used with another source register.
I-type Instruction Format Example
Consider the following subtraction example to understand the use of I-type:
[code]li $t2,30
sub $t1, $t2, 26
Where SUB is the opcode, $t1 is the destination register $rt, $t2 is the first source and 26 is the immediate value.
[/code]MIPS J-Format
J stands for "JUMP.". J-type has a jump instruction and a target address. General representation of J-Type is as follows:
[code]jump Target_Address
[/code]TOTAL 32-BITS | |||||
---|---|---|---|---|---|
6-bits | 5-bits | 5-bits | 5-bits | 5-bits | 6-bits |
opcode | Target Address |
Opcode (bit 31-bit 26)
In I-format opcode is a 6-bit jump instruction. They are usually j, jal, jar etc
Target Address (bit 25-bit 0)
The target address is 26-bit address in a program where the control is to be transferred.
J-type Instruction Format Example
Consider the following subtraction example to understand the use of I-type:
[code]j addition
addition:
add $t1,$t2,$t3
Here we have a 26-bit target address "addition".
[/code]MIPS FR-Format
It's similar to R-type instruction, the only difference is that it is reserved for floating point numbers.
TOTAL 32-BITS | |||||
---|---|---|---|---|---|
6-bits | 5-bits | 5-bits | 5-bits | 5-bits | 6-bits |
opcode | fmt | ft | fs | fd | funct |
MIPS FI-Format
It's similar to I-type instruction, the only difference is that it is reserved for floating point numbers.
TOTAL 32-BITS | |||||
---|---|---|---|---|---|
6-bits | 5-bits | 5-bits | 5-bits | 5-bits | 6-bits |
opcode | rs | rt | immediate value |
Thats all about MIPS Instruction formats. Comment to show me if it was helpful. Waiting for you!