SlideShare a Scribd company logo
2
Most read
6
Most read
8
Most read
MIPS Architecture
Data Types and Literals
Data types:
Instructions are all 32 bits
byte(8 bits), halfword (2 bytes), word (4 bytes)
a character requires 1 byte of storage
an integer requires 1 word (4 bytes) of storage
Literals:
Numbers entered as is. e.g. 4
Characters enclosed in single quotes. e.g. 'b'
Strings enclosed in double quotes. e.g. "A string"
Registers
• 32 general-purpose registers
• register preceded by $ in assembly language
instruction
two formats for addressing:
– using register number e.g. $0 through $31
– using equivalent names e.g. $t1, $sp
• special registers Lo and Hi used to store result of
multiplication and division
– not directly addressable; contents accessed with special
instruction mfhi ("move from Hi") and mflo ("move from
Lo")
• stack grows from high memory to low memory
Register
Number
Alternative
Name
Description
0 zero the value 0
1 $at (assembler temporary) reserved by the assembler
2-3 $v0 - $v1 (values) from expression evaluation and function results
4-7 $a0 - $a3
(arguments) First four parameters for subroutine.
Not preserved across procedure calls
8-15 $t0 - $t7
(temporaries) Caller saved if needed. Subroutines can use
w/out saving.
Not preserved across procedure calls
16-23 $s0 - $s7
(saved values) - Call saved.
A subroutine using one of these must save original and
restore it before exiting.
Preserved across procedure calls
24-25 $t8 - $t9
(temporaries) Caller saved if needed. Subroutines can use
w/out saving.
These are in addition to $t0 - $t7 above.
Not preserved across procedure calls.
26-27 $k0 - $k1 reserved for use by the interrupt/trap handler
28 $gp
global pointer.
Points to the middle of the 64K block of memory in the static
data segment.
29 $sp
stack pointer
Points to last location on the stack.
30 $s8/$fp
saved value / frame pointer
Preserved across procedure calls
Program Structure
• Data Declarations
– placed in section of program identified with assembler
directive .data
– declares variable names used in program; storage
allocated in main memory (RAM)
• Code
– placed in section of text identified with assembler
directive .text
– contains program code (instructions)
– starting point for code e.g.excution given label main:
– ending point of main code should use exit system call
• Comments
• anything following # on a line
# This stuff would be considered a comment
Data Declarations
• format for declarations:
name: storage_type value(s)
create storage for variable of specified type with
given name and specified value
– value(s) usually gives initial value(s);
– for storage type .space, gives number of spaces to
be allocated
• Storage_type : word, byte,half word
Examples of Data Declarations
• var1: .word 3
# create a single integer variable with initial value 3
• array1: .byte 'a','b'
# create a 2-element character array with elements initialized # to a
and b
• array2: .space 40
# allocate 40 consecutive bytes, with storage uninitialized # could be
used as a 40-element character array, or a # 10-element integer array; a
comment should indicate which!
Load / Store Instructions
• Load / Store Instructions
– Memory access only allowed with load and store
instructions
– all other instructions use register operands
• load:
lw register_destination, Memory
# copy word (4 bytes) at source RAM location to
destination register.
lb register_destination, Memory
#copy byte at source RAM location to low-order byte
of destination register,and sign extended to higher-order
bytes
Store Word
sw register_source, Memory
#store word in source register into RAM
destination
sb register_source, Memory
#store byte (low-order) in source register into
RAM destination
load Immediate
li register_destination, value
#load immediate value into destination register
Example of Data Transfer Instruction
.data
var1: .word 23
.text
__start:
lw $t0, var1
li $t1, 5
sw $t1, var1
Arithmetic Instructions
• most use 3 operands
• all operands are registers; no RAM or indirect addressing
• operand size is word (4 bytes)
• add $t0,$t1,$t2 # $t0 = $t1 + $t2
add as signed (2's complement) integers
• sub $t2,$t3,$t4 # $t2 = $t3 - $t4
• addi $t2,$t3, 5 # $t2 = $t3 + 5 "add immediate" (no
sub immediate)
• addu $t1,$t6,$t7 # $t1 = $t6 + $t7; add as unsigned
integers
• subu $t1,$t6,$t7 # $t1 = $t6 + $t7; subtract as unsigned
integers
Control Structures
• Branches
• comparison for conditional branches is built into
instruction
• b target # unconditional branch to program label target
• beq $t0,$t1,target # branch to target if $t0 = $t1
• blt $t0,$t1,target # branch to target if $t0 < $t1
• ble $t0,$t1,target # branch to target if $t0 <= $t1
• bgt $t0,$t1,target # branch to target if $t0 > $t1
• bge $t0,$t1,target # branch to target if $t0 >= $t1
• bne $t0,$t1,target # branch to target if $t0 <> $t1
• j target
# unconditional jump to program label target
• jr $t3
# jump to address contained in $t3 ("jump
register")
MIPS Architecture

More Related Content

What's hot (20)

PPT
8086
Ravi Anand
 
PPTX
4.programmable dma controller 8257
MdFazleRabbi18
 
DOCX
Instruction set of 8086
Vijay Kumar
 
PPT
isa architecture
AJAL A J
 
PPTX
8255 PPI
deval patel
 
PPTX
Stacks & subroutines 1
deval patel
 
PPTX
Segment registers
maamir farooq
 
PPT
Memory Addressing
chauhankapil
 
PPT
Architecture of 8086 Microprocessor
Mustapha Fatty
 
PPTX
DAA AND DAS
Basavaraj Shetty
 
PPTX
MIPS Instruction Set
babuece
 
PPT
8086 assembly language
Mir Majid
 
PPTX
Part I:Introduction to assembly language
Ahmed M. Abed
 
PDF
8086 instructions
Ravi Anand
 
PPTX
8086 Microprocessor powerpoint
Randhir Kumar
 
PPTX
block diagram of 8086
asrithak
 
PPTX
General register organization (computer organization)
rishi ram khanal
 
PPTX
Stack and its usage in assembly language
Usman Bin Saad
 
PPTX
Data transfer and manipulation
PreethaPreetha5
 
PPTX
SHLD and LHLD instruction
Romilkumar Siddhapura
 
4.programmable dma controller 8257
MdFazleRabbi18
 
Instruction set of 8086
Vijay Kumar
 
isa architecture
AJAL A J
 
8255 PPI
deval patel
 
Stacks & subroutines 1
deval patel
 
Segment registers
maamir farooq
 
Memory Addressing
chauhankapil
 
Architecture of 8086 Microprocessor
Mustapha Fatty
 
DAA AND DAS
Basavaraj Shetty
 
MIPS Instruction Set
babuece
 
8086 assembly language
Mir Majid
 
Part I:Introduction to assembly language
Ahmed M. Abed
 
8086 instructions
Ravi Anand
 
8086 Microprocessor powerpoint
Randhir Kumar
 
block diagram of 8086
asrithak
 
General register organization (computer organization)
rishi ram khanal
 
Stack and its usage in assembly language
Usman Bin Saad
 
Data transfer and manipulation
PreethaPreetha5
 
SHLD and LHLD instruction
Romilkumar Siddhapura
 

Similar to MIPS Architecture (20)

PPTX
Lecture 2 coal sping12
Rabia Khalid
 
PPT
Module 1-ppt System programming
vishnu sankar
 
PPTX
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
ALPHONCEKIMUYU
 
PPT
Variables, identifiers, constants, declaration in c
GayathriShiva4
 
PPT
Chapter02.PPTArray.pptxArray.pptxArray.pptx
yatakumar84
 
PPT
C language ppt is a presentation of how to explain the introduction of a c la...
sdsharmila11
 
PPT
THE BASIC CONCEPTS OF C PROGRAMMINGPPT.PPT
shanthabalaji2013
 
PPT
A File is a collection of data stored in the secondary memory. So far data wa...
bhargavi804095
 
PPT
Chapter02.PPT
Chaitanya Jambotkar
 
PPT
Introduction to Problem Solving C Programming
RKarthickCSEKIOT
 
PPT
c programming 2nd chapter pdf.PPT
KauserJahan6
 
PPT
introduction2_programming slides briefly exolained
RumaSinha8
 
PPTX
Computer Organization Unit 3 Computer Fundamentals
AntonySuresh13
 
PPTX
Introduction to C Programming language Chapter02.pptx
foxel54542
 
PDF
C programming language
Mahmoud Eladawi
 
PPT
Assembler
Mohd Arif
 
PPT
(246431835) instruction set principles (2) (1)
Alveena Saleem
 
PPT
Escape Sequences and Variables
yarkhosh
 
PDF
7986-lect 7.pdf
RiazAhmad521284
 
PPTX
MODULE- 3-CO-Instructions and Programs.pptx
ravindraravi7677
 
Lecture 2 coal sping12
Rabia Khalid
 
Module 1-ppt System programming
vishnu sankar
 
CHAPTER 3 STRUCTURED PROGRAMMING.pptx 2024
ALPHONCEKIMUYU
 
Variables, identifiers, constants, declaration in c
GayathriShiva4
 
Chapter02.PPTArray.pptxArray.pptxArray.pptx
yatakumar84
 
C language ppt is a presentation of how to explain the introduction of a c la...
sdsharmila11
 
THE BASIC CONCEPTS OF C PROGRAMMINGPPT.PPT
shanthabalaji2013
 
A File is a collection of data stored in the secondary memory. So far data wa...
bhargavi804095
 
Chapter02.PPT
Chaitanya Jambotkar
 
Introduction to Problem Solving C Programming
RKarthickCSEKIOT
 
c programming 2nd chapter pdf.PPT
KauserJahan6
 
introduction2_programming slides briefly exolained
RumaSinha8
 
Computer Organization Unit 3 Computer Fundamentals
AntonySuresh13
 
Introduction to C Programming language Chapter02.pptx
foxel54542
 
C programming language
Mahmoud Eladawi
 
Assembler
Mohd Arif
 
(246431835) instruction set principles (2) (1)
Alveena Saleem
 
Escape Sequences and Variables
yarkhosh
 
7986-lect 7.pdf
RiazAhmad521284
 
MODULE- 3-CO-Instructions and Programs.pptx
ravindraravi7677
 
Ad

Recently uploaded (20)

PPTX
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
PDF
SalesForce Managed Services Benefits (1).pdf
TechForce Services
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PPTX
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
PDF
Market Insight : ETH Dominance Returns
CIFDAQ
 
PPTX
PCU Keynote at IEEE World Congress on Services 250710.pptx
Ramesh Jain
 
PPTX
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
PDF
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
PDF
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
PDF
introduction to computer hardware and sofeware
chauhanshraddha2007
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PPTX
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Per Axbom: The spectacular lies of maps
Nexer Digital
 
Earn Agentblazer Status with Slack Community Patna.pptx
SanjeetMishra29
 
SalesForce Managed Services Benefits (1).pdf
TechForce Services
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
Market Insight : ETH Dominance Returns
CIFDAQ
 
PCU Keynote at IEEE World Congress on Services 250710.pptx
Ramesh Jain
 
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
introduction to computer hardware and sofeware
chauhanshraddha2007
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Per Axbom: The spectacular lies of maps
Nexer Digital
 
Ad

MIPS Architecture

  • 2. Data Types and Literals Data types: Instructions are all 32 bits byte(8 bits), halfword (2 bytes), word (4 bytes) a character requires 1 byte of storage an integer requires 1 word (4 bytes) of storage Literals: Numbers entered as is. e.g. 4 Characters enclosed in single quotes. e.g. 'b' Strings enclosed in double quotes. e.g. "A string"
  • 3. Registers • 32 general-purpose registers • register preceded by $ in assembly language instruction two formats for addressing: – using register number e.g. $0 through $31 – using equivalent names e.g. $t1, $sp • special registers Lo and Hi used to store result of multiplication and division – not directly addressable; contents accessed with special instruction mfhi ("move from Hi") and mflo ("move from Lo") • stack grows from high memory to low memory
  • 4. Register Number Alternative Name Description 0 zero the value 0 1 $at (assembler temporary) reserved by the assembler 2-3 $v0 - $v1 (values) from expression evaluation and function results 4-7 $a0 - $a3 (arguments) First four parameters for subroutine. Not preserved across procedure calls 8-15 $t0 - $t7 (temporaries) Caller saved if needed. Subroutines can use w/out saving. Not preserved across procedure calls
  • 5. 16-23 $s0 - $s7 (saved values) - Call saved. A subroutine using one of these must save original and restore it before exiting. Preserved across procedure calls 24-25 $t8 - $t9 (temporaries) Caller saved if needed. Subroutines can use w/out saving. These are in addition to $t0 - $t7 above. Not preserved across procedure calls. 26-27 $k0 - $k1 reserved for use by the interrupt/trap handler 28 $gp global pointer. Points to the middle of the 64K block of memory in the static data segment. 29 $sp stack pointer Points to last location on the stack. 30 $s8/$fp saved value / frame pointer Preserved across procedure calls
  • 6. Program Structure • Data Declarations – placed in section of program identified with assembler directive .data – declares variable names used in program; storage allocated in main memory (RAM) • Code – placed in section of text identified with assembler directive .text – contains program code (instructions) – starting point for code e.g.excution given label main: – ending point of main code should use exit system call
  • 7. • Comments • anything following # on a line # This stuff would be considered a comment
  • 8. Data Declarations • format for declarations: name: storage_type value(s) create storage for variable of specified type with given name and specified value – value(s) usually gives initial value(s); – for storage type .space, gives number of spaces to be allocated • Storage_type : word, byte,half word
  • 9. Examples of Data Declarations • var1: .word 3 # create a single integer variable with initial value 3 • array1: .byte 'a','b' # create a 2-element character array with elements initialized # to a and b • array2: .space 40 # allocate 40 consecutive bytes, with storage uninitialized # could be used as a 40-element character array, or a # 10-element integer array; a comment should indicate which!
  • 10. Load / Store Instructions • Load / Store Instructions – Memory access only allowed with load and store instructions – all other instructions use register operands • load: lw register_destination, Memory # copy word (4 bytes) at source RAM location to destination register. lb register_destination, Memory #copy byte at source RAM location to low-order byte of destination register,and sign extended to higher-order bytes
  • 11. Store Word sw register_source, Memory #store word in source register into RAM destination sb register_source, Memory #store byte (low-order) in source register into RAM destination
  • 12. load Immediate li register_destination, value #load immediate value into destination register
  • 13. Example of Data Transfer Instruction .data var1: .word 23 .text __start: lw $t0, var1 li $t1, 5 sw $t1, var1
  • 14. Arithmetic Instructions • most use 3 operands • all operands are registers; no RAM or indirect addressing • operand size is word (4 bytes) • add $t0,$t1,$t2 # $t0 = $t1 + $t2 add as signed (2's complement) integers • sub $t2,$t3,$t4 # $t2 = $t3 - $t4 • addi $t2,$t3, 5 # $t2 = $t3 + 5 "add immediate" (no sub immediate) • addu $t1,$t6,$t7 # $t1 = $t6 + $t7; add as unsigned integers • subu $t1,$t6,$t7 # $t1 = $t6 + $t7; subtract as unsigned integers
  • 15. Control Structures • Branches • comparison for conditional branches is built into instruction • b target # unconditional branch to program label target • beq $t0,$t1,target # branch to target if $t0 = $t1 • blt $t0,$t1,target # branch to target if $t0 < $t1 • ble $t0,$t1,target # branch to target if $t0 <= $t1 • bgt $t0,$t1,target # branch to target if $t0 > $t1 • bge $t0,$t1,target # branch to target if $t0 >= $t1 • bne $t0,$t1,target # branch to target if $t0 <> $t1
  • 16. • j target # unconditional jump to program label target • jr $t3 # jump to address contained in $t3 ("jump register")