Skip to content

6) MIPS instructions

mindersm edited this page Dec 13, 2014 · 2 revisions

Five main instruction types

There are various languages, or instruction styles, even for our simple MIPS processor. The one that was used primarily to create the processor was the ‘R’ type instruction using 16 bits. There are other instruction types that could be used to operate with a MIPS processor, but the main types are R, memory reference (load and store), I, J.

Breakdown of the Instructions

There are 8 types of bits that would be found in all of the MIPS instruction set. these are;

opcode; this defines what function is to be performed
rs; this is the register that is supplying the information
rt; this is the second source register (R-Type), or the destination register
rd; this is the destination register for R-Type instructions shamt; this is the shift amount, or how much a register needs to be shifted
function; this determines which operation is to be performed
immediate; this is used to locate where to load data from or store data to memory. address; this is used to set where a set of memory will be going.

Although this seems to be confusing at first, reading through what each instruction type is will clear up the meaning of each of these bit types.

Arithmetic or "R-Type" Instructions

The ‘R’ means that the instructions are stored in a register file and is the most complex as it allows for the largest amount of instructions. These instructions can only write to a register file however. The layout of an R type is as follows;
4- opcode
2- rs
2- rt
2-rd
2-shamt
2-funct

Load and Store Instructions

These will take one type of data and convert it to another. So this instruction set will load from memory and then write to a register or it will load from a register and save to the memory. This function is important as the R type instruction can only write to a register, and this instruction will allow the result to be saved. They layout of a load and store function looks like;
4-opcode
2-rs
2-rt
8-immediate

Branch or "I" Instructions

Immediate means that the instruction must operate on an immediate instruction or register value, this type is the second most complex it also allows for branching. Branching is important as allows for the processor to execute conditional statements (i.e. loops, if, and case statements).
The breakdown of the bits of this type of instruction is as follows;
4-opcode
2-rs
2-rt
8-immediate

Jump Instructions

Jump instructions are used for jumping by the processor and is the simplest command of the three instructions sets, as they do not contain any other commands other than the jumping of the information. This is mostly used for data storage.
The breakdown of jump instructions goes like this;
4-opcode
12-address

Clone this wiki locally