0% found this document useful (0 votes)
7 views

CH 3 1st Year (Nouman) Central Processing Unit

Uploaded by

hameed ullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

CH 3 1st Year (Nouman) Central Processing Unit

Uploaded by

hameed ullah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Central Processing Unit

SHORT QUESTIONS

i) What is the function of ALU in the computer?


ALU (Arithmetic Logic Unit) is the basic part of CPU that deals with (‫ )کے ساتھ نمٹنا‬all
mathematical calculations. It is further divided into two parts:

 Arithmetic Unit (AU)


 Logic Unit (LU)

Arithmetic Unit deals with arithmetic calculations such as addition (+), subtraction (-)
and multiplication (x), whereas Logic Unit (LU) deals with all logical comparisons such as
greater than (>), less than (<), equals to (=) etc.

ii) What is the function of control unit in the computer?


Control Unit (CU) is the part of CPU which manages (‫ سنبھالنا نپٹانا‬- ‫ )سربراہی کرنا‬the
functions performed by different parts of the computer. It coordinates1 (‫)ہم آہنگی پیدا کرنا‬
and control (،‫ )بس یا قابو میں رکھنا‬the different parts of computer like brains controls the
human body. It fetches instructions from memory, decodes and executes them. It calls
the ALU when it has any instruction in the form of arithmetic or logic expression. It
sends the instruction to ALU for processing. ALU then submit its result to CU for further
processing. It also directs (‫ )ہدایت کرتا ہے‬input and output devices to respond ( ‫جوابا عمل‬
‫ )کرنا‬to program’s instructions.

iii) What is a microprocessor?


A microprocessor is a programmable, multipurpose (‫)کثیر المقاصد‬, device that
incorporates (‫ )شامل کرتا ہے‬the functions (‫ )افعال‬of a CPU (central processing unit) on a
single IC (integrated circuit) Chip. A microprocessor accepts binary data as input,
processes that data, and then provides output based on the instructions stored in the
memory.
The data is processed using the microprocessor's ALU (arithmetical and logical unit),
control unit, and a register array (‫)صف‬. The register array holds the data and instruction
via a number of registers that act as temporary fast access memory locations. The flow
(‫ )بہاؤ‬of instructions and data through the system is managed by the control unit.

1
Coordinates means to make many different things work effectively as a whole

Chapter 3 |1 M. Nouman Abid 1st Year


Central Processing Unit
iv.) Define system bus.
The system bus is a pathway (‫ )راستہ‬composed of (‫ )پر مشتمل‬cables2 (‫ )تار‬and connectors
(‫ )جوڑنے واال آلہ‬used to carry (‫ )لے جانا‬data between a computer microprocessor and the
main memory.”
Most of the system buses are made up of 50 to 100 lines for communication. The
system bus consists of three types of buses:
 Data bus
 Address bus
 Control bus

v) Write short note on Memory Buffer Register (MBR).


Memory buffer register (MBR) or memory data register (MDR) contains the data which
is to be moved (‫ )چس کو منتقل کرنا ہے‬from memory to other components or from other
components to the memory.
It is the register in a computer’s processor or CPU. It contains a copy of the value in the
memory location (‫ )مقام‬specified by (‫ بتانا‬- ‫ )بیان کرنا‬the memory address register. It acts as
(‫ )کے طور پر کام کرتا ہے‬a buffer3 allowing the processor and memory units to act
independently (‫ )آزادانہ طور پر‬without being affected (‫ )اثر انداز ہوے بغیر‬by minor
differences (‫ )اختالفات‬in operation (‫)کارروائی‬.

vi.) What is CPU operation?


CPU is the main hardware component (‫ )جزو‬in a computer system. It carries out ( ,‫پورا کرنا‬
‫ )انجام دینا‬the instructions of a computer program by performing arithmetical, logical and
input/output operations of the system. The basic function (‫ )کام‬of a CPU is to execute
(‫ )انجام دے‬a set of stored instructions called program.

There are four steps in CPU operation.

 Fetch: At this step, the instruction is fetched from memory.


 Decode: At this step, the fetched instruction is translated.
 Execute: Instruction is executed (Each part of the CPU that is needed is activated
to carry out the instructions)
 Store: The result obtained as a result of instruction execution is stored in the
memory at last step.

2
Cable is a conductor for transmitting electrical or optical signals or electric power.
3
A buffer is a data area shared by (‫ )اشتراک میں – مل کر استعمال کرتے ہیں‬hardware devices or program that operate
at (‫ )کام کرتے ہے‬different speeds

Chapter 3 |2 M. Nouman Abid 1st Year


Central Processing Unit
vii) What is meant by an instruction?
Instruction (or instruction code) is a group of bits that tells computer to perform ( ‫انجام‬
‫ )دیں‬a specific operation (‫ عمل‬- ‫)کارروائی‬

Instructions are stored in main memory waiting to be processed (‫ )عملدرآمد‬by processor.


It has two fields:

 Operation code: shows an action (‫ )عمل‬which has to be performed by the CPU.


 Operand code tells the parameters (‫ )حد‬of action. It depends on operation that
will be performed. It can be data or memory address.

There are different types of instructions:

 Data transfer instructions: The data transfer instructions are used to transfer
data from one location in computer to another location without changing the
content.
 Data processing instructions: Data processing instructions are used to perform
arithmetic and logic operations
 Program control instructions: Program control instructions are used to alter ( ‫تبدیل‬
‫ )کرنا‬the sequence (‫ )ترتیب‬of program execution.
 Miscellaneous instructions: The miscellaneous instructions involve various
special operations.

viii) Differentiate between op-code and operand?


The difference between Op-code and Operand is as follows:

HEADINGS OP-CODE OPERAND


Difference Op-Code is the part of instruction Operand is the data or memory
that represents (‫ )ظاہر کرنا‬an location used to (‫)استعمال کیا جاتا ہے‬
action that processor execute. executes that instruction.
Dependency It is independent (‫)خود مختار‬. It depends (‫ )انحصار‬on the
operation.
Functionality An op-code is a single instruction Operands are manipulated ( ‫حسب‬
that can be executed by the CPU. ‫ )منشاء چالنا اشاروں پر چالنا‬by the op-
code.
Example: In this example, the op-code is In this example, the operands are
MOV, AL, 34h the MOV instruction the register named AL and the
value 34 hex.

Chapter 3 |3 M. Nouman Abid 1st Year


Central Processing Unit
ix) Show computer instruction format with the help of a diagram
and label its parts.
The instruction format is as follows:

The above figure shows an instruction format which as two fields:

 Op-code field is used to define different operations such as LOAD, STORE, ADD,
SHIFT etc.
 Operand field can have data or it carries address of data.

Different instructions formats are as follows.

 Zero Address Instruction:


In this format there is only one Op-Code and no operand e.g. HALT, STOP
 One Address Instruction:
In this format there is one Op-Code and One operand e.g. JMP AX
 Two Address Instruction:
In this format there is one Op-Code and two operands e.g. ADD A B

x) Differentiate between CISC and RISC processor architecture ( ‫طرز‬


‫)تعمیر‬.
The difference between CISC and RISC processor architecture is as follows:

HEADINGS CISC RISC


Acronym CISC stands for (‫)سے مراد‬ RISC stands for Reduced (‫)کم کیا گیا‬
(‫)مخفف‬ Complex (‫ )پیچیدہ‬Instruction Set Instruction Set Chip.
Chip.
Emphasis CISC architecture emphasis on RISC architecture emphasis on
(‫ زور دینا‬,‫)تاکید کرنا‬ hardware. software.
Clock It includes multi-clock. It includes single- clock.
Instructions It has large amount of and It has small amount of and simple
complex instructions. instructions.
Cycles CISC utilize more cycles. RISC utilize less cycles.
Speed CISC are slower. RISC are faster.
Uses Computers typically use CISC. Tablets, smartphones etc. use
RISC.

Chapter 3 |4 M. Nouman Abid 1st Year


Central Processing Unit
LONG QUESTIONS

i) What is CPU? Describe basic components of CPU in detail.

Central Processing Unit (CPU):


CPU is the main part of any computer system. It is said to be the brain of computer. It
controls all the working of computer. It is also called a processor or microprocessor as
well. It is IC chip of square shape or rectangle placed in motherboard of computer. CPU
is connected to all parts of the computer.

CPU controls all instructions, storage of data, input and output operations and functions
of all devices attached.

CPU consists of the following basic components:

1. Arithmetic and Logic Unit (ALU)


2. Control Unit (CU)
3. Registers
4. Cache
5. Internal Buses

1. Arithmetic Logic Unit (ALU):


ALU is the basic part of CPU that deals with all mathematical calculations. It is further
divided into two parts:

 Arithmetic Unit (AU)


 Logic Unit (LU)

AU deals with arithmetic calculations such as addition (+), subtraction (-) and
multiplication (x), whereas LU deals with all logical comparisons such as greater than (>),
less than (<), equals to (=) etc.

2. Control Unit (CU):


It is the part of CPU which controls and manages all processing of computer. It extracts
(‫ )نکالنا‬instruction from memory, decodes and executes them. It calls the ALU when
necessary.
It also arranges (‫ )بندوبست‬the storage and directs (‫ )لے جانا‬the data to output.

Chapter 3 |5 M. Nouman Abid 1st Year


Central Processing Unit
CU is also responsible for controlling the flow of instructions and data within the CPU. It
contains logic )‫ منطق‬- ‫ )قابلیت‬to interpret instructions and to generate required (‫)در کار‬
signals4 necessary for execution of those instructions.

3. Registers:
Register is a high speed small storage area within the CPU. Register temporarily stores
currently executing instruction and pass (‫ )منتقل کرنا‬information to other parts of CPU and
to main memory. For example, if two numbers are added, both numbers must be in
registers and the result is also placed in a register.
The register can also contain the address of a memory location where data is stored
rather than the actual data itself.

4. Cache:
Cache memory is extremely fast static RAM (SRAM) that is built into CPU or located
(‫ )بٹھائ – رکھی جاتی ہے‬next to (‫ )ملحق‬CPU and is effective because most programs access
the same data or instructions over and over again. Caches stores repeatedly used
information. CPU accesses it quickly and more efficiently.

There are different levels of Cache. These are:

4.1. Level 1 (L1) Cache:


It is also called primary cache, internal cache or system cache. It exists in the
microprocessor and operates at same speed as CPU. CPU accesses it directly and
it holds data that CPU needs to execute instructions. CPU Processor first checks
the L1 cache memory. It is fastest but most expensive and smaller in size (8 to
128KB).

4.2. Level 2 (L2) Cache:


It is commonly referred to as secondary cache or external cache. It pulls
information from RAM which is then accessed by L1 Cache. It was located on the
motherboard of earlier computers. In modern computers it is found on the
processor chip. It size is 64KB to 16MB

4.3. Level 3 (L3) Cache:


In modern computer L3 is located on motherboard. Its size is large in comparison
to L1 and L2 cache.

4
a signal is an electrical or radio wave that conveys information

Chapter 3 |6 M. Nouman Abid 1st Year


Central Processing Unit
5. Internal buses:
Bus is a set of conducting lines used to move data around the computer. It interconnects
CPU to all the other components on the motherboard.
The internal bus carries data within the motherboard. It connects motherboard to all
other components of computer. It enables communications between internal
components such as computer video card and memory.
An internal bus can carry data, memory addresses and control information. It enables
faster data transfer as it is internal to the system.

ii) What is a register? Explain different types of registers.


Register is a high speed small storage area within the CPU. Register temporarily stores
currently executing instruction and pass (‫ )منتقل کرنا‬information to other parts of CPU and
to main memory. For example, if two numbers are added, both numbers must be in
registers and the result is also placed in a register.

The register can also contain the address of a memory location where data is stored
rather than the actual data itself.

The number of registers that a CPU has and the size of each register determines ( ‫تعین کرتا‬
‫ )ہے‬the power and speed of a CPU. For example, a 32-bit CPU is one in which each
register is 32-bits wide. Therefore, each CPU instruction can manipulate 32 bits of data.

There are two types of registers:

 General purpose registers


 Special purpose registers

1. General purpose registers:


General Purpose Registers are used for storing data as well as addresses. These are used
for arithmetic operation and data movement. All operands and addresses are stored in
them at the time of program execution. Their size ranges between 8 – 32 bit. Commonly
used general purpose registers are as follows:

 Accumulator (AX)
 Base register (DX)
 Counter register (BX)
 Data register (CX)

Chapter 3 |7 M. Nouman Abid 1st Year


Central Processing Unit
1.1. Accumulator register (AX):
AX register is used by CPU for performing arithmetic and logical operations and to hold
the result of those operations. These are initially set to zero then each number in turn is
added to the value in the accumulator. It has two 8-bit registers (AH and AL) which are
combined together and used as a one 16-bit register, which is shown in figure below:

1.2. Base registers (BX):


BX register can perform arithmetic and data movement. BX can hold memory address
that points to another variable. It usually contains pointers. It consists of two 8- bit
registers (BH and BL) which are combined together and used as 16- bit register, which is
shown in below figure:

1.3. Counter register (CX):


CX register act as counter for repeating instructions. It consists of two 8-bit registers (CH
and CL) which can be combined and used as 16-bit register, which is shown in figure
below:

1.4. Data register (DX):


DX registers are used in multiply and divide operations. It works like a buffer and holds
anything that is copied from memory. It also consists of two 8-bit registers, which are
combined together to work as a 16-bit register, which is shown in figure below:

2. Special purpose registers:


Special Purpose Registers holds the state of program. These are used by Control units to
control the operation of CPU and by operating system to control the execution of
program. Some types of special purpose registers are as follows:

2.1. Instruction Register (IR):


IR resides in control unit. It stores the instruction currently in execution. Every
instruction which has to be executed is first loaded into the instruction register. It is also
known as current instruction register (CIR) as it holds the instruction currently in
execution.

Chapter 3 |8 M. Nouman Abid 1st Year


Central Processing Unit
2.2. Memory Address Register (MAR):
MAR holds the memory address. The memory address is that address from which CPU
will get data and to where the data will be sent and then stored. It stores the memory
location of data that needs to be accessed.

2.3. Memory Buffer Register (MBR):


MBR holds the contents of memory which are to be moved from memory to
components and from components to memory. In order to store some information first
it is transferred to the MBR and from MBR it will go to the specified memory.

2.4. Program counter (PC):


PC is also known as instruction pointer. It contains the address of the next to be fetched
(executed). When an instruction is fetched, its value is incremented by 1.

iii) What is a system bus? Explain different types of buses used in


computers.
System bus:
“The system bus is a pathway (‫ )راستہ‬composed of (‫ )پر مشتمل‬cables5 (‫ )تار‬and connectors
(‫ )جوڑنے واال آلہ‬used to carry (‫ )لے جانا‬data between a computer microprocessor and the
main memory.”

Most of the system buses are made up of 50 to 100 lines for communication. The
system bus consists of three types of buses:

 Data bus
 Address bus
 Control bus

1. Data bus:
Data bus handles the transfer of data and instructions. It transfers the instructions from
memory to CPU for execution. It carries data (operand) from the CPU to memory and
from memory to CPU when required. It is also used to transfer data between memory
and I/O devices during input/output operation. It can transfer data in both directions i.e.
from CPU to memory and memory to CPU. It means that it is bidirectional bus but works
at one side at a time. A data bus is 32 to 64-bits wide. At a time a 32 bit of data can
travel through 32-bits wide data bus.

5
Cable is a conductor for transmitting electrical or optical signals or electric power.

Chapter 3 |9 M. Nouman Abid 1st Year


Central Processing Unit
2. Address bus:
An address bus is a group of wires that are used to transfer the addresses of memory or
I/O devices. Address indicates (‫ )اشارہ کرنا‬a memory location or register where
information is stored. It is unidirectional. 8 bit bus can transfer up to 256 unique
addresses and 16 bit bus can transfer 65,536 addresses to different locations.

3. Control bus:
Control bus is used by processor to direct and monitor the action of other components
of computer. It also transfers some control signals like Read, write, interrupt etc. This is
a dedicated bus, because all timing signals are generated according to control signal.
The size of this bus ranges from 8 to 16 bits.

iv.) Explain different types of CPU instructions. Also give examples.


Instruction:
Instruction (or instruction code) is a group of bits that tells computer to perform ( ‫انجام‬
‫ )دیں‬a specific operation (‫ عمل‬- ‫)کارروائی‬

Instructions are stored in main memory waiting to be processed (‫ )عملدرآمد‬by processor.


It has two fields:

 Operation code: shows an action (‫ )عمل‬which has to be performed by the CPU.

 Operand code tells the parameters (‫ )حد‬of action. It depends on operation that
will be performed. It can be data or memory address.

CPU instructions are of different types:

C h a p t e r 3 | 10 M. Nouman Abid 1st Year


Central Processing Unit
1. Data Transfer instructions
2. Data Processing instructions
3. Program Control instructions.

1. Data transfer instructions:


The data transfer instructions are used to transfer data from one location in computer
to another location without changing the content.

The most common transfers of data are between:

 Register and memory


 Registers and I/O
 Registers to registers

Some of the common data transfer instructions are:

1.1. MOVE (MOV) instruction:


This instructions copy data from one operand to another. That transfer might be
between register to memory or memory to register. The syntax of this
instruction is:

MOV destination, source

MOV A,B

The above instruction will move the contents of register A to B.

1.2. LOAD (LD) instruction:


This instruction loads the contents of memory to specified register. The syntax of
this instruction is:

LD destination

LD A

The above instruction will load the data from memory to register A.

1.3. STORE (STO) instruction:


This instruction will store a value to memory. It copies the data from a register to
memory.

2. Data processing instructions:


Data processing instructions are used to perform arithmetic and logic operations. These
instructions are divided into three basic types:

C h a p t e r 3 | 11 M. Nouman Abid 1st Year


Central Processing Unit
 Arithmetic instructions
 Logical instructions
 Shift instructions

2.1. Arithmetic instructions:


Arithmetic instructions handle four basic types of operations i.e. ADD, SUB, MUL and
DIV. These instructions can operate on fixed-point, binary or decimal data. Some more
operations may also be handled with these instructions are: ABSOLUTE, NEGATE,
INCREMENT and DECREMENT

Operands are first move to Operational Register to execute arithmetic instructions.

2.2. Logical instructions:


Logical operations include AND, OR, NOT and XOR.

All these instructions operate on the binary data stored in registers.

2.3. Shift instructions:


These types of instructions are used to transfer bits, from left or to the right of operand.

3. Program Control Instructions:


Program control instructions are used to alter (‫ )تبدیل کرنا‬the sequence (‫ )ترتیب‬of program
execution. They allow the flow of program to change according to the given condition.
Some of the program control instructions are:

3.1. JMP instruction: This instruction jumps to begin the execution at another
location.
3.2. CMP instruction: This instruction is used to compare the operand with numeric
value.
3.3. Loop instruction: It is used to run the statements repeatedly.

Here is the example to explain these instructions:

CMP DX, 00; Compare the DX value with zero

JE L7 ; If yes, then jump of L7

...

L7:

C h a p t e r 3 | 12 M. Nouman Abid 1st Year


Central Processing Unit
v) What is Instruction cycle? Explain different phases of CPU
instruction cycle.
Instruction cycle:
Instruction Cycle also called CPU Cycle is basic operation of CPU in which CPU fetch
(retrieve) instruction from memory and then decodes and executes instruction. Each
Cycle occurs only when clock pulse (signal) is generated.

There are four phases of an instruction cycle. These are: Fetch, Decode, Execute and
Store

1. Fetch:
In the first phase of instruction cycle, the instruction is fetched from memory. The
address of instruction to be fetched is obtained form Program Counter (PC). After being
fetched the instruction is stored in Instruction Register (IR).

2. Decode:
At this phase, the decoder translates the instruction. The instruction may include
immediate6, direct7 or indirect8 operand. If the instruction has an indirect address then
an effective address is also read from memory and any required data is fetched from
memory and is placed into data register.

3. Execute:
At execute phase the instructions are executed. The decoded instructions are passed to
the relevant places for execution by the CPU. For example mathematical instructions are
sent to ALU etc.

4. Store:
This is the last phase in which the result of the executed instructions is stored in the
main memory or sent to the output device. Usually this phase is not included in the
instruction cycle.

6
Immediate: instructions use their operand to hold the data needed to complete the instruction.
7
Direct: instructions use their operand to hold the memory address of the data. The effective address of the
operand in memory is part of the instruction.
8
Indirect: The instruction uses their operand to contain a memory address, which contains the effective address of
the operand in memory.

C h a p t e r 3 | 13 M. Nouman Abid 1st Year


Central Processing Unit

MCQ's-
i) Which of the following performs the arithmetic and logic operations on data?

A. ALU B. Control unit C. Bus D. Memory unit

ii) Coordinates and controls the computer system, just like the brain controls the
human body.

A. Bus B. Control unit C. Output unit D. Register

iii) Where are the logical operations performed in the CPU?

A. CU B. Register C. ALU D. Memory

iv)_______ Is a small memory device available in the CPU to store data temporarily.

A. CU B. Register C. ALU D. Memory

v)___is the small amount of memory located between a main memory and Processor.

A. RAM B. ROM C. Cache D. PROM

Vi.) Which of the followings cache memories resides inside the microprocessor and is
very fast from the other memories?

A. L1 cache B. L2 cache C. L3 cache D. L4 cache

vii) ____Register can perform arithmetic and data movement and it has some special
addressing abilities.

A. Base register B. Memory buffer register C. Data register D. Counter register

viii) Which of the following register has a special role in multiply and divide
operations?

A. Base register B. Memory buffer register C. Data register D. Counter register

ix) Register holds either the address of the instruction being executed or the address
of the next instruction to be executed.

A. Program counter B. Memory buffer register C. Data register D. Counter register

C h a p t e r 3 | 14 M. Nouman Abid 1st Year


Central Processing Unit
x) System bus connects the Central Processing Unit to ______ on the motherboard.

A. Register B. Main memory C. ALU D. Input unit

xi) Which of the following steps, in instruction cycle, interpret the instruction?

A. Fetch B. Decode C. Execute D. Write-back

xii) _____Instruction is used when number of statements is to be repeated.

A. LD B. LOOP C. JMP D. MOV

x iii) __________ is a microprocessor architecture that is designed to perform a


smaller number of types of computer instructions.

A. RISC B. CISC C. DISK D. LIST

xiv) How many op-codes do a Zero-Address instruction has?

A.1 B. 2 C. 3 D. 0

xv) Which of the following is not an arithmetic instruction?

A. DIV B. MUL C. SUB D. JMP

C h a p t e r 3 | 15 M. Nouman Abid 1st Year

You might also like