View
226
Download
0
Embed Size (px)
Citation preview
Faculty of Computer Science
CMPUT 229 © 2006
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
© 2006
Department of Computing Science
CMPUT 229
Memory, Processor and Program
Clements, pp. 207
COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED
© 2006
Department of Computing Science
CMPUT 229
Random-Access Memory System
Clements, pp. 208
COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED
© 2006
Department of Computing Science
CMPUT 229
The 68K Register Set
Clements, pp. 211
COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED
© 2006
Department of Computing Science
CMPUT 229
Execution of a Three-Address Instruction
Clements, pp. 212
COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED
© 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]
© 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
© 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
© 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
© 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.
© 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.
© 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
© 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
© 2006
Department of Computing Science
CMPUT 229
Addressing modes
Clements, pp. 213
© 2006
Department of Computing Science
CMPUT 229
Addressing modes
Clements, pp. 213
© 2006
Department of Computing Science
CMPUT 229
Addressing modes
Clements, pp. 213
© 2006
Department of Computing Science
CMPUT 229
Some 68K Three-Address Instruction Formats
Clements, pp. 212
COPYRIGHT 2006 OXFORD UNIVERSITY PRESS ALL RIGHTS RESERVED
© 2006
Department of Computing Science
CMPUT 229
Overview of the 68K’s instructions
Instruction Categories:
– Data movement
– Arithmetic
– Logical
– Shift
– Bit
– Compare
– Control
© 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)