Unit 3
Unit 3
Organisation
1.1 Introduction
We know that a computer has five main components
1. Input unit
This unit contains devices with the help of which we enter data into computer.
For example, keyboard, mouse etc.
2. Arithmetic and logic unit (ALU)
This unit performs the arithmetic operations like addition,subtraction etc. and
logical operations like comparison, selection etc.
3. Memory unit
This unit stores instructions, data and intermediate results.
4. Control unit
This unit controls the operations of all parts of computer.
5. Output unit
This unit consists of devices with the help of which we get the information
from computer. For example, monitor, printers etc.
CPU(Central Processing Unit) is the heart of the computer which consists of
arithmetic and logic unit, control unit, register and decoders etc. CPUis connected
with various WO devices and memories by sets of wires called buses) A single bus
computer architecture is shown in figure 11.1
inalout
The purpose of CPUis to execute the instructions stored in the main memory.
Therefore,question arises, how these instructions will be exécuted by the CPU?
This chapter answer this question. In this chapter, we will discuss the basic
structures of CPU, the instruction cycle, instruction formats and addressing modes.
[255]
CPU
Registers
O-O ALU
Main Memory
Control unit
Bus
Device Device
Controller Controller
FIGURE 11.1
K.2 Bus
In a microcomputer, all the above mentioned units are linked to one another via
buses. A Bus is basically a set of wires that carry data bits and act as a
communication path between the processing unit and peripherals. Wires are used
to connect Register together. To connect n-registers we need n(n-1) wires, to
manage these wires is very difficult, moreover more wires causes more problems.
So in place of wires a Bus is used. Bus is a fast and safe mnedium of data transfer
from one place to other.
Two way of Data Transfer Occur :
()/Unidirectional Bus : Ad
Where bus is used to transfer data in one direction called Unidirectional. e.g.
Address Bus. Transfer is controlled by control signals.
[256]
(i) Bidirectional Bus :
Where Bus is used to transfer data in both irections, each direction is
controlled by a control switch. This bus is called Bidirectional. e.g. control,
Data Bus.
Abus is a group of wires which are used to transmit electrical signals. In a typical
eomputer, there are basically three types of buses namely address bus, data bus
and control bus.
Address Bus
This bus is used to carry address of the device to which microprocessor wants to
interact. For example, if a microprocessor has to retrieve the contents of a memory
location whose address is 3000H then it willtrarsihit the address, 3000H on the
address bus. This address is received by all the devices connected to it but only
the device whose address is on address bus responds.
Data Bus
This bus is used to transmit data from one device to another and vice versa. For
example, the contents of the above addressed memory location will be sent to the
processor via data bus. Similarly data from memory may be transmited to output
unit on the same bus.
Control Bus
ToSoo'
This bus is used to transmit and receive control signals between the microprocessor
and various devices attached to itJFor example when ALUhas finished a particular
computations it sends a contol signal to the microprocessor to tell this fact.
Width
Pardt
(The width of a bus is defined as the no. of wires that constitutes it)8-bjt
microprocessor has bit-wide data bus. This means that 8 bits of information can
be transmitted in parallel over the data bus.
Calcu lae
The width of the address bus can be used to compute the totalamount of memory
that can be directly accessed by the processor. If width of an adders bus is 16 then
216 memory locations can be accessed by processor.
The arrangement of the three types of buses in a typical computer system is shown
in fig. 11.2
( 257]
ADDRESS BUS
Control
MEMRW y Signal - WO Read/Write
CONTROL BäS
FIGURE 11.2
Here CPU, memory chips and /O devices are connected via address bus, data
bus and a set of control signals. If it is required to read the contents of a particular
memory location,the CPUfirst sends out the address of thà location on the address
bus and a memory read control ignal on the control bus. The memory responds by
outputting the stored data. from the addressed location onto the data bus. On the
data bus, first the data i_ read from the memory into one of the registers of CPU.
and later written from the CPUto the designated /Odevice.
M.3Instruction Set
An instruction set is a collection of all the instructions a CPU can execute. Each
instruction consists of several elements. An instruction element is a unit of information
required by the CPUfor execution.
3
15
Opcode
Reference to Reference to
mode operand 1 operand 2
FIGURE 11.3
[260]
Data Processing Unit
ALU AC
To/trom MBR
main
memory
&
/O MAR CONTROL
PC IR
Devices UNIT
cONTROL SIGNALS
FIGURE 11.4
These four address instructions have become obsolete now beçause execution
of these instructions is very slow.
2. 3-address instructions :
To reduce the length of an instruction, a register called Program Counter (PC)
is used to compute the address of the next instruction. Hence a three address
instructionconsists of the following parts operation code.
[263 ]
() Operation code
() Two addresses for two operands.
(ii) Address of the memory location where the result of the operation is to be
stored.
The general form of a three address instruction is
3. 2-address instructions
An improvement over three address instructions was achieved by using two
address instructions.
in 2-address instructions both operand address are specified. The resuit is
placed in ane of the specified address. The general form of a two address
instruction is.
op-code address-1
5. 0-address instruction
The zero address instruction do not contain any operandaddress. The operand
addresses are implied. These zero address instructions are also called stack
instructions. The general form of zero address instructions is
op-code
264]
The
number of address in the instruction depends upon the register organization of
into the one of the three
thecomputer. From this point of view, most Computers fall
typesof CPU organization :-
Single accumulator organizations
(2) General register organizations
(3) Stack organization
) Single accumulator organization (1-address instruction)
Most of the instructions ofan accumulator based machine contain one operand
address. The other operand is implied and it is in the accumulator. For example,
the instruction that specifies an arithmetic addition is defined by one address
instruction
ADD X
Where Xis the address of the operand. Meaning of this instruction is
AC -AC + M[X]
M[X] symbolizes the memory word located at address X and AC is the
accumulator register.
Intel 8080.and
8085 are mainly one-address processors using a single 8-bit
accumulator.
Willpush the word al address Xto the top of the stack. Operation type instruction
do not needan address field in stack organized computers. For example the
instruction.
ADD
Pops two top operands from the stack, adds them and pushes the result back
into the stack. There is no need to specify operands with an address field
since all operands are implied to be in the stack. We willuse the symbols.
LADD, SUB, MUL and DIV for the four arithmetic operations, MOV for the
transfer operation and LOAD andSTORE for transfers to and from memory
and AC register.
Example 11.1
Compare zero, one, two and three address instructions by writing program to
complete
F= (R+ S) *(U+ V)
Solution:
() Three-Address Instructions
Ac
The program is as follows : 2 -3
ADD R1, R, S R1 -MR] + M[S]
ADD R2, Ú, V R2M[U] + M[V] PuSH, poP
MUL F, R1, R2 M[F] R1 + R2
(ii) Two-Address Instructions
The program is as follows :
MOV R1, R R1-M[R]
ADD R1, S R1 R1 + M[Sj
MOV R2, U R2 4- M[U]
ADD R2, V R2 4-R2+ M[V]
MUL R1, R2 R1 R1 * R2
MOV F, R1 MIF]R1
(266]
ACuulator
One-Address Instructions
The program iS
as follows :
LOAD R AC+ MIR]
ADD AC AC+M[S)
STORE_T M[T]e-AC
LOAD U AC MU)
ADD ACAC + M[V)
MUL "ACAÇ*M[T]
STOREF M[F]-AC
required for storing
In the above program, T is address of a temporary location
the intermediate result.
Zero Address Instructions
(iv)
The program is as follows (TOS stands for top of stack)
PUSH TOS R
PUSH TOS S
ADD TOS (R+S)
PUSH U TOSU
PUSH V TOS V
ADD TOS (U+ )
MUL TOS (R+S)*(U+V)
POP F M[F]TOS
[268]
Memory
ADD 234
Mode blt
234 Operand
AC
FIGURE11.5
Memory
ADD 234
Mode bit
234 1008
1008 Operand
AC
FIGURE11.6
( 269 ]
(vii) Relative Address Mode
this type of
Thisis also called PC(Progam Counter) addressing. Incontents
CPU inadds
given thethe
cOunter to the
contents oroftoprogram
instruction
of addressi
the ng
address
the contents given in the instruction to find the
effective address of the operand.
PC+Contents of address field
Effective address = contents of
or Relative.
A new address is generated called
For example: ADD*+100
ADD$+100
here * or $represents contents of PC and this instruction implies that add the
contents of PC tothe value given in theinstruction (100) tofind the final address
of the operand.
vi) Indexed Addressing Mode
The indexed address can be any general purpose register in the CPU. The
purpose lo
CPU design may set aside a separate set of registers for indexing
the mode the effective address is computed by adding the contents of the
address given to the contents of indexed register. This mode is generally
used for address modification in calculations.
[271]
11.9.2 Indirect Cycle
Once the instruction is fetched, the next step is to determine whether it
requires
memory reference or a register reference or it is an input/ output instruction. a
instruction can use several
However, the memory
Depending on the
reference
type of addressing the effective address (EA) addressing
of operands
calculation of effective
modes,
in the
memory are calculated. In certain cases, the address inrequire
one memory reference (for example in the case of
indirect
addressing)
to direct Such
cases a special cycle which converts all the indirect addresses
required. This cycle is termed as an indirect cycle. address is
The steps of indirect cycleare:
() transfer the address bitsof instruction to the MAR. This transfer o ,
achieved using DR only as DR and lR at this point of time Contains
value. same
MAR DR(Address)
(i) Once again a memory read operation as done in fetch cycle is performed and
the desired address of the operand is obtained in the DH. or memory bufter
register (MBR)
DR -(M)
(ii) transfer the address pat so obtained in DR as the address part of instruction
IR (Address) DR (Address)
[272]