CSCE 611: Introduction to MIPS Instruction Set Architecture - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

CSCE 611: Introduction to MIPS Instruction Set Architecture

Description:

... instruction behavior, load-store, fixed instruction widths, ... MIPS addresses load/store locations. base register 16-bit signed offset (byte addressed) ... – PowerPoint PPT presentation

Number of Views:529
Avg rating:3.0/5.0
Slides: 16
Provided by: jasond9
Category:

less

Transcript and Presenter's Notes

Title: CSCE 611: Introduction to MIPS Instruction Set Architecture


1
CSCE 611Introduction to MIPS Instruction Set
Architecture
  • Instructor Jason D. Bakos

2
Instruction Set Architecture
  • Instruction Set Architecture (ISA)
  • Usually defines a family of microprocessors
  • Examples Intel x86 (IA32), Sun Sparc, DEC
    Alpha, IBM/360, IBM PowerPC, M68K, DEC VAX
  • Formally, it defines the interface between a user
    and a microprocessor
  • ISA includes
  • Instruction set
  • What each instruction does
  • Rules for using instructions
  • Mnemonics, functionality, addressing modes
  • Instruction encoding
  • ISA is a form of abstraction
  • Low-level details of microprocessor
    (microarchitecture) are invisible to user

3
Instruction Set Architecture
  • ISA ltgt abstraction is ideal, but a misnomer
  • Many processor implementation details are
    revealed through ISA
  • Example
  • Motorola 6800 / Intel 8085 (1970s)
  • 1-address architecture ADDA ltmem_addrgt
  • (A) (A) (addr)
  • Intel x86 / IBM 360 (1980s)
  • 2-address architecture ADD EAX, EBX or- ADD
    EAX,ltmem_addrgt
  • (A) (A) (B)
  • MIPS (1990s)
  • 3-address architecture ADD 2, 3, 4
  • (2) (3) (4)
  • Advancements in fabrication technology
  • Interconnects metal layers

4
MIPS Architecture
  • Design philosophies for ISAs RISC vs. CISC
  • Execution time
  • instructions per program cycles per instruction
    seconds per cycle
  • MIPS is the first implementation of a RISC
    architecture
  • Simple instruction behavior, load-store, fixed
    instruction widths, balanced execution
    (parallelizable)
  • MIPS R2000 ISA
  • Designed for use with high-level programming
    languages
  • small set of instructions and addressing modes,
    easy for compilers
  • Minimize/balance amount of work (computation and
    data flow) per instruction
  • allows for parallel execution
  • Load-store machine
  • large register set, minimize main memory access
  • Fixed instruction width (32-bits), small set of
    uniform instruction encodings
  • minimize control complexity, allow for more
    registers

5
MIPS Architecture
  • MIPS processors used in
  • SGI machines
  • Series2 TiVo
  • Windows CE devices
  • Cisco/Linksys routers
  • Nintendo 64
  • Sony Playstation 1/2/PSP
  • Cable boxes
  • Competes against ARM for cell phones
  • John L. Hennessy (Stanford, 1981)
  • Deep instruction pipelines with interlocks
  • 1984 MIPS Computer Systems
  • R2000 (1985), R3000 (1988), R4000 (64-bit, 1991)
  • SGI acquisition (1992) gt MIPS Technologies
  • Transition to licensed IP MIPS32 and MIPS64
    (1999)
  • Heavyweight embedded processor

6
MIPS Microarchitecture
7
MIPS Instructions
  • MIPS instructions fall into 5 classes
  • Arithmetic/logical/shift/comparison
  • Control instructions (branch and jump)
  • Load/store
  • Other (exception, register movement to/from GP
    registers, etc.)
  • Three instruction encoding formats
  • R-type (6-bit opcode, 5-bit rs, 5-bit rt, 5-bit
    rd, 5-bit shamt, 6-bit function code)
  • I-type (6-bit opcode, 5-bit rs, 5-bit rt, 16-bit
    immediate)
  • J-type (6-bit opcode, 26-bit pseudo-direct
    address)

8
MIPS Instructions
  • Arithmetic R-type add, addu, sub, subu
  • Arithmetic I-type addi, addiu
  • Logical R-type and, or, nor, xor
  • Logical I-type andi, ori, xori
  • Shift R-type sll, sllv, srl, srlv, sra, srav
  • Load/Store I-type lui, lw, lh, lhu, lb, lbu,
    sw, sh, sb
  • Branch I-type
  • beq, bne, bgez, bgezal, bgtz, blez, blezal, bltz
  • Jump J-type j, jal
  • Jump R-type jr, jalr
  • OS support syscall
  • Multiply/divide mult, multu, div, divu
  • result held in 2 special registers

9
MIPS Addressing Modes
  • MIPS addresses register operands using 5-bit
    field
  • Example ADD 2, 3, 4
  • MIPS addresses branch targets as signed
    instruction offset
  • relative to next instruction (PC relative)
  • in units of instructions (words)
  • held in 16-bit offset in I-type
  • Example BEQ 2, 3, 12
  • Immediate addressing
  • Operand is help as constant (literal) in
    instruction word
  • Example ADDI 2, 3, 64

10
MIPS Addressing Modes (cont)
  • MIPS addresses jump targets as register content
    or 26-bit pseudo-direct address
  • Example JR 31, J 128
  • MIPS addresses load/store locations
  • base register 16-bit signed offset (byte
    addressed)
  • Example LW 2, 128(3)
  • 16-bit direct address (base register is 0)
  • Example LW 2, 4092(0)
  • indirect (offset is 0)
  • Example LW 2, 0(4)

11
Example Instructions
  • ADD 2, 3, 4
  • R-type A/L/S/C instruction
  • Opcode is 0s, rd2, rs3, rt4, func000010
  • 000000 00011 00100 00010 00000 000010
  • JALR 3
  • R-type jump instruction
  • Opcode is 0s, rs3, rt0, rd31 (by default),
    func001001
  • 000000 00011 00000 11111 00000 001001
  • ADDI 2, 3, 12
  • I-type A/L/S/C instruction
  • Opcode is 001000, rs3, rt2, imm12
  • 001000 00011 00010 0000000000001100

12
Example Instructions
  • BEQ 3, 4, 4
  • I-type conditional branch instruction
  • Opcode is 000100, rs00011, rt00100, imm4
    (skips next 4 instructions)
  • 000100 00011 00100 0000000000000100
  • SW 2, 128(3)
  • I-type memory address instruction
  • Opcode is 101011, rs00011, rt00010,
    imm0000000010000000
  • 101011 00011 00010 0000000010000000
  • J 128
  • J-type pseudodirect jump instruction
  • Opcode is 000010, 26-bit pseudodirect address is
    128/4 32
  • 000010 00000000000000000000100000

13
Pseudoinstructions
  • Some MIPS instructions dont have direct hardware
    implementations
  • Ex abs 2, 3
  • Resolved to
  • bgez 3, pos
  • sub 2, 0, 3
  • j out
  • pos add 2, 0, 3
  • out
  • Ex rol 2, 3, 4
  • Resolved to
  • addi 1, 0, 32
  • sub 1, 1, 4
  • srlv 1, 3, 1
  • sllv 2, 3, 4
  • or 2, 2, 1

14
MIPS Code Example
  • for (i0iltni) aibi10
  • xor 2,2,2 zero out index register (i)
  • lw 3,n load iteration limit
  • sll 3,3,2 multiply by 4 (words)
  • la 4,a get address of a (assume lt 216)
  • la 5,b get address of b (assume lt 216)
  • j test
  • loop add 6,5,2 compute address of bi
  • lw 7,0(6) load bi
  • addi 7,7,10 compute bibi10
  • add 6,4,2 compute address of ai
  • sw 7,0(6) store into ai
  • addi 2,2,4 increment i
  • test blt 2,3,loop loop if test succeeds

15
MIPS Instruction Set Architecture
  • 32 general purpose integer registers
  • Some have special purposes
  • These are the only registers the programmer can
    directly use
  • 0 gt constant 0
  • 1 gt at (reserved for assembler)
  • 2,3 gt v0,v1 (expression evaluation and
    results of a function)
  • 4-7 gt a0-a3 (arguments 1-4)
  • 8-15 gt t0-t7 (temporary values)
  • Used when evaluating expressions that contain
    more than two operands (partial solutions)
  • Not preserved across function calls
  • 16-23 gt s0-gts7 (for local variables,
    preserved across function calls)
  • 24, 25 gt t8, t9 (more temps)
  • 26,27 gt k0, k1 (reserved for OS kernel)
  • 28 gt gp (pointer to global area)
  • 29 gt sp (stack pointer)
  • 30 gt fp (frame pointer)
  • 31 gt ra (return address, for branch-and-links)
  • Program counter (PC) contains address of next
    instruction to be executed
Write a Comment
User Comments (0)
About PowerShow.com