Computer Organization & Assembly Language: Lab Manual 5
Computer Organization & Assembly Language: Lab Manual 5
Computer Organization & Assembly Language: Lab Manual 5
Lab Manual 5
R-Format
I-Format
J-Format
FI-Format
FR Format
MIPS R-Format
MIPS Instruction R-Format is used for arithmetic and logical instruction. Encoding format used for
TOTAL 32-BITS
The first source register is rs. The source register contains a value for the operation. It's is 5-bit long.
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.
The function is used in addition to opcode to specify the operation. Its size is 6-bits.
Where SUB is the opcode, $t1 is the destination register $rd, $t2 is the first source and $t3 is the
second source register.
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:
TOTAL 32-BITS
It is operational code. It is the machine representation of instructions. It's is 6-bit long. i.e. add, sub
The first source register is rs. The source register contains a value for the operation. It's is 5-bit long.
li $t2,30
Where SUB is the opcode, $t1 is the destination register $rt, $t2 is the first source and 26 is the
immediate value.
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:
jump Target_Address
TOTAL 32-BITS
In I-format opcode is a 6-bit jump instruction. They are usually j, jal, jar etc
j addition
addition:
add $t1,$t2,$t3
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
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
Mips Registers
A Register is the smallest memory on a processor. There are multiple registers on a processor
assigned various tasks. In assembly language, we operate on data through a set of registers. There
are different registers for each architecture such as MIPS registers, X86 registers, and ARM
registers. It can be directly addressed or accessed.
A register is usually equal to the size of the processor. I.e., if a processor is 32 bit than the registers
will also be 32 bits.
Whereas there are some basic registers used for various operation on a processor. Some of the basic
registers are:
Memory buffer register (MBR)
Memory address register (MAR)
Instruction register (IR)
Instruction buffer register (IBR)
Program counter (PC)
Accumulator (AC) and multiplier quotient (MQ)
Mips Registers Table
In MIPS assembly each register is 32 bit. These registers are divided into the general purpose and
special purpose registers.
There are 32 general purpose registers. General purpose means these all can be used as an operand
in the instructions but still there are limitations for some registers. i.e
Task:
Write a program in which:
Mips Syntax is pretty similar to x86 and Arm syntax. Below is the basic syntax of MIPS instruction
set:
.text
Example 1:
.data
welcome: .asciiz “\nWelcome to MIPS:”
.text
Example 2:
.data
msg1: .asciiz “\nSum of value and 100:”
In the above msg1 is variable initialized with string data.
.text
li $t0, 5
Hope you understood the basic Syntax! If there any question let us know in the comment box.
Task:
Your task is to print your roll no, name, batch and subject.