You are on page 1of 10

COMPUTER SCIENCE NOTES (ICS_PART-I)

Written By: Ajab Noor


Lecturer in Computer Science GPGC
Bannu
COMPUTER SCIENCE NOTES (ICS_PART_I)
UNIT#3

CENTRAL PROCESSING UNIT

2020
EDITION

2020
EDITION
2020
EDITION

1|Page
COMPUTER SCIENCE NOTES (ICS_PART-I)

What is CPU? Explain different components of CPU?


CPU stands for Central Processing Unit. It is also known as microprocessor or
processor. It is the brain of computer system. Just like human brain controls all
the activities of human body, the CPU controls all the operations of the
computer. Computers use two types of storage; Primary storage and secondary
storage. The CPU mainly interacts with primary storage or main memory,
referring to it for both instructions and data.
There are four important functions of CPU;
✓ Fetch
✓ Decode
✓ Execute
✓ Write back (Store)
Basic Components of CPU: The three main components of the CPU are
following;
1. Arithmetic Logic Unit (ALU)
2. Control Unit (CU)
3. Registers (Memory Unit)
Arithmetic Logic Unit: It is the main processing unit of CPU which executes all
arithmetic and logical operations. It performs arithmetic calculations like
addition, subtraction, multiplication and division as well as comparisons of two
data items. There can be more than one Arithmetic logic unit in a CPU.
Control Unit: Its name clearly shows that it controls and co-ordinates computer
components. It extracts instructions from memory and decodes and executes
them, calling on the ALU when necessary. It communicates with Input/output
devices for transfer of data or results from storage. It does not process or store
data.
Registers/Memory Unit: Registers are temporary storage areas which are
responsible for holding the data that is to be processed. They store the
instructions and data in a Processor. This data is further used by Control Unit.
The main registers are Program counter, Instruction register, Memory Buffer
register, Memory Address register, Accumulator register, Status register, flag
register etc.

2|Page
COMPUTER SCIENCE NOTES (ICS_PART-I)

What is System Bus? Explain different types of System Bus?


Bus: A bus is a common pathway through which information flows from one
computer component to another. This pathway is used for communication
purpose and it is established between two or more components of a computer.
OR
All the components of computer are connected with a set of parallel lines. All
these lines are used to transfer data in the form of bits from one component to
another component. These lines are called Bus.
There are two types of buses:

• System Bus
• Expansion Bus
System Bus: It is used to connect main components of the computer. System
Bus connects the CPU to the main memory (RAM) on the motherboard. The
system bus is also called the front-side bus, memory bus, local bus, or host bus.
Expansion Bus: It is used to connect various peripheral devices (I/O devices) to
the CPU. It is also called I/O buses or external buses.
Types of System Bus: It is divided into three main categories.

• Control Bus
• Address Bus
• Data Bus
Control Bus: It is a bi-directional bus that carries control signals (Read, Write,
acknowledge) from one component to another. It specifies the type of
operation that is to be performed. The size of control bus is from 8-16 bits.
Address Bus: It is a uni-directional bus that carries addresses not data. It carries
address signal from CPU to read and write data in the memory.
An address is a unique ID of each component connected to the system bus. The
address bus consists of 16, 20, 24, 32 parallel signal lines.
Data Bus: It is a bi-directional bus that carries the actual data from one
component to another. There are 32 or 64 parallel lines of data bus.
The amount of data that a bus can transmit is called bus-width. A 64-line data
bus can transmit 64 bits (8 bytes) at a time.

3|Page
COMPUTER SCIENCE NOTES (ICS_PART-I)

___________________________*****xxxxx*****_______________________________

What is Register? Discuss different types of Registers?


Registers: A high speed temporary storage areas within CPU is called Registers.
Their function is to temporarily store binary information and pass it to other
parts of the CPU or RAM during the execution of program instructions. The
number of registers varies from processor to processor. It increases the
performance of the CPU.
Types of Registers: Registers are divided into two major groups according to
their purpose and function.
• General Purpose Registers
• Special Purpose Registers
General Purpose Registers: It is used to store data as well as addresses. Theses
registers are used for arithmetic and data movement. Its size is 8-32 bits.
Following are the commonly used general purpose registers.
i. Accumulator Register (AX)
ii. Data Register (DX)
iii. Base Register (BX)
iv. Counter Register (CX)
Accumulator Register (AX): It is used for arithmetic (+,−,,  ) and logical (, ,
, ) operations. It is of 16 bits and is divided into two 8-bit registers AH and AL.
It is initially set to zero.
Bits 15……………………………….............0
16-bit AX Register
8-bit AH Register 8-bit AL Register

Base Register (BX): It is used to hold the address of the base storage location
from where the data were stored continuously. Base register value is used to
find the data that is required. It is of 16 bits and is divided into two 8-bit registers
BH and BL.
Bits 15……………………………….............0
16-bit BX Register
8-bit BH Register 8-bit BL Register
4|Page
COMPUTER SCIENCE NOTES (ICS_PART-I)

Counter Register (CX): It is used in looping and repeating instructions. It is of 16


bits and is divided into two 8-bit registers CH and CL.
Bits 15……………………………….............0
16-bit CX Register
8-bit CH Register 8-bit CL Register

Data Register (DX): It is used in multiplication, division and input/output


operations. It is of 16 bits and is divided into two 8-bit registers DH and DL.
Bits 15……………………………….............0
16-bit BX Register
8-bit DH Register 8-bit DL Register

Special Purpose Registers: It is used to hold the state of a program. These are
used by control unit to control the operations of CPU and by the operating
system to control the execution of the programs. Following are the special
purpose registers.
i. Instruction Register (IR)
ii. Program Counter (PC)
iii. Memory Address Register (MAR)
iv. Memory Buffer Register (MBR)
Instruction Register (IR): Instruction register is used to store or hold the actual
instruction being loaded, decoded or executed currently. After loaded the
instruction from memory, it is decoded and then executed. It’s also called
Current Instruction Register (CIR).
Memory Address Register (MAR): It holds the address of the active memory
location. Suppose CPU wants to store some data in the memory or to read the
data from the memory. It places the address of the required memory location in
the MAR.
Memory Buffer Register (MBR): It holds the contents of data or instruction read
from, or written in memory. It means that this register is used to store
data/instruction coming from the memory or going to the memory.
Program Counter (PC): It holds the address of the next instruction to be fetched
and executed. When instruction is fetched, the value of PC is automatically
incremented by 1 and it points to the address of next instruction. It is also called
Instruction Pointer (IP).
___________________________*****xxxxx*****_______________________________

What is an Instruction? Discuss different types of Instructions?


Instruction: A group of bits that tells the computer to perform a specific
operation. Instruction has two fields;
Operation Code: It represents an action that the processor execute.

5|Page
COMPUTER SCIENCE NOTES (ICS_PART-I)

Operand Code: It defines the parameters of the action. It can be data or memory
address.

Operation Code Operand Code

Types of Instructions: There are different types of instructions.


a) Data Transfer Instructions
b) Data Processing Instructions
c) Program Control Instructions
d) Miscellaneous Instructions
Data Transfer Instructions: The data transfer instructions are used to transfer
data from one location to another. This transfer of data can be either from
register to register, register to memory or memory to register.
Following are some instructions that are used for data transfer purpose:
 MOV
 STORE
 LOAD
i. MOVE (MOV): It transfers the data from memory to register, register to
memory or register to register.
Syntax: MOV destination, source
Example: MOV AX, BX (Move the data of AX register to BX register)
ii. STORE (STO): It stores data from register to memory.
iii. LOAD (LD): It loads data to register from memory.
Example: LD AX (Load the data to AX register from memory).
Data Processing Instructions: It is used to perform arithmetic and logical
operations on the values of two registers. The result is also stored in these
registers. It is divided into three types;
• Arithmetic Instructions
• Logical Instructions
• Shift Instructions
i. Arithmetic Instructions: These are used for four basic operations i.e.,
Addition, Subtraction, Multiplication, Division. It may operate on
floating point data, binary or decimal data.
Examples: ADD, SUB, MUL, DIV
ii. Logical Instructions: These are used to operate on binary data stored
in registers.
Examples: AND, OR, NOT, XOR

6|Page
COMPUTER SCIENCE NOTES (ICS_PART-I)

iii. Shift Instructions: These are used for transfer of bits either to the left
of right of an operand.
Examples: Logical Shift Right (SHR), Logical Shift Left (SHL)
Program Control Instructions: These are used to change the flow of a program
or in other words it changes the address value in the Program Counter (PC)
register.
Examples: JMP, LOOP
a) JMP: It is used to jump from one memory location to another memory
location or from one part of a program to another part of the program.
b) LOOP: It is used when number of statements are to be repeated.
___________________________*****xxxxx*****_______________________________

Show computer instruction format with the help of a diagram and


label its parts?
The structure of an instruction is called Instruction format. An instruction format
defines the layout of the bits of an instruction. An instruction format must
include an Op-code (Operation Code) and zero or more Operands. The Op-code
will always be present.
 Op-code
 Operand
Op-code: It is a group of bits that define various processor operations such as
LOAD, STORE, ADD, SUB, MUL and SHIFT to be performed on some data stored
in registers or memory.
Operand: It can be data or address of data on which CPU performs an action.
Different instructions formats are used which are given below;
• Zero-Address Instruction
• One-Address Instruction
• Two-Address Instruction
Zero-Address Instruction: It requires only one Op-code, having no operand.
Examples: HALT, STOP
0……………….7 bits

Op-Code

One-Address Instruction: It requires one Op-code and one Operand. These


instructions require one address to do the operation.
Examples: LDA, JMP
0--------------7,8-------------20 bits

Op-code Operand

7|Page
COMPUTER SCIENCE NOTES (ICS_PART-I)

Two-Address Instruction: It requires one Op-code and two Operands.


Examples: MOV, ADD, SUB, MUL, DIV
ADD AX, BX
0..…….……….7,8…………...19,20……………...31 bits

Op-code Operand Operand

___________________________*****xxxxx*****_______________________________

What is Instruction Cycle? Explain different phases of CPU Instruction


Cycle?
Instruction Cycle: The Instruction Cycle (also known as the fetch-decode-
execute cycle or simply fetch-execute cycle or Machine cycle) is a process by
which a Processor retrieves a program instruction from memory, determines
what action to be perform and carries out those actions is called Instruction
Cycle. This cycle is repeated continuously by the CPU from booting of computer
till it is shut down.
Steps of Instruction Cycle: There are four steps of Instruction Cycle.
a) Fetch (Get an instruction from main memory)
b) Decode (Translate it into computer commands)
c) Execute (Actually process the commands)
d) Store (Write the result to the main memory)
Fetch: The CPU reads the value of PC and the instruction is copied into the
Instruction Register (IR). This process is done in three steps;
✓ Copy the contents of PC into MAR
✓ Copy the data from the memory to MBR
✓ Instruction is copied into IR
After completing the above steps, the value of PC is incremented by 1 and it
points to the address of next instruction.
Decode: Decoding means to activate the appropriate circuit to execute the
instruction. The control unit (CU) decodes the instruction by analyzing the Op-
code of the instruction. CU also reads the values of operands specified in the
instruction.
Execute: The process of performing an action on the decoded instruction is
called Execution. After decoding, the CU passes the decoded instruction to the
relevant units to perform the action.
Store: The generated result is stored in the main memory or sent to an output
device. This step is optional.

8|Page
COMPUTER SCIENCE NOTES (ICS_PART-I)

___________________________*****xxxxx*****_______________________________

Briefly elaborate the classification of Microprocessors? Also


differentiate between RISC and CISC processor?
Besides the classification based on the word length, the classification is also
based on the architecture i.e., Instruction Set of the microprocessor. These are
categorized into;
 RISC (Reduced Instruction Set Computer)
 CISC (Complex Instruction Set Computer)
RISC (Reduced Instruction Set Computer): It stands for Reduced Instruction Set
Computer. It is a type of microprocessor architecture that uses a small set of
instructions of uniform length. These are simple instructions which are generally
executed in one clock cycle. RISC chips are relatively simple to design and
inexpensive. The setback of this design is that the computer has to repeatedly
perform simple operations to execute a larger program having a large number
of processing operations.
Examples: SPARC, POWER PC etc.
CISC (Complex Instruction Set Computer): It stands for Complex Instruction Set
Computer. These processors offer the users, hundreds of instructions of variable
sizes. CISC architecture includes a complete set of special purpose circuits that
carry out these instructions at a very high speed. These instructions interact with

9|Page
COMPUTER SCIENCE NOTES (ICS_PART-I)

memory by using complex addressing modes. CISC processors reduce the


program size and hence lesser number of memory cycles are required to execute
the programs. This increases the overall speed of execution.
Examples: Motorola 680x0 family, Intel architecture, AMD etc.
RISC vs CISC
Basis for
RISC CISC
Comparison

Stand RISC stands for ‘Reduced CISC stands for Complex


Instruction Set Computer. Instruction Set Computer.

Instruction The RISC processors have a The CISC processors have a


Set smaller set of instructions larger set of instructions

Memory Unit RISC has no memory unit and CISC has a memory unit to
uses a separate hardware to implement complex
implement instructions instructions

Program RISC has a hard-wired unit of CISC has a


programming microprogramming unit

Design RISC is a complex compiler CISC is an easy compiler


design design

Calculations RISC calculations are faster CISC calculations are slow


and more precise and precise

Decoding RISC decoding of instructions CISC decoding of instructions


is simple is complex

Time Execution time is very less in Execution time is very high in


RISC CISC

External RISC does not require external CISC requires external


memory memory for calculations memory for calculations

Examples SPARC, POWER PC Motorola 680x0 family, Intel


architecture, AMD

X
AJAB NOOR
Lecturer in Computer Science, GPGC Bannu

10 | P a g e

You might also like