Basic I/O operations , stack and Encoding Machine instructions
COMPUTER ORGANIZATION
Prepared by
Mr. SUTHAGAR S/ AP/ ECE
Mr. SUTHAGAR S / AP/ ECE
Basic Input/Output Operations
Mr. SUTHAGAR S / AP/ ECE
Input/Output
Mr. SUTHAGAR S / AP/ ECE
Program-Controlled I/O Example
Mr. SUTHAGAR S / AP/ ECE
Program-Controlled I/O Example
- Registers
- Device interface
Mr. SUTHAGAR S / AP/ ECE
Program-Controlled I/O Example
Mr. SUTHAGAR S / AP/ ECE
Program-Controlled I/O Example
Mr. SUTHAGAR S / AP/ ECE
Program-Controlled I/O Example
Mr. SUTHAGAR S / AP/ ECE
Stacks
Mr. SUTHAGAR S / AP/ ECE
Home Work
Mr. SUTHAGAR S / AP/ ECE
Stack Organization
Last In First Out
SP
Stack Bottom
Current�Top of Stack�TOS
0
1
2
3
4
7
8
9
10
5
6
Stack
0 0 5 5
0 0 0 8
0 0 2 5
0 0 1 5
0 1 2 3
FULL
EMPTY
Mr. SUTHAGAR S / AP/ ECE
Stack Organization
SP ← SP – 1
M[SP] ← DR
If (SP = 0) then (FULL ← 1)
EMPTY ← 0
SP
Stack Bottom
Current�Top of Stack�TOS
0
1
2
3
4
7
8
9
10
5
6
Stack
0 0 5 5
0 0 0 8
0 0 2 5
0 0 1 5
0 1 2 3
FULL
EMPTY
1 6 9 0
1 6 9 0
Current�Top of Stack�TOS
Mr. SUTHAGAR S / AP/ ECE
Stack Organization
DR ← M[SP]
SP ← SP + 1
If (SP = 11) then (EMPTY ← 1)
FULL ← 0
SP
Stack Bottom
Current�Top of Stack�TOS
0
1
2
3
4
7
8
9
10
5
6
Stack
0 0 5 5
0 0 0 8
0 0 2 5
0 0 1 5
0 1 2 3
FULL
EMPTY
1 6 9 0
1 6 9 0
Current�Top of Stack�TOS
Mr. SUTHAGAR S / AP/ ECE
Stack Organization
SP ← SP – 1
M[SP] ← DR
DR ← M[SP]
SP ← SP + 1
0
1
2
102
202
201
200
100
101
PC
AR
SP
Mr. SUTHAGAR S / AP/ ECE
Additional Instructions
Mr. SUTHAGAR S / AP/ ECE
Logical Shifts
C
R0
0
before:
after:
0
1
0
0
0
1
1
1
.
.
.
1
1
0
0
1
1
1
0
0
0
(b) Logical shift r
ight
LShiftR #2,R0
(a) Logical shift left
LShiftL #2,R0
C
R0
0
before:
after:
0
1
0
0
0
1
1
1
.
.
.
1
1
1
1
0
.
.
.
0
0
1
0
1
.
.
.
Mr. SUTHAGAR S / AP/ ECE
Arithmetic Shifts
C
before:
after:
0
1
1
1
0
0
0
1
.
.
.
0
1
1
1
0
0
1
0
1
1
(c) Ar
ithmetic shift r
ight
AShiftR #2,R0
R0
.
.
.
Mr. SUTHAGAR S / AP/ ECE
Rotate
Figure 2.32. Rotate instructions.
C
R0
before:
after:
0
1
0
0
0
1
1
1
.
.
.
1
1
1
0
1
1
1
0
0
1
(c) Rotate r
ight without carr
y
RotateR #2,R0
(a) Rotate left without carr
y
RotateL #2,R0
C
R0
before:
after:
0
1
0
0
0
1
1
1
.
.
.
1
1
1
1
0
.
.
.
1
0
1
0
1
C
before:
after:
0
1
0
0
0
1
1
1
.
.
.
1
1
1
0
1
1
1
0
0
0
(d) Rotate r
ight with carr
y
RotateRC #2,R0
R0
.
.
.
.
.
.
(b) Rotate left with carr
y
RotateLC #2,R0
C
R0
before:
after:
0
1
0
0
0
1
1
1
.
.
.
1
1
1
1
0
.
.
.
0
0
1
0
1
Mr. SUTHAGAR S / AP/ ECE
Encoding of Machine Instructions
Mr. SUTHAGAR S / AP/ ECE
Encoding of Machine Instructions
OP code
Source
Dest
Other info
8
7
7
10
(a) One-word instruction
Mr. SUTHAGAR S / AP/ ECE
Encoding of Machine Instructions
(b) Two-word instruction
Memory address/Immediate operand
OP code
Source
Dest
Other info
Mr. SUTHAGAR S / AP/ ECE
Encoding of Machine Instructions
Mr. SUTHAGAR S / AP/ ECE
Encoding of Machine Instructions
Mr. SUTHAGAR S / AP/ ECE