faculty of computer science © 2006 cmput 229 the instruction set architecture registers, addressing...

20
Faculty of Computer Science CMPUT 229 © 2006 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

Post on 15-Jan-2016

227 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

Faculty of Computer Science

CMPUT 229 © 2006

The Instruction Set Architecture

Registers, Addressing Modes, and Instructions

Page 2: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Machine Levels and Virtual Architectures

Clements, pp. 205

COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED

Page 3: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Memory, Processor and Program

Clements, pp. 207

COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED

Page 4: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Random-Access Memory System

Clements, pp. 208

COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED

Page 5: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

The 68K Register Set

Clements, pp. 211

COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED

Page 6: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Execution of a Three-Address Instruction

Clements, pp. 212

COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED

Page 7: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Register Transfer Logic (RTL) Notation

Clements, pp. 209

Processor

Family

Instruction

MnemonicRTL definition

68K MOVE DO, (A5) [A5] [D0]

ARM ADD R1, R2, R3 [R1] [R2] + [R3]

IA32 MOV ah, 6 [ah] 6

PowerPC li r25, 10 [r25] 10

MIPS add $t0, $s1, $s2 [t0] [s1] + [s2]

Page 8: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Instruction Operands and Destination

Three-Address Instruction:

ADD P, Q, R

P Q R

+

Two-Address Instruction:

ADD P, Q

P Q

+

One-Address Instruction:

ADD P

P Accumulator

+

Zero-Address Instruction:

ADD

Stack

+

Top

Clements, pp. 213

Page 9: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Some 68K 2-address instructions (and one 1-address)

Instruction RTL definitionADD D4, D1 [D1] [D1] + [D4]

SUB P, D6 [D6] [D6] - [P]

AND D7, P [P] [P] ^ [D7]

MOVE D3, D1 [D1] [D3]

MOVE X, D1 [D1] X

MOVE D2, Y [Y] [D2]

MOVE X,Z [Z] [X]

CLR D0 [D0] 0

Clements, pp. 213

Page 10: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Example: A program to add

MOVE.L #Table, A0 ; A0 points to the table (A0 has the address of the Table)

CLR.B D0 ; Use DO to hold the sum - clear it first

MOVE.B #20, D1 ; There are 20 numbers to add

Next ADD.B (A0), D0 ; Add a number to the total in D0

ADD.L #1, A0 ; Point to the next number in the list

SUB.B #1, D1 ; Decrement the counter

BNE Next ; Repeat until all added in

Clements, pp. 216

Page 11: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Example: A program to add

MOVE.L #Table, A0 ; A0 points to the table (A0 has the address of the Table)

CLR.B D0 ; Use DO to hold the sum - clear it first

MOVE.B #20, D1 ; There are 20 numbers to add

Next ADD.B (A0), D0 ; Add a number to the total in D0

ADD.L #1, A0 ; Point to the next number in the list

SUB.B #1, D1 ; Decrement the counter

BNE Next ; Repeat until all added in

Clements, pp. 216

Must initialize registers

and memory locations.

Page 12: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Example: A program to add

MOVE.L #Table, A0 ; A0 points to the table (A0 has the address of the Table)

CLR.B D0 ; Use DO to hold the sum - clear it first

MOVE.B #20, D1 ; There are 20 numbers to add

Next ADD.B (A0), D0 ; Add a number to the total in D0

ADD.L #1, A0 ; Point to the next number in the list

SUB.B #1, D1 ; Decrement the counter

BNE Next ; Repeat until all added in

Clements, pp. 216

Must initialize registers

and memory locations.

Suffixes indicate

Data size.

Page 13: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Example: A program to add

MOVE.L #Table, A0 ; A0 points to the table (A0 has the address of the Table)

CLR.B D0 ; Use DO to hold the sum - clear it first

MOVE.B #20, D1 ; There are 20 numbers to add

Next ADD.B (A0), D0 ; Add a number to the total in D0

ADD.L #1, A0 ; Point to the next number in the list

SUB.B #1, D1 ; Decrement the counter

BNE Next ; Repeat until all added in

Clements, pp. 216

Must initialize registers

and memory locations.

Suffixes indicate

Data size.

# indicates a literal value:

MOVE.B #20, D1

MOVE.B 20, D1

Page 14: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Example: A program to add

MOVE.L #Table, A0 ; A0 points to the table (A0 has the address of the Table)

CLR.B D0 ; Use DO to hold the sum - clear it first

MOVE.B #20, D1 ; There are 20 numbers to add

Next ADD.B (A0), D0 ; Add a number to the total in D0

ADD.L #1, A0 ; Point to the next number in the list

SUB.B #1, D1 ; Decrement the counter

BNE Next ; Repeat until all added in

Clements, pp. 216

Must initialize registers

and memory locations.

Suffixes indicate

Data size.

# indicates a literal value:

MOVE.B #20, D1

MOVE.B 20, D1

Loads the address of

Table, not the content of the

memory location at Table

Page 15: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Addressing modes

Clements, pp. 213

Page 16: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Addressing modes

Clements, pp. 213

Page 17: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Addressing modes

Clements, pp. 213

Page 18: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Some 68K Three-Address Instruction Formats

Clements, pp. 212

COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED

Page 19: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Overview of the 68K’s instructions

Instruction Categories:

– Data movement

– Arithmetic

– Logical

– Shift

– Bit

– Compare

– Control

Page 20: Faculty of Computer Science © 2006 CMPUT 229 The Instruction Set Architecture Registers, Addressing Modes, and Instructions

© 2006

Department of Computing Science

CMPUT 229

Status Register

Status bits:

Z-bit: Set if the result is zero

N-bit: Set if the result is negative

C-bit: Set if the result yields a carry-out

V-bit: Set if the result is out of range (overflow)