Professional Documents
Culture Documents
MIPS Assembly Language: An Introduction: Paritos H
MIPS Assembly Language: An Introduction: Paritos H
MIPS Assembly Language: An Introduction: Paritos H
An Introduction
Paritos
h
Computer Languages:
Classification based on level of abstraction
High level languages (C, C++, Java, Python, Matlab) more closer to natural
language
You dont need to worry about the platform you are working language takes care of
memory management
Advantage: programming is easy
Disadvantage: less efficient, slower than lower level languages, sometimes code may
not work as you had intended
Assembly
language
RISC
Used, mainly, in embedded systems
Machine
code
Instruction set
3 types of instructions:
R register to register
I - immediate
J jump
R type instructions
Example: addition: Sum = number_1 + number_2 (number are
stored in registers, so you are essentially adding contents of 2
registers)
Sum -> destination, number_1 -> source 1, number_2 ->source
2
J type instructions
Example: jump: j d -> jump to address specified by d
Instruction formats
Assembly language code is translated to machine code
Machine code line consists of strings of 0s and 1s: 00010 00011
Instruction format means how the machine code is formatted
R type instruction
6 bits opcode, 5 bits for register1, 5 bits for register2, 5 bits for
destination register, 5 bits for shift amount, 6 bits for funct
I type instruction
6 bits for opcode, 5 bits for register1, 5 bits for destination register,
16 bits for immediate number
J type instruction
6 bits for opcode, 26 bits for address
Sample code
We will use MARS a MIPS simulator
Install Java if needed
Registers
One of the key advantages of assembly language is
direct control of the registers closer than higher
level languages