Top Banner
CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set
22

CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

Dec 20, 2015

Download

Documents

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: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 1

Instruction Set Architectures

• Classification

• Addressing Modes

• Types of Instructions

• Encoding Instructions

• MIPS64 Instruction Set

Page 2: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 2

ISA Classification (Fig. 2.1)

Page 3: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 3

Addressing Modes

• There are a variety of ways a machine instruction can specify an address in memory.

• Effective address - the actual address used to access memory. May not be the address that appears in the instruction but is computed from the instruction address

• Impacts of having a variety of addr. modes:– can significantly reduce number of instructions needed

– can increase average CPI

– more complexity for hardware design and implementation

Page 4: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 4

Usage of memory addressing modes (Fig. 2.7)

Page 5: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 5

Displacement addressing

Add R4, 100(R1)

Add R4 R1 100

??? bits for this field of the instruction

Useful for accessing nearby data

How large should the displacement field be?

n bits ==> 0 to 2^n if all positive

==> 0 to 2^(n-1) if both positive and negative

because one bit is used for the sign

Page 6: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 6

Displacements used in benchmarks (Fig. 2.8)

• x axis gives number of bits

• data is from a machine with max. 16 bit displacement

Page 7: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 7

Immediate addressing

ADDI R1,R2, #2

ADDI R1 R2 2

??? bits for the immediate field

Useful for many instructions that need a small constant

How large should the immediate field be?

n bits ==> 0 to 2^n if all positive

==> 0 to 2^(n-1) if both positive and negative

because one bit is used for the sign

Page 8: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 8

Immediate data usage in benchmarks (Fig. 2.9)

• Heavy use of immediate data

Page 9: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 9

Immediate data usage in benchmarks

• Data is from a machine limited to 16 bit immediates

Page 10: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 10

Types of instructions (by operation)

• arithmetic/logical

• data movement

• control

• floating point

• decimal

• string

• graphics

Page 11: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 11

Top ten 80x86 instructions

Rank12345678910

InstructionLoadCond. BranchCompareStoreAddAndSubMove R to RCallReturn

Frequency22%20%16%12% 8% 6% 5% 4% 1% 1%

Page 12: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 12

Control flow instructions

• conditional branches BEQZ HOME

• unconditional branches or jumps JMP ROPE

• procedure call

• procedure return

Target of the branch can be specified as

• explicit direct JMP ROPE

• explicit indirect JMP (R1)

• displacement JMP 100(R2)

• PC relative JMP 100(PC)

Page 13: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 13

Use of branches in benchmarks (Fig. 2.19)

Page 14: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 14

Displacements used in branches (Fig. 2.20)

• 4-8 bits captures most of the displacements

Page 15: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 15

Instruction encoding issues• total size(s) of instructions (halfword, word,

doubleword)

• number of fields, number of operands

• number of bits for each field

Dependent on:number of registerstypes of instructions (operations)addressing modes etc.

Page 16: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 16

Basic varieties of instruction encoding:variable, fixed, hybrid (Fig. 2.23)

Page 17: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 17

MIPS64 Architecture

Registers

• 32 64-bit general purpose registers

R0, R1, R2 ….. R31

• 32 64-bit floating points registers

F0, F1, … F31

Page 18: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 18

MIPS64 Architecture (cont)

Data types

• Integer data types

byte (8 bits), halfword (16 bits),

word (32 bits), doubleword (64 bits)

• Floating point data types

single precision (32 bits)

double precision (64 bits)

Page 19: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 19

MIPS64 Architecture (cont)

Addressing modes (looks like four, only two)

• Immediate - 16 bits

ADD R1, R2,#3• Displacement - 16 bits

LW R1,30(R2)• Registered deferred/indirect - use 0 displacement

LW R1,0(R2)• Absolute - use R0 as the base, R0 = 0

LW R1,508(R0)

Page 20: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 20

MIPS64 Instruction Format (Fig. 2.27)

Page 21: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 21

Deciphering MIPS64 notation

LD R1,30(R2) Regs[R1] <--64 Mem[30 + Regs[R2]]

LH R1,40(R3) Regs[R1] <--64

(Mem[40 + Regs[R3]0)**48 ##

Mem[40 + Regs[R3]] ##

Mem[41 + Regs[R3]]

Load halfword Duplicate the sign bit, concatenate

with the byte at Mem[40 + Regs[R3]] and

concatenate with the byte at

Mem[41 + Regs[R3]]. This makes a total of 64 bits.

Page 22: CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.

CIS429/529 ISA - 22

Deciphering MIPS64 notation

JAL NAME Regs[R31] <-- PC + 4 save return address

PC 36-63 <-- NAME

((PC + 4) - 2 **27 <= NAME <

((PC + 4) + 2**27 ) Check bounds on value of NAME

since this uses PC relative addressing

Used for subroutine calls

25

25