Top Banner
8/13/2019 04_MIPS_ISA http://slidepdf.com/reader/full/04mipsisa 1/25 MIPS Instruction Set Architecture  (Second Edition: Chapter 3 Fourth Edition: Chapter 2) from Dr. Andrea Di Blas’ notes
25

04_MIPS_ISA

Jun 04, 2018

Download

Documents

michiemar
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 1/25

MIPSInstruction Set

Architecture 

(Second Edition: Chapter 3Fourth Edition: Chapter 2)from Dr. Andrea Di Blas’ notes

Page 2: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 2/25

CMPE 110 – Spring 2011 – J. Ferguson 

Instruction Set Architectures•  What is the ISA

•  Types of ISA–  Accumulator Architecture

–  General Purpose Architecture

•  Memory Operands•  Register Operands (Load/Store)

•  MIPS ISA

4 - 2

Page 3: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 3/25

CMPE 110 – Spring 2011 – J. Ferguson 

Instruction Set Architecture•  Definition 1: The interface between a computer’s

software and its hardware.

•  Definition 2: A computer’s Assembly Language•  Advantage: Allows different computer types (with

the same ISA) to run identical software.

4 - 3

Page 4: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 4/25

CMPE 110 – Spring 2011 – J. Ferguson  5 - 4

ISA - Specifics

ISA is all of the programmer-visible  components andoperations of the computer.

–  memory organization

•  address space - how may locations can be addressed?

•  addressability - how many bits per location?–  register set

•  how many? what size? how are they used?–  instruction set

•  opcodes

• 

data types•  addressing modes

The ISA provides all the information needed for someone to write a program inmachine language (or translate from a high-level language to machine language).

Page 5: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 5/25

CMPE 110 – Spring 2011 – J. Ferguson 

Basic ISA Types – based onOperands

•  A, B, C are operands in A+B = C

•  Stack Architecture – no explicit operands

•  Accumulator Architecture – one explicit operand•  General Purpose Register Architectures: 3 explicit

operands–  Memory-Memory

–  Register-Memory

–  Register-Register

4 - 5

Page 6: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 6/25

CMPE 110 – Spring 2011 – J. Ferguson 

Stack Architecture

4 - 6

5

4

3

2 V3

1 V2

0 V1

A = B * (C + D * B)

1.  Push B2.  Push D3.  *4.  Push C

5. 

+6.  Push B7.  *8.  Pop A

SP

5

4 D

3 B

2 V3

1 V2

0 V1

0. 2.

5

4 C

3 DB

2 V3

1 V2

0 V1

4.

5

4 B

3 A

2 V3

1 V2

0 V1

8.

0 explicit operands. All operands on Stack.

Page 7: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 7/25

CMPE 110 – Spring 2011 – J. Ferguson 

Accumulator Architecture

4 - 7

One explicit operand per instruction. Other twoare (1 source, 1 destination) are in the Accumulator.

accumulator

ALU

ex operand

A = B * (C + D * B)

1.  Load B2.  Mult D3.  Add C4.  Mult B5.  Store A

Page 8: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 8/25

CMPE 110 – Spring 2011 – J. Ferguson 

GPR Architecture: Register-

Memory

4 - 8

Two Operands: a Register (for one source anddestination) and a memory location.

registers

ALU

A = B * (C + D * B)

1.  Load R0, B2.  Mult R0, D

3.  Add R0, C4.  Mult R0, B5.  Store R0, A

Memoryor registers

Page 9: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 9/25

CMPE 110 – Spring 2011 – J. Ferguson 

GPR Architecture: Memory-

Memory

4 - 9

ALU

A = B * (C + D * B)

1.  Mult R0, D, B2.  Add R0, R0, C

3.  Mult A, B, R0

Three Operands, each can be from a register orfrom memory.

Page 10: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 10/25

CMPE 110 – Spring 2011 – J. Ferguson 

GPR Architecture: Register –

Register (Load/Store)

4 - 10

Three Operands, each must be from a register.Load and Store to move data memory!"registers

ALU

A = B * (C + D * B)1.  Load R0, B2.  Load R1, D3.  Mult R2, R0, R1

4.  Load R3, C5.  Add R3, R3, R26.  Mult R4, R0, R07.  Store R4, A registers

Page 11: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 11/25

CMPE 110 – Spring 2011 – J. Ferguson 

Comparison of GPR Arch.•  Memory-Memory (DEC VAX)

–  Fewest instructions

–  Most memory accesses (up to 3 data accesses perinstruction)

•  Register-Memory (PDP-11, IBM 360, i80x86)–  1-2 data memory accesses on average

–  Smaller code size

–  Variable instruction length

•  Load/Store Register-Register

–  Fewest data memory accesses–  Simple code generation

–  Simpler to Pipeline!

4 - 11

Page 12: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 12/25

CMPE 110 – Spring 2011 – J. Ferguson 

Advantages for each ISA type•  Stack Arch.

–  No need to have explicit operands. (ALU instructionssimpler)

•  Memory-Memory GPU Arch.–  Very flexible, fewer instructions to execute program.

•  Accumulator and Reg-Mem GPU Arch.–  Only one explicit operand. Fewer data memory accesses

•  Load/Store (Reg-Reg GPU) Arch.–  Flexible once in registers, fewer data memory accesses,

designed for pipelining.

4 - 12

Page 13: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 13/25

CMPE 110 – Spring 2011 – J. Ferguson 

RISC type of Register-Register

GPUReduced Instruction Set Computer (RISC) research

•  Many complex instructions were seldom, if ever,

used in compiled code•  In some cases more, simpler instructions were

faster than fewer, complicated instructions.

•  Microinstruction pipelining techniques could beapplied to processors if instructions were changed.

4 - 13

Page 14: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 14/25

CMPE 110 – Spring 2011 – J. Ferguson 

RISC design principles•  Make the common case fast.

•  Smaller is faster

–  Design easier to optimize–  Distance increases propagation delay.

•  If it is expensive to implement in hardware, maybeit should be implemented in software instead.

•  Simplicity favors regularity

4 - 14

Page 15: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 15/25

CMPE 110 – Spring 2011 – J. Ferguson 

RISC architecture characteristics•  Fixed size instructions (for easy pipelining and

decoding)

•  Memory transactions allowed only in separate Loadand Store instructions (for easier pipelining)

•  Few and simple addressing modes

•  Large orthogonal register sets (no/few specialregisters)

•  No/few complicated instructions

4 - 15

Page 16: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 16/25

CMPE 110 – Spring 2011 – J. Ferguson 

Microprocessor without

Interlocked Pipeline Stages(MIPS)

•  Company founded by Hennessey and others in 1984

to build a commercial RISC processor.•  Bought by Silicon Graphics and is now MIPS

Technologies

•  Processors used by Sony, Nintendo, etc.

4 - 16

Page 17: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 17/25

CMPE 110 – Spring 2011 – J. Ferguson 

Units of Data

•  BIT: one binary digit (0 or 1)

•  BYTE: an 8-bit binary string

•  NIBBLE or NYBBLE: a 4-bit binary string

•  WORD: a string of n bits, where n is ISA dependent•  DOUBLEWORD: an ordered set of 2 words

•  QUADWORD: an ordered set of 4 words

4 - 17

Page 18: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 18/25

CMPE 110 – Spring 2011 – J. Ferguson 

Our MIPS

•  32 bit architecture: word length, address length.

•  32 General Purpose Registers: very generous in1984.

• 

Instruction set function:–  Computational (uses ALU): and, or, add, etc.

–  Memory Access: lw, lb, sw, sb–  Program flow

•  Instruction set format:

–  R-type–  I-type

–  J-type

4 - 18

Page 19: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 19/25

CMPE 110 – Spring 2011 – J. Ferguson 

R-type (register) Format

•  op (opcode): basic operation of instruction – also determinesformat – op = 0 for all R-type instructions

•  rs: first source operand

•  rt: second source operand

•  rd: destination

•  shamt: shift amount•  funct: function variant (e.g. add and sub same op, but add has

funct=32 and sub has funct=34

4 - 19

op rs rt rd shamt funct

31 26 25 21 20 16 15 11 10 6 5 0

6 bits 5 bits 6 bits5 bits5 bits5 bits

Page 20: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 20/25

CMPE 110 – Spring 2011 – J. Ferguson 

R-type Instructions

4 - 20

examples:add Rd,Rs,Rt   ; Rd = Rs + Rtsub Rd,Rs,Rtor Rd,Rs,Rt

MEANING  comp  $17  $18  $3  -  add 

Decimal 0 17 18 3 0 32Binary 00 0000 1 0001 1 0010 0 0011 0 0000 10 0000

Hex 00 11 12 03 00 20

add $3,$17,$3

Page 21: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 21/25

CMPE 110 – Spring 2011 – J. Ferguson 

I-type (immediate) Format

•  op (opcode): basic operation of instruction (e.g. lw opcode = 35,addi opcode = 8, beq opcode = 4)

•  rs/base: register containing source operand or base

•  rt: destination register for addi or loads, source register forstores, second operand for beq 

•  offset/immediate: immediate field in computation instructions,byte  address offset (wrt rs) in load/store instructions, word  address offset (wrt PC) in branch instructions – always signextended to a 32-bit value.

4 - 21

op rs rt offset/immediate

31 26 25 21 20 16 15 0

6 bits 5 bits 16 bits5 bits

Page 22: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 22/25

CMPE 110 – Spring 2011 – J. Ferguson 

I-type Instructions

4 - 22

examples:addi Rd,Rs,N   ; Rd = Rs + SignExt(N)ori Rd,Rs,N ; Rd = Rs | SignExt(N)beq Rs,Rt,Label ;If(Rs == Rt) goto Label

lw Rt,N(Rs) ;Rt = Mem[Rs + SignExt(N)]sw Rt,N(Rs) ;Mem[Rs + SignExt(N)] = Rt

MEANING  addi  $22  $8  -16 Decimal 9 22 8 -16

Binary 00 1001 1 0110 0 1000 1111 1111 1111 0000

Hex 09 16 08 FFF0

addi $8,$22,-16

Page 23: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 23/25

CMPE 110 – Spring 2011 – J. Ferguson 

J-type (jump) Format

•  op (opcode): basic operation of instruction (e.g. j opcode = 2)

•  target: target word  address of the instruction to jump to.

4 - 23

op target

31 26 25 06 bits 26 bits

Page 24: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 24/25

CMPE 110 – Spring 2011 – J. Ferguson 

J-type Instructions

4 - 24

examples:j Label   ; goto LabelJal Label ; $31 = PC+4, goto Label

MEANING   j  Label 

Decimal 2

Binary 00 0010 (part of) Label’s address

Hex 2

Page 25: 04_MIPS_ISA

8/13/2019 04_MIPS_ISA

http://slidepdf.com/reader/full/04mipsisa 25/25

CMPE 110 – Spring 2011 – J. Ferguson 

R-, I, and J-type format

comparison

4 - 25

op rs rt rd shamt funct

31 26 25 21 20 16 15 11 10 6 5 0

R-type:

op rs rt offset/immediate

31 26 25 21 20 16 15 0

op target

31 26 25 0

I-type:

J-type: