Unit - 03 Central Processing Unit and Instruction Lecture-01
Central Processing Unit and Instruction
Micro operations :
Arithmetic micro-operations
Logic micro-operations
Shift micro-operations
Control Unit :
Hardwired Control Unit & Micro programmed Control Unit.
Components of CPU :
Buses, Registers, Flags, Stacks, I/O Ports
General Register Organization
Instruction formats & Types of Instructions.
Addressing modes
Data transfer and manipulation, Program control, Instruction cycle.
Unit - 03 Central Processing Unit and Instruction Lecture-01
Micro-Operations
The operations performed on data stored in registers are called micro-operations.
It is an atomic operation excuted on the information stored in one or more registers.
Example: Add, Sub, Increment/Decrement, Shift, count etc.
Types of Micro-Operations
The micro-operations in digital computers are of 4 types:
1. Register transfer micro-operations
2. Arithmetic micro-operations
3. Logic micro-operations
4. Shift micro-operations
Unit - 03 Central Processing Unit and Instruction Lecture-01
Arithmetic Micro-Operations
Some of the arithmetic micro-operations are addition, subtraction, increment and decrement.
Add Micro-Operation :
R3 → R1 + R2
Subtract Micro-Operation :
R3 → R1 + R2' + 1
Increment/Decrement Micro-Operation :
R1 → R1 + 1
R1 → R1 – 1
Unit - 03 Central Processing Unit and Instruction Lecture-01
Logic Micro-Operations
These are binary micro-operations performed on the bits stored in the registers.
These operations consider each bit separately and treat them as binary variables.
Example: AND , OR , NOT , X-OR etc.
Shift Micro-Operations
These are used for serial transfer of data.
That means we can shift the contents of the register to the left or right.
There are three types of shifts operation :
1. Logical Shift
2. Circular Shift
3. Arithmetic Shift
Unit - 03 Central Processing Unit and Instruction Lecture-01
Logical Shift
It transfers through the serial input.
The symbol "shl" is used for logical shift left and "shr" is used for logical shift right.
R1 ← shl R1
R1 ← shr R1
Circular Shift
This circulates or rotates the bits of register around the two ends without any loss of data or contents.
"cil" and "cir" is used for circular shift left and right respectively.
Arithmetic Shift
An arithmetic shift left multiplies a signed binary number by 2 and shift
right divides the number by 2.
Arithmetic shift micro-operation leaves the sign bit unchanged because the
signed number remains same when it is multiplied or divided by 2.
Unit - 03 Central Processing Unit and Instruction Lecture-02
Control Unit :
The Control Unit is the essential components of CPU.
It controls the various components like input & output devices, logic unit and memory.
The Control Unit is directs the component’s operations and tells them how to respond to the instruction
received from the program.
The Control Unit cannot store or process the data, it just directs the data signals.
Control unit directs working of all its components.
Unit - 03 Central Processing Unit and Instruction Lecture-02
Design of Control Unit
Control unit can be designed in two possible best ways.
1. Hardwired Control Unit
2. Micro-programmed Control Unit
Hardwired Control Unit
The design of the CU by using the hardware is called hardwired control unit.
The control logic is implemented with Gates, flip-flops and other digital circuits.
Hardware design is always faster.
It generates the fastest control signal.
Unit - 03 Central Processing Unit and Instruction Lecture-02
Micro-programmed Control Unit
In this control, logic is implemented with micro-programs.
It is a midway between hardware and software.
All possible control words are stored in a memory and fetched from memory based on the requirements.
Memory can be easily changed, we can change the value (0 or 1) in the control word, enabling and
disabling signals.
Unit - 03 Central Processing Unit and Instruction Lecture-02
Unit - 03 Central Processing Unit and Instruction Lecture-03
Components of the CPU :
Buses
Registers
Flags
Stacks
I/O Ports
Unit - 03 Central Processing Unit and Instruction Lecture-03
Buses
A bus is a collection of wires.
It is a link between the different components of the computer and processor.
They are used to send signals and data from the processor to different devices and
vice versa.
There are three types of buses :
1. Address bus which is used to send memory address from process to other
components.
2. Data bus, which is used to send actual data from the processor to the
components.
3. Control bus, used to send control signals from the processor to other
devices.
Unit - 03 Central Processing Unit and Instruction Lecture-03
Registers
It is a part of a CPU.
It is a very high speed semi conductor memory.
It is used to store the instructions temporarily.
These registers are also known as Processor registers as they play an important role in the processing of data.
It stores the memory address of the next instruction.
There are various kinds of registers that perform different functions.
MAR
MBR
MDR
PC
IR etc.
Unit - 03 Central Processing Unit and Instruction Lecture-03
Flags :
Flags are an important component of CPU.
It is used to store the current outcomes of calculations and actions performed by CPU.
Flags are a dynamic register that record the condition of a CPU calculation.
The status of each flag determines the CPU next action or decisions.
Some common flags in CPU are :
Sign flag
Zero flag
Parity flag
Carry flag
AC flag
Unit - 03 Central Processing Unit and Instruction Lecture-03
Stacks :
It is a data structure that stores information in such a manner that the item stored last is retrieved first.
It works on FILO or LIFO technique.
The register that holds the address for the stack is called a stack pointer (SP) because its value always points
at the top item in the stack.
The two operations of a stack are the insertion(push) and deletion(pop) of items.
Unit - 03 Central Processing Unit and Instruction Lecture-01
I/O Ports :
It acts as an interface between the computer and external devices like printers, modems, etc.
We can connect external devices to the computer with the help of ports and cables.
These are basically slots on motherboard where we connect external devices.
Mouse, keyboards, printers, speakers are some examples of external devices that connected to
the computer through ports.
Unit - 03 Central Processing Unit and Instruction Lecture-04
General Register Organization :
When we are using multiple general-purpose registers, instead of a single register, then this type of organization is
known as General register organization.
A register is a collection of flip-flops.
In the CPU, a register is a high-speed storage location.
Before processing, the data is always defined in a register.
The general-purpose registers are used to calculate data and store addresses.
Types of Registers
1. AC ( accumulator )
2. DR ( Data registers )
3. AR ( Address registers )
4. PC ( Program counter )
5. MDR ( Memory data registers )
6. IR ( index registers )
7. MBR ( Memory buffer registers )
Unit - 03 Central Processing Unit and Instruction Lecture-04
Accumulator :
An accumulator is a type of register included in a CPU.
It acts as a temporary storage location which holds an intermediate value in mathematical and logical calculations.
Intermediate results of an operation are progressively written to the accumulator, overwriting the previous value.
Example, in the operation "3 + 4 + 5," the accumulator would hold the value 3, then the value 7, then the value 12.
Program counter :
It is a register in the CPU containing the address of the next instruction to be executed.
When an instruction gets fetched, the program counter increases its stored value by 1.
After each instruction is fetched, the program counter points to the next instruction in
the sequence.
When the computer restarts or is reset, the program counter normally reverts to 0.
Unit - 03 Central Processing Unit and Instruction Lecture-05
Instruction format :
The instruction format is a way an instruction is written.
It describes the internal structures (layout) of the bits of an instruction.
Designing of an Instruction format is very complex.
An instruction format must include an addressing mode, opcode, and zero or more operands.
General structure of an Instruction format :
Unit - 03 Central Processing Unit and Instruction Lecture-05
Types of instruction format :
1) Zero Address Instruction Format
There is no address field.
Stack is used.
Instructions are PUSH, POP etc.
2) One Address Instruction Format
This instruction format uses only one address field.
Instructions are LOAD, ADD, STORE etc.
Example :
operation source
ADD A
Unit - 03 Central Processing Unit and Instruction Lecture-05
3) Two Address Instruction Format
It uses two address fields.
Instructions are ADD, MUL, MOV
Example :
operation source, destination
ADD A, B
4) Three Address Instruction Format
It uses three instruction fields.
Instrctions are ADD, MUL etc
Example :
operation source 1, source 2, destination
ADD A, B, C
Unit - 03 Central Processing Unit and Instruction Lecture-05
Instruction Cycle :
A program residing in memory of a computer consists of a sequence of instructions.
These instructions are executed by the processor by going through a cycle for each instruction.
Each instruction cycle consists of the following phases :
Fetch instruction from memory.
Decode the instruction.
Read the effective address from memory.
Execute the instruction.
Unit - 03 Central Processing Unit and Instruction Lecture-05
Unit - 03 Central Processing Unit and Instruction Lecture-05