Module 11
Module 11
Sequencing
“Must-Perform” Operations
Data transfers between the memory and the processor
registers
Arithmetic and logic operations on data
Program sequencing and control
I/O transfers
Register Transfer Notation
Identify
a location by a symbolic name standing for its
hardware binary address (LOC, R0,…)
Contents of a location are denoted by placing square
Two-Address Instructions
• ADD A,B
• MOVE B,C
One-Address Instructions
• LOAD A
• ADD B
• STORE C
Using Registers
Registers are faster
Shorter instructions
The number of registers is smaller (e.g. 32 registers need 5 bits)
Minimize the frequency with which data is moved back and
forth between the memory and processor registers.
Let Ri represents a general purpose register,
LOAD A,Ri
STORE Ri,A
ADD A,Ri
Only one memory address is specified in instruction, still may
1. LOAD A ; AC ← [A]
2. ADD B ; AC ← AC +
[B]
3. STORE T ; [T] ← AC
4. LOAD C ; AC ← [C]
5. ADD D ; AC ← AC +
[D]
6. MUL T ; AC ← AC
[T]
7. STORE X ; [X] ← AC
Instruction Execution and Straight-Line
Sequencing
Address Contents
i
Assumptions:
Begin execution here Move A,R0
i+4
3-instruction
program
- One memory operand
Add B,R0
segment per instruction
i+8 Move R0,C
- 32-bit word length
- Memory is byte
addressable
A - Full memory address
can be directly specified
in a single-word instruction
B Data for
the program
Two-phase procedure
-Instruction fetch
-Instruction execute
C
Page 43
•
•
•
i + 4n - 4 Add NUMn,R0
i + 4n Move R0,SUM
•
•
•
SUM
NUM1
NUM2
•
•
•
NUMn
Branching LOOP
Determine address of
"Next" number and add
Program "Next" number to R0
loop
Decrement R1
Branch>0 LOOP
Branch target
Move R0,SUM
Conditional branch
•
•
•
SUM
N n
NUM1
•
•
•
NUMn
Condition Codes
Condition code flags
Condition code register / status register
N (negative)
Z (zero)
V (overflow)
C (carry)
Different instructions affect different flags
Conditional Branch Instructions
Example: A: 11110000
A: 1 1 1 1 0 0 0 0 +(−B): 1 1 1 0 1 1 0 0
B: 0 0 0 1 0 1 0 0 11011100
C=1 Z=0
S=1
V=0
Status Bits
Cn-1
A B
Cn ALU
F
V Z S C
Fn-1
Zero Check