SlideShare une entreprise Scribd logo
1  sur  22
Computer Architecture
06:- MIPS ISA
Outline - Instruction Sets
• Instruction Set Overview
• MIPS Instruction Set
• Overview 
• Registers and Memory
• MIPS Instructions
MIPS
• MIPS:
Microprocessor without Interlocked Pipeline Stages
• We’ll be working with the MIPS instruction set architecture
• similar to other architectures developed since the 1980's
• Almost 100 million MIPS processors manufactured in 2002
• used by NEC, Nintendo, Cisco, Silicon Graphics, Sony, …
Outline - Instruction Sets
• Instruction Set Overview
• MIPS Instruction Set
• Overview
• Registers and Memory 
• MIPS Instructions
MIPS Registers and Memory
Memory
4GB Max
(Typically 64MB-1GB)
0x00000000
0x00000004
0x00000008
0x0000000C
0x00000010
0x00000014
0x00000018
0x0000001C
0xfffffff4
0xfffffffc
0xfffffffc
PC = 0x0000001C
Registers
32 General Purpose Registers
R0
R1
R2
R30
R31
32 bits
MIPS Registers and Usage
Name Register number Usage
$ z e r o 0 the constant value 0
$ a t 1 reserved for assembler
$ v 0 - $ v 1 2-3 values for results and expression evaluation
$ a 0 - $ a 3 4-7 arguments
$ t 0 - $ t 7 8-15 temporary registers
$ s 0 - $ s 7 16-23 saved registers
$ t 8 - $ t 9 24-25 more temporary registers
$ k 0 - $ k 1 26-27 reserved for Operating System kernel
$ g p 28 global pointer
$ s p 29 stack pointer
$ f p 30 frame pointer
$ r a 31 return address
Each register can be referred to by number or name.
More about MIPS Memory Organization
• Two views of memory:
• 232 bytes with addresses 0, 1, 2, …, 232-1
• 230 4-byte words* with addresses 0, 4, 8, …, 232-4
• Both views use byte addresses
• Word address must be multiple of 4 (aligned)
8 bits
0x00000000
0x00000001
0x00000002
0x00000003
0x00000000
0x00000004
0x00000008
0x0000000C
32 bits
0 1 2 3
*Word sizes vary in
other architectures
MIPS Instructions
• All instructions exactly 32 bits wide
• Different formats for different purposes
• Similarities in formats ease implementation
op rs rt offset
6 bits 5 bits 5 bits 16 bits
op rs rt rd functshamt
6 bits 5 bits 5 bits 5 bits 5 bits 6 bits
R-Format
I-Format
op address
6 bits 26 bits
J-Format
31 0
31 0
31 0
MIPS Instruction Types
• Arithmetic & Logical - manipulate data in registers
add $s1, $s2, $s3 $s1 = $s2 + $s3
or $s3, $s4, $s5 $s3 = $s4 OR $s5
• Data Transfer - move register data to/from memory
lw $s1, 100($s2) $s1 = Memory[$s2 + 100]
sw $s1, 100($s2) Memory[$s2 + 100] = $s1
• Branch - alter program flow
beq $s1, $s2, 25 if ($s1==$s1) PC = PC + 4 + 4*25
MIPS Arithmetic & Logical Instructions
• Instruction usage (assembly)
add dest, src1, src2 dest=src1 + src2
sub dest, src1, src2 dest=src1 - src2
and dest, src1, src2 dest=src1 AND src2
• Instruction characteristics
• Always 3 operands: destination + 2 sources
• Operand order is fixed
• Operands are always general purpose registers
• Design Principles:
• Design Principle 1: Simplicity favors regularity
• Design Principle 2: Smaller is faster
Arithmetic & Logical Instructions - Binary
Representation
• Used for arithmetic, logical, shift instructions
• op: Basic operation of the instruction (opcode)
• rs: first register source operand
• rt: second register source operand
• rd: register destination operand
• shamt: shift amount (more about this later)
• funct: function - specific type of operation
• Also called “R-Format” or “R-Type” Instructions
op rs rt rd functshamt
6 bits 5 bits 5 bits 5 bits 5 bits 6 bits
031
op rs rt rd functshamt
6 bits 5 bits 5 bits 5 bits 5 bits 6 bits
Decimal
Binary
Arithmetic & Logical Instructions -
Binary Representation Example
• Machine language for
add $8, $17, $18
• See reference card for op, funct values
000000
0
10001
17
10010
18
01000
8
00000
0
100000
32
031
MIPS Data Transfer Instructions
• Transfer data between registers and memory
• Instruction format (assembly)
lw $dest, offset($addr) load word
sw $src, offset($addr)store word
• Uses:
• Accessing a variable in main memory
• Accessing an array element
Example - Loading a Simple Variable
lw R5,8(R2) Memory
0x00
Variable Z = 692310
Variable X
Variable Y
0x04
0x08
0x0c
0x10
0x14
0x18
0x1c
8
+
Registers
R0=0 (constant)
R1
R2=0x10
R30
R31
R3
R4
R5R5
R2=0x10
R5 = 629310
Variable Z = 692310
Data Transfer Example - Array Variable
Registers
R0=0 (constant)
R1
R2=0x08
R30
R31
R3
R4
R5=105
C Program: int a[5];
a[3] = z;
Assembly: sw $5,12($2)
12=0xc
+
Memory
0x00
a[0]
a[4]
a[2]
a[1]
a[3]
0x04
0x08
0x0c
0x10
0x14
0x18
0x1c
Base Address
R5=105
R2=0x08
a[3]=105
scaled offset
Data Transfer Instructions -
Binary Representation
• Used for load, store instructions
• op: Basic operation of the instruction (opcode)
• rs: first register source operand
• rt: second register source operand
• offset: 16-bit signed address offset (-32,768 to
+32,767)
• Also called “I-Format” or “I-Type” instructions
op rs rt offset
6 bits 5 bits 5 bits 16 bits
Address
I-Format vs. R-Format Instructions
• Compare with R-Format
offset
6 bits 5 bits 5 bits 16 bits
I-Formatop rs rt
rd functshamt
6 bits 5 bits 5 bits 5 bits 5 bits 6 bits
R-Formatop rs rt
Note similarity!
I-Format Example
• Machine language for
lw $9, 1200($8) == lw $t1, 1200($t0)
op rs rt offset
6 bits 5 bits 5 bits 16 bits
Binary
Decimal35 8 9 1200
100011 01000 01001 0000010010110000
031
Binary Representation - Jump
• Jump Instruction uses J-Format (op=2)
• What happens during execution?
PC = PC[31:28] : (IR[25:0] << 2)
op address
6 bits 26 bits
Conversion to
word offset
Concatenate
upper 4 bits
of PC to form
complete
32-bit address
How to Decode?
• What is the assembly language statement
corresponding to this machine instruction?
0x00af8020
• Convert to binary
0000 0000 1010 1111 1000 0000 0010 0000
• Decode
• op: 00000
• rs: 00101
• rt: 01111
• rd: 10000
• shamt: 00000
• funct: 100000
• Solution: add $s0, $a1, $t7
Summary - MIPS Instruction Set
• simple instructions all 32 bits wide
• very structured, no unnecessary baggage
• only three instruction formats
op rs rt offset
6 bits 5 bits 5 bits 16 bits
op rs rt rd functshamt
6 bits 5 bits 5 bits 5 bits 5 bits 6 bits
R-Format
I-Format
op address
6 bits 26 bits
J-Format
Coming up Next
MIPS Assembly Language.
C u ……. Take Care,,,

Contenu connexe

Tendances

22cs201 COMPUTER ORGANIZATION AND ARCHITECTURE
22cs201 COMPUTER ORGANIZATION AND ARCHITECTURE22cs201 COMPUTER ORGANIZATION AND ARCHITECTURE
22cs201 COMPUTER ORGANIZATION AND ARCHITECTUREKathirvel Ayyaswamy
 
8086 Microprocessor
8086 Microprocessor 8086 Microprocessor
8086 Microprocessor Vijay Kumar
 
Introduction to Microprocessors
Introduction to MicroprocessorsIntroduction to Microprocessors
Introduction to Microprocessors76 Degree Creative
 
8086 instructions
8086 instructions8086 instructions
8086 instructionsRavi Anand
 
Assembly Language Lecture 4
Assembly Language Lecture 4Assembly Language Lecture 4
Assembly Language Lecture 4Motaz Saad
 
Architecture of 8086 microprocessor
Architecture of  8086 microprocessorArchitecture of  8086 microprocessor
Architecture of 8086 microprocessorAnirban Saha Anik
 
8086 assembly language
8086 assembly language8086 assembly language
8086 assembly languageMir Majid
 
Unit II arm 7 Instruction Set
Unit II arm 7 Instruction SetUnit II arm 7 Instruction Set
Unit II arm 7 Instruction SetDr. Pankaj Zope
 
Chapter 6 hardware structure of 8086
Chapter 6  hardware structure of 8086Chapter 6  hardware structure of 8086
Chapter 6 hardware structure of 8086SHREEHARI WADAWADAGI
 
Assembly Language for x86 Processors 7th Edition Chapter 2 : x86 Processor Ar...
Assembly Language for x86 Processors 7th Edition Chapter 2 : x86 Processor Ar...Assembly Language for x86 Processors 7th Edition Chapter 2 : x86 Processor Ar...
Assembly Language for x86 Processors 7th Edition Chapter 2 : x86 Processor Ar...ssuser65bfce
 
Assembly Language and microprocessor
Assembly Language and microprocessorAssembly Language and microprocessor
Assembly Language and microprocessorKhaled Sany
 
Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1Motaz Saad
 
Evolution of microprocessors and 80486 Microprocessor.
Evolution of microprocessors and 80486 Microprocessor.Evolution of microprocessors and 80486 Microprocessor.
Evolution of microprocessors and 80486 Microprocessor.Ritwik MG
 

Tendances (20)

22cs201 COMPUTER ORGANIZATION AND ARCHITECTURE
22cs201 COMPUTER ORGANIZATION AND ARCHITECTURE22cs201 COMPUTER ORGANIZATION AND ARCHITECTURE
22cs201 COMPUTER ORGANIZATION AND ARCHITECTURE
 
8086 Microprocessor
8086 Microprocessor 8086 Microprocessor
8086 Microprocessor
 
Introduction to Microprocessors
Introduction to MicroprocessorsIntroduction to Microprocessors
Introduction to Microprocessors
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
 
Assembly Language Lecture 4
Assembly Language Lecture 4Assembly Language Lecture 4
Assembly Language Lecture 4
 
ARM Fundamentals
ARM FundamentalsARM Fundamentals
ARM Fundamentals
 
Parallel Adder
Parallel Adder Parallel Adder
Parallel Adder
 
Architecture of 8086 microprocessor
Architecture of  8086 microprocessorArchitecture of  8086 microprocessor
Architecture of 8086 microprocessor
 
8086 assembly language
8086 assembly language8086 assembly language
8086 assembly language
 
Unit II arm 7 Instruction Set
Unit II arm 7 Instruction SetUnit II arm 7 Instruction Set
Unit II arm 7 Instruction Set
 
Chapter 6 hardware structure of 8086
Chapter 6  hardware structure of 8086Chapter 6  hardware structure of 8086
Chapter 6 hardware structure of 8086
 
Assembly Language for x86 Processors 7th Edition Chapter 2 : x86 Processor Ar...
Assembly Language for x86 Processors 7th Edition Chapter 2 : x86 Processor Ar...Assembly Language for x86 Processors 7th Edition Chapter 2 : x86 Processor Ar...
Assembly Language for x86 Processors 7th Edition Chapter 2 : x86 Processor Ar...
 
Ec8791 lpc2148 timer unit
Ec8791 lpc2148 timer unitEc8791 lpc2148 timer unit
Ec8791 lpc2148 timer unit
 
Microprocessor systems 8085(2)
Microprocessor systems 8085(2)Microprocessor systems 8085(2)
Microprocessor systems 8085(2)
 
Assembly Language and microprocessor
Assembly Language and microprocessorAssembly Language and microprocessor
Assembly Language and microprocessor
 
Subroutine
SubroutineSubroutine
Subroutine
 
8251 USART
8251 USART8251 USART
8251 USART
 
Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1
 
ARM Introduction
ARM IntroductionARM Introduction
ARM Introduction
 
Evolution of microprocessors and 80486 Microprocessor.
Evolution of microprocessors and 80486 Microprocessor.Evolution of microprocessors and 80486 Microprocessor.
Evolution of microprocessors and 80486 Microprocessor.
 

En vedette

Mips implementation
Mips implementationMips implementation
Mips implementationhoang974
 
05 instruction set design and architecture
05 instruction set design and architecture05 instruction set design and architecture
05 instruction set design and architectureWaqar Jamil
 
8 bit single cycle processor
8 bit single cycle processor8 bit single cycle processor
8 bit single cycle processorDhaval Kaneria
 
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...Rahul Borthakur
 
Lec 12-15 mips instruction set processor
Lec 12-15 mips instruction set processorLec 12-15 mips instruction set processor
Lec 12-15 mips instruction set processorMayank Roy
 
Computer Architecture – An Introduction
Computer Architecture – An IntroductionComputer Architecture – An Introduction
Computer Architecture – An IntroductionDilum Bandara
 
Instruction Set Architecture
Instruction Set ArchitectureInstruction Set Architecture
Instruction Set ArchitectureDilum Bandara
 

En vedette (9)

8 bit alu design
8 bit alu design8 bit alu design
8 bit alu design
 
Mips implementation
Mips implementationMips implementation
Mips implementation
 
05 instruction set design and architecture
05 instruction set design and architecture05 instruction set design and architecture
05 instruction set design and architecture
 
Case study of digital camera
Case study of digital cameraCase study of digital camera
Case study of digital camera
 
8 bit single cycle processor
8 bit single cycle processor8 bit single cycle processor
8 bit single cycle processor
 
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...
Designing of 8 BIT Arithmetic and Logical Unit and implementing on Xilinx Ver...
 
Lec 12-15 mips instruction set processor
Lec 12-15 mips instruction set processorLec 12-15 mips instruction set processor
Lec 12-15 mips instruction set processor
 
Computer Architecture – An Introduction
Computer Architecture – An IntroductionComputer Architecture – An Introduction
Computer Architecture – An Introduction
 
Instruction Set Architecture
Instruction Set ArchitectureInstruction Set Architecture
Instruction Set Architecture
 

Similaire à 06 mips-isa

LECTURE2 td 2 sue les theories de graphes
LECTURE2 td 2 sue les theories de graphesLECTURE2 td 2 sue les theories de graphes
LECTURE2 td 2 sue les theories de graphesAhmedMahjoub15
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristicsdilip kumar
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristicsSher Shah Merkhel
 
Instruction set.pptx
Instruction set.pptxInstruction set.pptx
Instruction set.pptxssuser000e54
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristicsAnwal Mirza
 
11-risc-cisc-and-isa-w.pptx
11-risc-cisc-and-isa-w.pptx11-risc-cisc-and-isa-w.pptx
11-risc-cisc-and-isa-w.pptxSuma Prakash
 
Tema2_ArchitectureMIPS.pptx
Tema2_ArchitectureMIPS.pptxTema2_ArchitectureMIPS.pptx
Tema2_ArchitectureMIPS.pptxgopikahari7
 
Lec18 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- In...
Lec18 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- In...Lec18 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- In...
Lec18 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- In...Hsien-Hsin Sean Lee, Ph.D.
 
6_2018_11_23!09_24_56_PM (1).pptx
6_2018_11_23!09_24_56_PM (1).pptx6_2018_11_23!09_24_56_PM (1).pptx
6_2018_11_23!09_24_56_PM (1).pptxHebaEng
 
Computer_Architecture.pptx
Computer_Architecture.pptxComputer_Architecture.pptx
Computer_Architecture.pptxJUNSHIN8
 
Introduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM ProcessorIntroduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM ProcessorDarling Jemima
 
Intel microprocessor history lec12_x86arch.ppt
Intel microprocessor history lec12_x86arch.pptIntel microprocessor history lec12_x86arch.ppt
Intel microprocessor history lec12_x86arch.pptjeronimored
 

Similaire à 06 mips-isa (20)

LECTURE2 td 2 sue les theories de graphes
LECTURE2 td 2 sue les theories de graphesLECTURE2 td 2 sue les theories de graphes
LECTURE2 td 2 sue les theories de graphes
 
CO_Chapter2.ppt
CO_Chapter2.pptCO_Chapter2.ppt
CO_Chapter2.ppt
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristics
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristics
 
Computer System Architecture
Computer System ArchitectureComputer System Architecture
Computer System Architecture
 
Instruction set.pptx
Instruction set.pptxInstruction set.pptx
Instruction set.pptx
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristics
 
11-risc-cisc-and-isa-w.pptx
11-risc-cisc-and-isa-w.pptx11-risc-cisc-and-isa-w.pptx
11-risc-cisc-and-isa-w.pptx
 
Tema2_ArchitectureMIPS.pptx
Tema2_ArchitectureMIPS.pptxTema2_ArchitectureMIPS.pptx
Tema2_ArchitectureMIPS.pptx
 
Lec18 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- In...
Lec18 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- In...Lec18 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- In...
Lec18 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- In...
 
Highlevel assemly
Highlevel assemlyHighlevel assemly
Highlevel assemly
 
Assembly.ppt
Assembly.pptAssembly.ppt
Assembly.ppt
 
Lecture 03 basics of pic
Lecture 03 basics of picLecture 03 basics of pic
Lecture 03 basics of pic
 
6_2018_11_23!09_24_56_PM (1).pptx
6_2018_11_23!09_24_56_PM (1).pptx6_2018_11_23!09_24_56_PM (1).pptx
6_2018_11_23!09_24_56_PM (1).pptx
 
ISA.pptx
ISA.pptxISA.pptx
ISA.pptx
 
Computer_Architecture.pptx
Computer_Architecture.pptxComputer_Architecture.pptx
Computer_Architecture.pptx
 
Lecture7.pdf
Lecture7.pdfLecture7.pdf
Lecture7.pdf
 
Introduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM ProcessorIntroduction to Processor Design and ARM Processor
Introduction to Processor Design and ARM Processor
 
Intel microprocessor history lec12_x86arch.ppt
Intel microprocessor history lec12_x86arch.pptIntel microprocessor history lec12_x86arch.ppt
Intel microprocessor history lec12_x86arch.ppt
 
Kirby, Fabro
Kirby, FabroKirby, Fabro
Kirby, Fabro
 

06 mips-isa

  • 2. Outline - Instruction Sets • Instruction Set Overview • MIPS Instruction Set • Overview • Registers and Memory • MIPS Instructions
  • 3. MIPS • MIPS: Microprocessor without Interlocked Pipeline Stages • We’ll be working with the MIPS instruction set architecture • similar to other architectures developed since the 1980's • Almost 100 million MIPS processors manufactured in 2002 • used by NEC, Nintendo, Cisco, Silicon Graphics, Sony, …
  • 4. Outline - Instruction Sets • Instruction Set Overview • MIPS Instruction Set • Overview • Registers and Memory • MIPS Instructions
  • 5. MIPS Registers and Memory Memory 4GB Max (Typically 64MB-1GB) 0x00000000 0x00000004 0x00000008 0x0000000C 0x00000010 0x00000014 0x00000018 0x0000001C 0xfffffff4 0xfffffffc 0xfffffffc PC = 0x0000001C Registers 32 General Purpose Registers R0 R1 R2 R30 R31 32 bits
  • 6. MIPS Registers and Usage Name Register number Usage $ z e r o 0 the constant value 0 $ a t 1 reserved for assembler $ v 0 - $ v 1 2-3 values for results and expression evaluation $ a 0 - $ a 3 4-7 arguments $ t 0 - $ t 7 8-15 temporary registers $ s 0 - $ s 7 16-23 saved registers $ t 8 - $ t 9 24-25 more temporary registers $ k 0 - $ k 1 26-27 reserved for Operating System kernel $ g p 28 global pointer $ s p 29 stack pointer $ f p 30 frame pointer $ r a 31 return address Each register can be referred to by number or name.
  • 7. More about MIPS Memory Organization • Two views of memory: • 232 bytes with addresses 0, 1, 2, …, 232-1 • 230 4-byte words* with addresses 0, 4, 8, …, 232-4 • Both views use byte addresses • Word address must be multiple of 4 (aligned) 8 bits 0x00000000 0x00000001 0x00000002 0x00000003 0x00000000 0x00000004 0x00000008 0x0000000C 32 bits 0 1 2 3 *Word sizes vary in other architectures
  • 8. MIPS Instructions • All instructions exactly 32 bits wide • Different formats for different purposes • Similarities in formats ease implementation op rs rt offset 6 bits 5 bits 5 bits 16 bits op rs rt rd functshamt 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits R-Format I-Format op address 6 bits 26 bits J-Format 31 0 31 0 31 0
  • 9. MIPS Instruction Types • Arithmetic & Logical - manipulate data in registers add $s1, $s2, $s3 $s1 = $s2 + $s3 or $s3, $s4, $s5 $s3 = $s4 OR $s5 • Data Transfer - move register data to/from memory lw $s1, 100($s2) $s1 = Memory[$s2 + 100] sw $s1, 100($s2) Memory[$s2 + 100] = $s1 • Branch - alter program flow beq $s1, $s2, 25 if ($s1==$s1) PC = PC + 4 + 4*25
  • 10. MIPS Arithmetic & Logical Instructions • Instruction usage (assembly) add dest, src1, src2 dest=src1 + src2 sub dest, src1, src2 dest=src1 - src2 and dest, src1, src2 dest=src1 AND src2 • Instruction characteristics • Always 3 operands: destination + 2 sources • Operand order is fixed • Operands are always general purpose registers • Design Principles: • Design Principle 1: Simplicity favors regularity • Design Principle 2: Smaller is faster
  • 11. Arithmetic & Logical Instructions - Binary Representation • Used for arithmetic, logical, shift instructions • op: Basic operation of the instruction (opcode) • rs: first register source operand • rt: second register source operand • rd: register destination operand • shamt: shift amount (more about this later) • funct: function - specific type of operation • Also called “R-Format” or “R-Type” Instructions op rs rt rd functshamt 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits 031
  • 12. op rs rt rd functshamt 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits Decimal Binary Arithmetic & Logical Instructions - Binary Representation Example • Machine language for add $8, $17, $18 • See reference card for op, funct values 000000 0 10001 17 10010 18 01000 8 00000 0 100000 32 031
  • 13. MIPS Data Transfer Instructions • Transfer data between registers and memory • Instruction format (assembly) lw $dest, offset($addr) load word sw $src, offset($addr)store word • Uses: • Accessing a variable in main memory • Accessing an array element
  • 14. Example - Loading a Simple Variable lw R5,8(R2) Memory 0x00 Variable Z = 692310 Variable X Variable Y 0x04 0x08 0x0c 0x10 0x14 0x18 0x1c 8 + Registers R0=0 (constant) R1 R2=0x10 R30 R31 R3 R4 R5R5 R2=0x10 R5 = 629310 Variable Z = 692310
  • 15. Data Transfer Example - Array Variable Registers R0=0 (constant) R1 R2=0x08 R30 R31 R3 R4 R5=105 C Program: int a[5]; a[3] = z; Assembly: sw $5,12($2) 12=0xc + Memory 0x00 a[0] a[4] a[2] a[1] a[3] 0x04 0x08 0x0c 0x10 0x14 0x18 0x1c Base Address R5=105 R2=0x08 a[3]=105 scaled offset
  • 16. Data Transfer Instructions - Binary Representation • Used for load, store instructions • op: Basic operation of the instruction (opcode) • rs: first register source operand • rt: second register source operand • offset: 16-bit signed address offset (-32,768 to +32,767) • Also called “I-Format” or “I-Type” instructions op rs rt offset 6 bits 5 bits 5 bits 16 bits Address
  • 17. I-Format vs. R-Format Instructions • Compare with R-Format offset 6 bits 5 bits 5 bits 16 bits I-Formatop rs rt rd functshamt 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits R-Formatop rs rt Note similarity!
  • 18. I-Format Example • Machine language for lw $9, 1200($8) == lw $t1, 1200($t0) op rs rt offset 6 bits 5 bits 5 bits 16 bits Binary Decimal35 8 9 1200 100011 01000 01001 0000010010110000 031
  • 19. Binary Representation - Jump • Jump Instruction uses J-Format (op=2) • What happens during execution? PC = PC[31:28] : (IR[25:0] << 2) op address 6 bits 26 bits Conversion to word offset Concatenate upper 4 bits of PC to form complete 32-bit address
  • 20. How to Decode? • What is the assembly language statement corresponding to this machine instruction? 0x00af8020 • Convert to binary 0000 0000 1010 1111 1000 0000 0010 0000 • Decode • op: 00000 • rs: 00101 • rt: 01111 • rd: 10000 • shamt: 00000 • funct: 100000 • Solution: add $s0, $a1, $t7
  • 21. Summary - MIPS Instruction Set • simple instructions all 32 bits wide • very structured, no unnecessary baggage • only three instruction formats op rs rt offset 6 bits 5 bits 5 bits 16 bits op rs rt rd functshamt 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits R-Format I-Format op address 6 bits 26 bits J-Format
  • 22. Coming up Next MIPS Assembly Language. C u ……. Take Care,,,