COA Ch05 (2)
COA Ch05 (2)
1
5.1 Instruction Formats
3
Cont….
• Most computers fall into one of the three types of CPU X = Operand Address
organizations:
1. Single Accumulator (AC) Organization, i.e. ADD X AC AC M [ X ]
2. General register Organization, ADD R1,R2,R3 R1 R2 R3
-Register organization show how registers are selected and how
data flow between register and ALU. A decoder is used to select a
particular register.
3. Stack Organization, i.e. : PUSH X TOS M [ X ] no address field if
the instruction is ADD/MUL
A stack cannot be accessed randomly.
In choosing one over the other, the tradeoffs are simplicity (and cost)
of hardware design with execution speed and ease of use.
4
Cont….
Stack Organization
Stack or LIFO(Last-In, First-Out)
• A storage device that stores information.
The item stored last is the first item retrieved = a stack of tray.
• Stack Pointer (SP)
The register that holds the address for the stack
SP always points at the top item in the stack
• Two Operations of a stack : Insertion and Deletion of
Items
PUSH : Push-Down = Insertion
POP : Pop-Up = Deletion
5
Cont….
Stack
1) Register Stack
a finite number of memory words or register(stand alone)
2) Memory Stack Address
PUSH
4
SP = 0, SP SP 1 : Increment SP SP C
B
3
2
EMTY = 1,
FULL = 0 M [ SP ] DR : Write to the stack Last Item
A 1
0
If ( SP 0) then ( FULL 1) : Check if stack is full
6
Cont….
• The first item is stored at address 1, and the last item is stored at
address 0 : Read item from the top of stack
DR M [ SP ] Address
POP : SP SP 1 : Decrement Stack Pointer
Memory unit
1000
PC
If ( SP 0) then ( EMTY 1) : Check if stack is empty Program
(instruc tions)
FULL 0 : Mark not full
2000
AR
Data
3000
PUSH SP SP 1 Stac k
M [ SP ] DR 3997
SP 3998
•The first item is stored at address 4000 3999
4000
SP SP 1 DR
7
Cont….
8
Cont….
4 5 5 30
3 3 12 12 12 12 42
3 4 * 5 6 * +
9
Cont….
PUSH B
TOS A
TOS B
ADD TOS ( A B )
PUSH C TOS C
TOS D
PUSH D
TOS (C D )
ADD TOS (C D ) ( A B )
M [ X ] TOS
MUL
10
POP X
Cont….
Stack-organized computer does not use an address field for the instructions
ADD, and MUL
PUSH, and POP instructions need an address field to specify the operand
Zero-Address : absence of address ( ADD, MUL )
• In a one-address ISA, like MARIE, the infix expression,
X = (A + B) ∗ (C + D) is:
LOAD A AC ← M [A]
ADD B AC ← AC + M [B]
STORE T M [T] ← AC
LOAD C AC ← M [C]
ADD D AC ← AC + M [D]
MUL T AC ← AC ∗ M [T]
STORE X M [X] ← AC
* All operations are done between the AC register and memory operand
11
Cont….
14
Cont….
15
5.2 Instruction types
Instructions fall into several broad categories that you
should be familiar with:
• Data movement (e.g. load, store, Push, Pop..)
• Arithmetic
• Boolean
• Bit manipulation - used for setting and resetting
individual bits within a given data word.
e.g. Shift left, shift right, rotate left, rotate right
• I/O- (The basic schemes for handling I/O are
programmed I/O, interrupt-driven I/O)
• Control instructions(e.g. SKIPCOND)
• Special purpose instructions(e.g flag control, and cache
management.) 16
5.3 Addressing Modes
17
Cont….
19
Cont….
20
Example: For the instruction shown, what value is loaded into
the accumulator for each addressing mode?
800
21
Example: For the instruction shown, what value is loaded into
the accumulator for each addressing mode?
800
900
22
Example: For the instruction shown, what value is loaded into
the accumulator for each addressing mode?
800
900
1000
23
Example: For the instruction shown, what value is loaded into
the accumulator for each addressing mode?
800
900
1000
700
24
Characteristics of RISC and CISC
• Complex Instruction Set Computer(CISC)
(e.g. Intel Architecture)
Major characteristics of a CISC architecture
A large number of instructions - typically from 100
to 250 instructions.
It is a CPU design plan based on single
commands, which are skilled in executing
multi-step operations.
CISC computers have small programs. It has a
huge number of compound instructions, which
takes a long time to perform.
It has a memory unit to implement complex 25
instructions.
Cont….