XI-computer Notes Chapter 5
XI-computer Notes Chapter 5
General Purpose Register:- The general purpose registers may be used for temporarily storing
data. These registers may be combined to form register pairs in order to handle larger size data.
Accumulator Register:- The Accumulator (AC) register is a general purpose processing
register. The Accumulator Register is mainly used to store the result of logical and arithmetic
operations.
Status Register:- The status register also called Flag register, hold I bit flag to indicate certain
condition that arise during arithmetic and logical operations. The important conditions shown by
flag or statues register are:
Carry flag (CF):-The answer can be 17 bits long when two 16-bit numbers are added. This extra
bit that does not fit into the destination register is placed in the carry flag, which can be used and
tested.
Zero flag (ZF):-The zero flag indicates whether the result is zero or nonzero.
Sign flag (SF):-A sign flag indicate whether the result is plus or minus.
Parity flag (PF):-A parity flag is a check bit that is added to a block of data for error detection
purposes. The value of the parity bit is assigned as either 0 or 1. Making the number of 1s in the
message block even or odd depends on the type of parity.
Interrupt flag (IF):-It tells the processor whether it can be interrupted externally. Sometimes
programmers do not want a particular task to be interrupted, so the interrupt flag can be set to
zero. Interrupts can be disabled or enabled by special instructions to set this bit to 0 or 1,
respectively.
Memory Buffer Register (MBR):This register is also known as the memory data
register(MDR). It is used to hold a word (a data value) that is being stored to or retrieved from
the memory location currently addressed by the memory address register.
The Memory Address Register (MAR):-The Address Register or AR hold the memory address
of the data that the CPU wants to read or write to.
Instruction Register(IR):- The instruction read from memory is placed in the Instruction
register (IR) The IR or Instruction Register holds the instruction that is currently in execution.
The CPU mainly uses IR to get the instruction, decode it and decide which operations have to be
performed to execute the instruction.
Program Counter:-The Program Counter (PC) hold the address of the next instruction to be
read from memory after the current instruction is executed. PC can be considered an important
part of the CPU’s instruction-fetching and execution cycle.
The Data Register:-As the name suggests the Data Register or DR is the register that stores the
data that is written to memory or read from memory.
The Temporary Register (TR):- It is used for holding the temporary data during the processing.
The intermediate result of the calculations is stored in these registers. It is refer to as the general-
purpose register. It can also be used to store the intermediate data between many calculations or
complex calculations.
The Input Registers (IR):- It holds the input characters given by the user. As the name suggests
the input register is used to store the input that is given to the CPU from an external device or
source like a mouse or keyboard. This is mainly used in conjunction with I/O(Input/ Output)
instructions that transfer the data between external devices and the CPU.
The Output Registers (OR):- It holds the output after processing the input data. This will store
the result or the output from the CPU to an external device, such as a printer or monitor. It is
used in conjunction with the input/ Output instructions to transfer the data between external
devices and the CPU. It is also used to store the data temporarily that is to be shown as output so
the CPU can continue to execute further
Q6. Define the term Bus, describe its types and function.
Ans. Buses: Bus is a communication pathway connecting with two or more devices. It is a
collection of wires through which data is transmitted or electrical signals are transmitted. The
speed of a bus is measured in megahertz(MHz). The size of a bus(its width) is how many bits it
can transfer at a time. A 64 bit computer has buses with 64 bit width.. It can be unidirectional or
bidirectional. Each wire carries just one bit, a bus with eight wires can carry only 8-bit data
words.
There are three types of buses.
1. Control Bus
2. Data Bus
3. Address Bus
Control Bus: The control bus manages the communication between the computer’s CPU and its
other components. The control bus supervises the reading or writing of data. In fact it informs the
CPU that a particular unit has completed its job. For example when an output device has
completed the job of printing a character the control bus communicates this information to the
CPU and the CPU may transmit another character to the output device for printing or may take
some other suitable action.
Data Bus: A data bus carries data. It is an electrical path that connects the CPU, Memory,
Input/output devices, and secondary storage devices. The data bus is bi-directional because data
has to pass from CPU to memory as well as from memory to the CPU. The number of lines in
bus affects the speed at which the data travels between different components.
Address Bus: An address bus carries address information. It is a set of wires similar to the data
bus but it only connects CPU and memory. It is unidirectional electric signals are transmitted in
one direction from CPU to other devices. Whenever the processor needs data from the memory,
it places the address of data on the address bus. The address is carried to the memory where the
data from the requested address is fetched and placed on the data bus. The data bus carried to the
CPU.
A three address instruction to add two numbers, specifies the operation code for addition,
addresses of two number (operands) to be added, address of the memory location where the
result of addition of two numbers is to be stored, usually called address of the destination.
Instruction Meaning
ADD A,B,C Add the numbers stored at the memory locations A and B. Store the result
in
memory location C
In other words C=A+B
It must be clearly understood that the instruction ADD, A,B,C is coded in binary form before it
can be executed by the computer.
Two Address Instruction:-The type of instruction in a computer system that requires minimum
two operands to perform operations is known as a 2-address instruction. In the case of 2-
address instruction, the result is stored in one of the two operands.
In other words, a computer instruction in which operations like addition, subtraction,
multiplication, etc. are performed on two values stored in registers and the result is also stored
back into one of the same registers, it is called a 2-address instruction.
The Two Address Instruction has the following parts.
Operation Code
Address of one of the operands, say address1
Address of the storage location where the result is to be stored. This address is denoted by
address 2
Opcode Address 1
Syntax
The 1-addresss instruction takes the following syntax −
AB
Where, A is an opcode like INC for increment, and B is the operand on which the operation is to
be performed. Thus, in the case of 1-address instruction, the operand is modified.
while the 1-address instruction requires only one operand to perform an operation and stores the
result in the same operand or in a register.
Zero Address Instruction:-1. Zero(0) Address Instruction format
The instruction format in which there is no address field is called zero address instruction. In
zero address instruction format, stacks are used. In zero order instruction format, there is no
operand.
The zero address instructions are also called stack instructions and consist of opcode only. The
addresses of operand and destination are implied. The general form of zero-address instruction is
Opcode.
Q11. What is stack? Explain its operations with example.
Stack:-A stack is a linear data structure used for storing data. A stack is an ordered list in which
insertion and deletion are performed at one end, which is referred to as the top. The data which is
placed first is removed in last and which is placed last is removed first. It is known as the Last in
First Out (LIFO) rule. When an element is inserted in a stack, the concept is called push and
when the element is removed from the stack, the concept is called pop. When stack is completely
full it is called over flow state, and when stack is completely empty is called underflow state.
Examples: letter basket, stack of trays, stack of plates. There are only two basic operations on
stacks, the push (insert), and the pop (delete).
1. push():-Push is a function in stack definition which is used to insert data at the stack's top.
2. pop():- Pop is a function in the stack definition which is used to remove data from the stack's
top.
2 (a + b) * c *+abc ab+c*
3 a * (b + c) *a+bc abc+*
5 (a + b) * (c + d) *+ab+cd ab+cd+*
Q16. What is data processing cycle? What its steps with the help of a diagram.
Or Describe instruction fetch cycle.
Ans. To execute an instruction, a processor goes through a series of steps, called an instruction
cycle. The instruction cycle typically consists of fetching the instruction from memory, decoding
the opcode and the operands, executing the operation, and storing the result.
Fetching of an Instruction: -The instructions and data are stored in main memory as computer
words. These instructions and data are stored in memory in binary coded forms (0s and 1s). By
fetching of an instruction means transferring an instruction from a memory location to the
instruction register (IR). This instruction Register holds an instruction temporarily only for the
time when the instruction and data are being interpreted or decode. The instruction from a
memory location is transferred to instruction register via another register called memory buffer
register (MBR). All the instructions and data from memory pass through memory buffer register
on their way to other registers or to other units. The other registers used in a fetching operation
are program counter (PC) and memoryaddress register (MAR). thus, the registers needed in
instruction fetching operations are.
1. Instruction Register (IR)
2. Memory buffer register (MBR)
3. Program counter (PC)
4. Memory address register (MAR)
5. Decode fetching instruction: -
To execute the instruction, ADD 4, 3, the processor might fetch the machine code 0001 0100
0011 from memory, decode it into the opcode 0001 and the operands 0100 and 0011, execute the
addition operation, and store the result 0111 in a register or memory.
Execution of an instruction :-The operation code is transferred to the control unit. This control
unit sends opcode to decoder where it is decoded. After decoding the opcode, the control unit
issues commands in the form of control signals to various other units such as arithmetic logic
unit to perform the necessary operations. The address part of the instruction in IR is transferred
to a decoder which decodes it as the address of a particular memory location. This address is
transmitted to memory address register (MAR) which transmits it to the main memory. Under the
directions of the control unit, the operand stored in that particular memory location is transmitted
to the memory buffer register, from where it is transmitted to the ALU. The most import register
of the ALU is accumulator where all the arithmetic is performed. This operand (data) is passed to
the accumulator in ALU where the necessary arithmetic as directed by the control unit is
performed and the result of the operand is held in the accumulator for onward transmission to the
main memory.