Q.2) Give short answers to the following questions.
i) What is the function of ALU in the computer?
ALU (Arithmetic Logic Unit) is the basic part of CPU 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 controls all processing of computer. It extracts instruction from memory, decodes and executes them. It is the brain of computer which directs the operation of a processor. It calls the ALU when it has any instruction which is in the form of arithmetic or logic expression. It sends that instruction to ALU for processing. ALU than submit its result to CU for further processing. It also tells input and output devices to respond a program’s instructions.
iii) What is a microprocessor?
A microprocessor is a computer processor that contains CPU on a single chip. CPU is also referred as microprocessor.
It is a multipurpose, programmable device that accepts digital data as input, processes it according to instructions stored in its memory, and provides results as output. Microprocessor is also used to control the functionality of almost all digital devices, from clock to automobiles.
There are three basic characteristics of microprocessors:
- Instruction set: It is the set of instructions that the microprocessor can execute.
- Bandwidth: Bandwidth is the number of bits processed in a single instruction.
- Clock speed: Clock speed determines how many instructions per second the processor can execute. It is measured in MHz.
iv) Define system bus.
System bus is defined as:
“The system bus is a pathway composed of cables 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 contains the data which is to be moved from memory to other components or from components to the memory.
It is the register in a computer’s processor or CPU. It contains the copy of designated memory locations specified by the memory address register. It acts as a buffer 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 functionality of a CPU is to execute a set of stored instructions called program. There are four steps in CPU operation. These are:
- Fetch: At this steps instruction is fetched from memory.
- Decode:At this step fetched instruction is translated.instruction.
- Execute: Instruction is processed at this step.
- Store: The executed result is stored in the memory at last step.
vii) What is meant by an instruction?
“ A group of bits that tells the computer to perform a specific function.”
Instructions are stored in main memory. In main memory these are 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.
There are different types of instructions:
- Data transfer instructions: The data transfer instructions are responsible of transferring data among operands
- Data processing instructions: Data processing instructions are relevant to arithmetic and logic operations
- Program control instructions: Program control instructions are conditional instructions.
- Miscellaneous instructions: The miscellaneous instructions involve various query and special operations.
viii) Differentiate between op-code and operand?
The difference between Opcode and Operand is as follows:
|Difference||It is the part of instruction set that represents an action that processor execute.||It is the part of instruction set that defines the parameters of the action.|
|Dependency||It is independent||It depends on the operation.|
|Functionality||An opcode is a single instruction that can be executed by the CPU.||Operands are manipulated by the opcode.|
|Example: MOV, AL, 34h||In this example, the opcode is the MOV instruction||In this example, the operands are the register named AL and the value 34 hex.|
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 process operations such as LOAD, STORE, ADD ,SHIFT etc.
Operand field can have data or it carries address of data.
x) Differentiate between CISC and RISC processor architecture.
The difference between CISC and RISC processor architecture is as follows:
|Acronym||CISC stands for Complex Instruction Set Chip.||RISC stands for Reduced Instruction Set Chip.|
|Emphasis||CISC architecture emphasis on hardware.||RISC architecture emphasis on software.|
|Clock||It includes multi-clock.||It includes single- clock.|
|Instructions||It has complex instructions.||It has reduced instructions.|
|Cycles||CISC utilize more cycles.||RISC utilize less cycles.|
|Implementations||CISC implementations are slower.||RISC implementations are faster.|
|Uses||Computers typically use CISC.||Tablets, smartphones etc. use RISC.|
Extensive Questions class 11 computer science notes for kpk
Q.3) Give detailed answers to the following 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 referred to as 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.
Basic components of CPU:
CPU consists of the following basic components:
- Arithmetic and Logic Unit (ALU)
- Control Unit (CU)
- Internal Buses
Arithmetic Logic Unit (ALU):
This basic part of CPU 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.
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.
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 signals necessary for execution of those instructions.
Registers are used to quickly accept, store and transfer data and instructions that are being used immediately by the CPU.
It is a special high speed storage area within the CPU. It has a major role in memory of computer because all data must be represented in a register before it can be processed. For example, it 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 determine 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 various types of Registers that are used for various purposes. Registers are divided into two main types:
- General purpose Registers
- Special purpose Registers
General Purpose Registers are not used for storing any specific type of information. All operands and addresses are stored in them at the time of program execution.
Special Purpose Registers are not accessed by users. These used by the computer system at the time of program execution. Some types of special purpose registers are Memory Address Register (MAR), Memory Buffer Register (MBR), Instruction Register (IR), Program Counter (PC).
Cache memory is a portion of the high speed static RAM (SRAM) and is effective because most programs access the same data or instructions over and over. If repeatedly used information is placed in cache, CPU will access it faster and more efficiently.
There are different levels of Cache. These are:
- Level 1 (L1) Cache: It is referred to as primary cache, internal cache or system cache. It exists in the microprocessor and is very fast and most expensive cache. Processor first checks the L1 cache memory.
- Level 2 (L2) Cache: It is commonly referred to as secondary cache or external cache. It is located on the motherboard on earlier computers. In modern computers it is found on the processor chip.
- Level 3 (L3) Cache: In modern computer L3 is located on motherboard. Its size is large in comparison to L1 and L2 cache.
Bus is a pathway 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, control information and any other internal communications or processes. It enables faster data transfer as it is internal to the system.
Commonly used internal buses are memory bus, system bus etc.
System bus contains three types of buses:
a. Data bus: This bus is used to carry data. It provides connection between CPU, memory and peripheral devices.
b. Address bus: It is used to transfer memory address where the executed instruction has to be stored.
c. Control bus: It is used by CPU to communicate with other devices
ii) What is a register? Explain different types of registers.
Register is a memory component which resides within a CPU. These are high speed temporary memory used to help the CPU get access to data and instructions quickly and effectively. These are semiconductor devices whose contents can be read and write at extremely high speeds but which are held their temporarily during the execution of programs.
Registers are the top memory hierarchy. These are the fastest way for the system to manipulate data. These are measured by the number of bits they can hold. For example, an 8-bit register means it can store 8 bits of data or a 32-bit register means it can store 32 bit of data.
Types of registers:
There are two type of registers:
- General purpose registers
- Special purpose registers
a. General purpose registers:
General purpose registers are not used for storing any specific type of information. All operands and addresses are stored in them at the time of program execution. Their ranges between 8 – 32 bit. Commonly used general purpose registers are as follows:
i. Accumulator (AX)
ii. Base register (DX)
iii. Counter register (BX)
iv. Data register (CX)
i. Accumulator register (AX):
AX registers are used for I/O port access, arithmetic, interrupt calls etc. 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:
ii. Base register (BX):
BX registers are used as a base pointer for memory access. It also gets some interrupt return values. 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:
iii. Counter register (CX):
CX registers are used as a loop counter and for shifts. 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:
iv. Data register (DX):
DX registers are used in multiply and divide operations. It works like a buffer. It copies the thing which has to be used by the processor. 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:
b. Special purpose registers:
Special purpose register are not accessed by users. These used by the computer system at the time of program execution. Some types of special purpose registers are as follows:
i. 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.
ii. 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.
iii. 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.
iv. Program counter (PC):
PC is also known as instruction pointer. It contains the address of the instruction that has to be executed at the current time. When an instruction is fetched, it is increments the stored value to 1.
iii) What is a system bus? Explain different types of buses used in computers.
A bus is a common pathway through which information flows from one component to another. This pathway is used for communication purpose and can be established between two or more computer components.
System bus connects the CPU to the main memory on the motherboard. There are three types of system buses:
i. Data bus
ii. Address bus
iii. Control bus
These are shown in figure below.
i. Data bus:
Data bus handles the transfer of data and instructions. It transfers the instructions from memory to CPU for execution and also to I/O devices. It carries data from the CPU and memory when required. 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 data can travel through data bus as it is 32-bits wide.
ii. Address bus:
An address bus is a group of wires that are used to transfer the addresses of memory or I/O devices. It is unidirectional. It is of 8 and 16 bits. 8 bit bus can transfer up to 256 unique addresses and 16 bit bus can transfer 65,536 addresses to different locations.
iii. Control bus:
Control bus is used to process data i.e. it directs data and monitor its actions in different areas of computer. It also transfers some control signals like Read, write, interrupt etc. Various operations are performed with the control bus in microprocessor. 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.
An instruction is an order given to a computer processor by a computer program. It is a segment of code that contains steps that need to be executed by the computer processor. Every time computer needs an instruction from computer processor to know how to do and what it is being asked to do. Every instruction has two fields:
- Operation code
- Operand code
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.
CPU instructions are of different types:
- Data Transfer instructions
- Data Processing instructions
- Program Control instructions.
a.Data transfer instructions:
The data transfer instructions are responsible of transferring data among operands. The most common transfers of data are between:
- Register and memory
- Registers and I/O
- Registers to registers
Some of the common data instructions are:
- 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
The above instruction will move the contents of register A to B.
- LOAD (LD) instruction: This instruction loads the contents of memory to specified register. The syntax of this instruction is:
The above instruction will load the data from memory to register A.
- STORE (STO) instruction: This instruction will store a value to memory. It copies the data from a register to memory.
b.Data processing instructions:
Data processing instructions are relevant to arithmetic and logic operations. It contains value of two registers to perform arithmetic and logic operations. These instructions are divided into three basic types:
- Arithmetic instructions
- Logical instructions
- Shift instructions
i. Arithmetic instructions:
Arithmetic instructions handle four basic types of operations. These are:
These instructions can operate on fixed-point, binary or decimal data. Some more operations may also be handled with these instructions. These are:
During the execution of arithmetic instructions, the operands will come in operational registers for the processing of data in ALU.
ii. Logical instructions:
Logical operations include
All these instructions operate on the binary data stored in registers.
iii. Shift instructions:
These types of instructions are used to transfer bits, from left or to the right of operand.
c. Program Control Instructions:
Program control instructions are conditional instructions. They put a condition for altering the sequence of program or the contents of PC register. They direct the flow of program and allow the flow of program to change according to the given condition. These conditions are based on decisions, made by different program control instructions. Some of the program control instructions are:
- JMP instruction: This instruction jumps to begin the execution at another location.
- CMP instruction: This instruction is used to compare to numeric data fields.
- 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
. . .
v) What is Instruction cycle? Explain different phases of CPU instruction cycle.
Instruction cycle can be defined as:
“The time period during which one instruction is fetched from memory and executed when a computer is given an instruction in machine language is called instruction cycle.”
This cycle is also machine cycle.
Phases of CPU instruction cycle:
There are four phases of an instruction cycle. These are:
I. Fetch :
In the first phase of instruction cycle, the instruction is fetched from memory. The instruction was in Program Counter (PC).After being fetched it is stored in Instruction Register (IR).
At this phase, the decoder translates the instruction. If the instruction has an indirect address then an effective address is also read from memory.
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.
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.