Pertemuan 15 Instruction Set Matakuliah : H0344/Organisasi dan Arsitektur Komputer

advertisement
Matakuliah
Tahun
Versi
: H0344/Organisasi dan Arsitektur Komputer
: 2005
: 1/1
Pertemuan 15
Instruction Set
1
Learning Outcomes
Pada akhir pertemuan ini, diharapkan mahasiswa
akan mampu :
• Menghubungkan instructions set untuk
merealisasikan suatu proses sederhana
2
Outline Materi
•
•
•
•
•
•
Machine Instruction Characteristics
Types of Operands
Types of Operation
Assembly Language
Addressing
Instruction Formats
3
Machine instruction characteristics
Instruction Cycle State Diagram
Instruction
fetch
Operand
fetch
Operand
store
Multiple
operands
Instruction
address
calculation
Instruction
operation
decoding
Instruction complete,
fetch next instruction
Operand
address
calculation
Multiple
result
Data
operation
Operand
address
calculation
Return for string
or vector data
4
Machine instruction characteristics
Elements of a machine instruction
1. Operation code
2. Source operand reference
3. Result operand reference
4. Next instruction reference
Source and result operands can be in one of three areas:
1. Main or virtual memory
2. CPU register
3. I/O device
5
Machine instruction characteristics
Instruction representation
• mnemonics
A simple instruction format
4 bits
6 bits
6 bits
Opcode
Operand reference
Operand reference
16 bits
6
Machine instruction characteristics
Instruction types
The operation
X=X+Y
X = 513
Y = 514
could be accomplished with three instructions:
1. Load a register with the contents of memory location 513.
2. Add the contents of memory location 514 to the register.
3. Store the content of the register in memory location 513.
7
Machine instruction characteristics
Instruction types
We can categorize instruction types as follows:
1. Data processing
2. Data storage
3. Data movement
4. Control
8
Machine instruction characteristics
Number of address
One of the traditional ways of describing processor
architecture is in term of the number of address contained
in each instruction.
Instruction
Comment
Instruction
Comment
Instruction
Comment
Sub Y, A, B
YA-B
Move Y, A
YA
Load D
Ac  D
Mpy T, D, E
TDxE
Sub Y, B
YY-B
Mpy E
Ac  Ac x E
Add T, T, C
TT+E
Move T, D
TD
Add C
Ac  Ac + E
Div Y, Y, T
YY/T
Mpy T, E
TE
Stor Y
Y  Ac
Add T, C
TC
Load A
Ac  A
Div Y, T
YY/T
Sub B
Ac  Ac - B
Div Y
Ac  Ac / Y
Stor Y
Y  Ac
(a) Three address instructions
(b) Two address instructions
(c) One address instructions
9
Machine instruction characteristics
Instruction set design
The most important of these fundamental design issues
include the following:
1. Operation repertoire
2. Data types
3. Instruction format
4. Register
5. Addressing
10
Types of operands
The most important general categories of data are:
1. Address
2. Numbers
3. Characters
4. Logical data
11
Types of operations
A useful and typical categories of operations is the
following:
1. Data transfer
2. Arithmetic
3. Logical
4. Conversion
5. I/O
6. System control
7. Transfer of control
12
Types of operations
Transfer of control
Branch instructions
Memory
address
200
201
202
203
Instruction
Sub X, Y
Brz 211
210
211
Br 202
225
Bre R1, R2, 235
235
13
Types of operations
Transfer of control
Skip instruction
Memory
address
Instruction
301
203
202
210
Isz R1
Br 301
14
Types of operations
Transfer of control
Procedure call instruction
4000
Main
4100
program 4101
Call Proc1
4500
4600
Procedure 4601
Proc1 4650
4651
4101
o
(c) Initial
Call Proc2
(d) After
Return
4101
o
o
Call Proc2
4601
4101
o
(a) Initial stack (b) After
content
Call Proc1
Call Proc2
Return
4800
Procedure
Proc2
Return
4651
4101
o
4101
o
o
(e) After
Call Proc2
(d) After
Return
(d) After
Return
15
Types of operations
Transfer of control
Stock Frame Growth Using Sample Procedures P and Q
y2
Stack pointer
y1
Q:
Old frame pointer
Frame pointer
Return point
x2
Stack pointer
x2
x1
Old frame pointer
P:
Return point
(a) P is active
x1
Frame pointer
Old frame pointer
P:
Return point
(b) P has called Q
16
Assembly language
Problem:
N=I+J+K
The program consists of four instructions:
1. Load the contents of location 201 (I) into the Ac.
2. Add the contents of location 202 (J) into the Ac.
3. Add the contents of location 203 (K) into the Ac.
4. Store the contents of the Ac into location 204 (N).
17
Assembly language
Computation of the Formula N = I + J + K
Address
Contents
Address
Instructions
101
102
103
104
0010
0001
0001
0011
0010
0010
0010
0010
0000
0000
0000
0000
0001
0010
0011
0100
101
102
103
104
Lda
Add
Add
Sta
201
202
203
204
201
202
203
204
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0000
0010
0011
0100
0000
201
202
203
204
Dat
Dat
Dat
Dat
2
3
4
0
(a) Binary program
(b) Symbolic program
Address
Contents
Label
101
102
103
104
2201
1202
1203
3204
Formul
Lda
Add
Add
Sta
I
J
K
L
201
202
203
204
0002
0003
0004
0000
I
J
K
N
Dat
Dat
Dat
Dat
2
3
4
0
(c) Hexadecimal program
Instructions
(d) Assembly program
18
Download