CPU
CPU
CPU
Central Processor
organization
INTRODUCTION
The CPU performs bulk of the processing
jobs.
Major components
Register Set
Stores temporary data during execution of instructions
Arithmetic and Logic Unit
Performs operations to execute instructions
Control Unit
Supervises the operation of the ALU and transfer of data
between register set and ALU
Components of CPU
REGISTER SET
CONTROL UNIT
R1 ← R2 + R3
MUX A selection (SELA): to place the content of R2 into bus A
MUX B selection (SELB): to place the content of R3 into bus B
ALU operation selection (OPR): to provide the arithmetic addition
(A + B)
Decoder destination selection (SELD): to transfer the
content of the output bus into R1
The four control selection variables are generated in the
control unit.
Example - contd.
FULL EMPTY
2
1
SP 0
DR
Push operation
PUSH SP ← SP + 1 increment stack pointer
M [SP] ← DR write item on top of the
stack
If (SP = max) then (FULL ← 1)
check if stack is full
EMPTY ← 0 mark the stack not
empty.
Pop Operation
POP DR ←M[SP] read item from the top of
stack
SP ←SP –1 decrement SP
If (SP = 0) then (EMPTY ←1)
check if stack is empty
FULL ← 0 mark the stack not full.
Memory Stack
Implemented in a random-access
memory attached to a CPU.
A portion of memory is assigned to a
stack and a processor register is used
as the stack pointer.
3 segments r used in memory
Program counter, address register,
stack pointer
Computer memory with program, data
and stack
PC 1000
Program
AR 2000
Data
3000
DR Stack
SP 3999
4000
4001
Push and Pop Operations
Push : SP ←SP-1
M[SP] ←DR
Stack pointer is decremented so that it points at the
address of the next word.
Pop : DR ←M[SP]
SP ←SP +1
The top item is read from the stack into a data
register.
The stack pointer is then incremented to point at a
next item.
Instruction Formats
The most common fields found in
instruction format are:-
An operation code field that specified the
operation to be performed
An address field that designates a memory
address or a processor registers.
A mode field that specifies the way the
operand or the effective address is
determined.
Instruction formats
The operation code field of an instruction
format is a group of bits that define various
processor operations.
The address field is either a memory address
or a register address.
There may be varying number of address
fields depending upon the internal
organization of the CPU registers.
Types of Instruction format
1. Four address instruction
2. Three address instruction
3. Two address instruction
4. One address instruction
Four address Instruction
The instruction formats where the number of
operands in memory, the address where
results r stored and also the address, where
the next instruction to be carried out is
stored.
eg: ADD P Q R S where
P&Q address of the operand
R address of memory (storage)
s next instruction.
Three address instruction
Address field to specify either processor register
or a memory operand.
eg: ADD R1,R2,R3 implies R1←R2+R3.
general format:
dest←[src1]op[scr2]
dest = destination
scrc1& scr2= source operand
Op= opcode field
Evaluate X = (A + B) * (C + D)
Three Address Instructions
ADD R1, A, B ; R1 ←M [A] + M [B]
ADD R2, C, D ; R2 ← M [C] + M [B]
MUL X, R1, R2 ; M [X] ← R1 * R2
Advantage: shorter programs
Disadvantage : too many bits required to
represent three addresses
Two address instruction
1. Two address are commonly used in
commercial instruction.
2. The first operand listed in the
instruction is assumed to both source
and destination.
ADD R1 R2 R1←R1+R2
general format:
dest←[dest] op[scr]
Evaluate X = (A + B) * (C + D)
Two Address Instructions
MOV R1, A ; R1 ← M [A]
ADD R1, B ; R1 ← R1 + M [B]
MOV R2, C ; R2 ← M [C]
ADD R2, D ; R2 ← R2 + M [D]
MUL R1, R2 ; R1 ← R1 * R2
MOV X1 R1 ; M [X] ← R1
One address instruction
The availability of an accumulator
register in a processor allows
intermediate results to be kept with out
unnecessary storing and retrieving
from the memory.
eg: ADD B AC←[AC]+B
General format: AC←[AC]OP[SCR]
Evaluate X = (A + B) * (C + D)
One address instructions : accumulator organization
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 [×]← AC
All operations are done between the AC register and a memory
operand. T is the address of a temporary memory location
required for storing the intermediate result.
Zero address instruction
A stack organise computer generally
uses the zero address instruction.
Evaluate X = (A + B) * (C + D)
Zero Address Instructions : stack organization
PUSH A ; TOS ← A
PUSH B ; TOS ← B
ADD ; TOS ←(A + B)
PUSH C ; TOS ← C
PUSH D ; TOS ← D
ADD ; TOS ← (C + D)
MUL ; TOS ← (C + D) * (A + B)
POP X ; M [X] ← TOS
Data transfer & manipulation
Most of the computer provide an extensive
set of instruction to give the user the
flexibility to carry out various computational
tasks.
Most common instruction can be classified
into the three categories
1. Data transfer instructions.
2. Data manipulation instructions.
3. Program control instructions.
Data transfer instructions
Data transfer instructions move data
from one place to another in the
computer, without changing the data
content.
The most common transfer are between
memory and processor register.
Instruction mnemonic
LOAD LD
STORE ST
MOVE MOV
EXCHANGE XCH
INPUT IN
OUTPUT OUT
PUSH PUSH
POP POP
DATA TRANSFER INSTRUCTIONS.