CH 05
CH 05
1
5.1 Instruction Formats
2
Cont….
3
Cont….
• Most computers fall into one of the three types of CPU X = Operand Address
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
• 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….
Implementation of Stack
1) Register Stack
a finite number of registers are used.
2) Memory Stack Address
PUSH
4
SP = 0, SP SP 1 : Increment SP SP C
B
3
2
EMTY = 0,
FULL = 1 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 * +
10
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
11
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
12
Cont….
15
Cont….
16
5.2 Instruction types
Instructions fall into several broad categories that you should
be familiar with:
• Data movement.
• Arithmetic.
• Boolean.
• Bit manipulation.(used for setting and resetting individual
bits within a given data word.
• 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.)
17
5.3 Addressing Modes
18
Cont….
21
Cont….
22
Cont….
• These are the values loaded into the accumulator for each
addressing mode.
23
Characteristics of RISC and CISC
• Complex Instruction Set Computer (CISC)
Major characteristics of a CISC architecture
A large number of instructions - typically from
100 to 250 instructions.
Some instructions that perform specialized tasks
and are used infrequently
A large variety of addressing modes-typically from
5 to 20 different modes
Variable-length instruction formats
Instructions that manipulate operands in memory
24
Cont….
25