Download document

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Instructions Addressing Modes
(Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design:
The Hardware/Software Interface, 3rd Ed., Morgan Kaufmann, 2007)
1
COURSE CONTENTS









Introduction
Instructions
Computer Arithmetic
Performance
Processor: Datapath
Processor: Control
Pipelining Techniques
Memory
Input/Output Devices
2
Overview of MIPS




Simple instructions all 32 bits wide
Very structured, no unnecessary baggage
Only three instruction formats
R
op
rs
rt
rd
I
op
rs
rt
16 bit address
J
op
shamt
funct
26 bit address
Addresses are not 32 bits
 How do we handle this with load and store instructions
3
Addresses in
Branches and Jumps

Instructions:
bne $t4,$t5,Label
beq $t4,$t5,Label
j Label

Next instruction is at Label if $t4≠$t5
Next instruction is at Label if $t4=$t5
Next instruction is at Label
Formats:
I
op
J
op
rs
rt
16 bit address
26 bit address
4
Addresses in Branches

Instructions:
bne $t4,$t5,Label
beq $t4,$t5,Label

Formats:
I


Next instruction is at Label if $t4≠$t5
Next instruction is at Label if $t4=$t5
op
rs
rt
16 bit address
Could specify a register (like lw and sw) and add it to address
 Use Instruction Address Register (PC = program counter)
 Most branches are local (principle of locality)
Jump instructions just use high order bits of PC
 Address boundaries of 256 MB
5
Addressing Modes

Register addressing


Base or displacement addressing


operand is a constant within instruction
e.g. 3rd operand in addi $s1, $s2, 10
PC-relative addressing


operand at memory location [register + constant (base)]
e.g. 2nd operand in lw $t0, 200($s1)
Immediate addressing


operand is in a register, e.g. add $s1, $s2, $s3
address = PC (+4) + constant in instruction (*4)
e.g. 3rd operand in bne $s0, $s1, Exit
Pseudodirect addressing

address = PC upper bits concatenated with 26-bit address in inst.
6
Addressing Modes
1. Immediateaddressing
op
rs
rt
Immediate
2. Register addressing
op
rs
rt
rd
...
funct
Registers
Register
3. Baseaddressing
op
rs
rt
Register
Memory
Address
+
Byte
Halfword
Word
7
Addressing Modes
4. PC-relativeaddressing
op
rs
rt
PC
5. Pseudodirect addressing
op
Address
PC
Memory
Address
+
Word
Memory
Word
8
Other Issues






MIPS assembler accepts this pseudoinstruction even though it is not
found in MIPS architecture:

move $t0, $t1 #$t0  $t1

it translates it to: add $t0, $zero, $t1
Other pseudoinstructions: mult, blt, bge, etc.
Assembler keeps track of addresses of labels in symbol table
Details of assembler, linker, & loader are given in Appendix A
Details of MIPS instruction set & architecture in Appendix A
% frequency of instruction execution
Instruction Class
Arithmetic
gcc frequency
48%
spice frequency
50%
Data Transfer
33%
41%
Conditional branch
17%
8%
Jump & proc. call
2%
1%
9
Instruction Set
Architecture Classes



Use of accumulator (a default register):

1 address instruction; e.g. add A: acc  acc + mem[A]

e.g. EDSAC, IBM 701, DEC PDP-8, MC 6800, Intel 8008
Use of stack:

0 address instruction;
e.g. add: top(stack)  top(stack) + next_top(stack)
Use of general purpose registers:

2 address instruction; e.g. add A, B: A  A + B

3 address instruction; e.g. add A,B,C: A  B + C

load/store (reg/reg): e.g. MIPS, Sun’s SPARC, MC PowerPC, DEC Alpha

memory/memory: e.g. DEC VAX

memory/register: e.g. DEC VAX, IBM 360, DEC PDP-11, MC 68000,
Intel 80386
10
RISC vs. CISC


RISC -- Reduced Instruction Set Computer -- philosophy (instruction sets
measured by how well compilers used them)

fixed instruction lengths

load/store instruction sets
 all operands of ALU instructions are in registers

limited addressing modes

limited operations

e.g. MIPS, Sun SPARC, HP PA-RISC, PowerPC (AIM), ARM, Renesas Tech.
SuperH (by Hitachi), ARM/Thumb, etc.
CISC – Complex Instruction Set Computer -- Implies

fewer instructions in the set

larger register file

longer programs

good for pipelining

simpler control
11
Chapter Summary







Instruction Type
Instruction Format
RISC Design Principles
Assembly vs. Machine Language
Addressing Modes
Classes of Instruction Set Architecture
RISC vs. CISC
12
Related documents