SlideShare a Scribd company logo
2
Most read
9
Most read
12
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

PPT
Mips architecture
PPTX
Instruction Set Architecture: MIPS
PPTX
Instruction Set of 8086 Microprocessor
PDF
Unit 3 – assembly language programming
DOCX
8086 pin diagram description
PPTX
Assembly language
PDF
Intel x86 Architecture
PPT
Instruction set of 8086
Mips architecture
Instruction Set Architecture: MIPS
Instruction Set of 8086 Microprocessor
Unit 3 – assembly language programming
8086 pin diagram description
Assembly language
Intel x86 Architecture
Instruction set of 8086

What's hot (20)

PPTX
Instruction set of 8086
PPTX
4.programmable dma controller 8257
PPTX
8086 Microprocessor
PDF
8086 instruction set with types
PPTX
8086 pin configuration
PDF
Session 8,9 PCI Express
PPTX
Instruction sets of 8086
PPT
Logic, shift and rotate instruction
PPTX
3.programmable interrupt controller 8259
PPT
8086-microprocessor
PPTX
8051 memory
PPT
Axi protocol
PPTX
8086 microprocessor
PPTX
Stack in microprocessor 8085(presantation)
PPTX
Programmers model of 8086
PPTX
INTEL 80386 MICROPROCESSOR
PDF
8086 String Instructions.pdf
PPTX
Assembly language
Instruction set of 8086
4.programmable dma controller 8257
8086 Microprocessor
8086 instruction set with types
8086 pin configuration
Session 8,9 PCI Express
Instruction sets of 8086
Logic, shift and rotate instruction
3.programmable interrupt controller 8259
8086-microprocessor
8051 memory
Axi protocol
8086 microprocessor
Stack in microprocessor 8085(presantation)
Programmers model of 8086
INTEL 80386 MICROPROCESSOR
8086 String Instructions.pdf
Assembly language
Ad

Similar to MIPS Architecture (20)

PPT
MIPS instruction set microprocessor lecture notes
PPT
Assembly.ppt
PPTX
Introduction to Computer Architecture
PPTX
Computer Organization Unit 3 Computer Fundamentals
PPTX
Introduction to Assembly Language & various basic things
PPTX
Introduction to Computer Architecture: unit 1
PPTX
Lecture 2 coal sping12
PPT
CODch3Slides.ppt
PPTX
Unit 1 computer architecture_gghhhjjhbh.pptx
PPTX
CSe_Cumilla Bangladesh_Country CSE CSE213_5.ppt
PPT
Assembly Language Basics
PPTX
Co&amp;al lecture-05
PPT
Computer Architecture Patterson chapter 3.ppt
PPT
12 mt06ped008
PPT
Assembly language programming_fundamentals 8086
PPTX
Computer Architecturebhhgggfggtggeerr.pptx
PDF
CE412 -advanced computer Architecture lecture 1.pdf
PPTX
Basic Structure of a Computer System
PPTX
instructionsetsofjdtufgmictfgfjh8086.pptx
MIPS instruction set microprocessor lecture notes
Assembly.ppt
Introduction to Computer Architecture
Computer Organization Unit 3 Computer Fundamentals
Introduction to Assembly Language & various basic things
Introduction to Computer Architecture: unit 1
Lecture 2 coal sping12
CODch3Slides.ppt
Unit 1 computer architecture_gghhhjjhbh.pptx
CSe_Cumilla Bangladesh_Country CSE CSE213_5.ppt
Assembly Language Basics
Co&amp;al lecture-05
Computer Architecture Patterson chapter 3.ppt
12 mt06ped008
Assembly language programming_fundamentals 8086
Computer Architecturebhhgggfggtggeerr.pptx
CE412 -advanced computer Architecture lecture 1.pdf
Basic Structure of a Computer System
instructionsetsofjdtufgmictfgfjh8086.pptx
Ad

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
A Presentation on Artificial Intelligence
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Machine learning based COVID-19 study performance prediction
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Approach and Philosophy of On baking technology
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
cuic standard and advanced reporting.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Empathic Computing: Creating Shared Understanding
NewMind AI Weekly Chronicles - August'25 Week I
A Presentation on Artificial Intelligence
Agricultural_Statistics_at_a_Glance_2022_0.pdf
NewMind AI Monthly Chronicles - July 2025
Diabetes mellitus diagnosis method based random forest with bat algorithm
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Unlocking AI with Model Context Protocol (MCP)
Machine learning based COVID-19 study performance prediction
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Network Security Unit 5.pdf for BCA BBA.
Approach and Philosophy of On baking technology
Per capita expenditure prediction using model stacking based on satellite ima...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
cuic standard and advanced reporting.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Encapsulation_ Review paper, used for researhc scholars
Reach Out and Touch Someone: Haptics and Empathic Computing
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Empathic Computing: Creating Shared Understanding

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")