Module-3 Basic str of computer,Machine Instruction
Module-3 Basic str of computer,Machine Instruction
MODULE – 3
Where Add is the operation code, LOCA is the Memory operand and R0 is
Register operand This instruction adds the contents of memory location LOCA
with the contents of Register R0 and the result is stored in R0 Register.
The symbolic representation of this instruction is
R0 [LOCA] + [R0]
The contents of memory location LOCA and Register R0 before and after the
execution of thisinstruction is as follows
2. MDR
It also establishes communication between Memory and the Processor.
It stores the contents of the memory location (data or operand), written into or read from
memory as shown in the figure.
3. CONTROL UNIT
It controls the data transfer operations between memory and the processor.
It controls the data transfer operations between I/O and processor.
It generates control signals for Memory and I/O devices.
4. PC (PROGRAM COUNTER)
It is a special purpose register used to hold the address of the next instruction to
be executed.
The contents of PC are incremented by 1 or 2 or 4, during the execution of current
instruction.
The contents of PC are incremented by 1 for 8 bit CPU, 2 for 16 bit CPU and for 4 for
32bit CPU.
5 GENERAL PURPOSE REGISTER / REGISTER ARRAY
The structure of register file is as shown in the figure
R0
R1
R2
.
Rn-1
a. BUS STRUCTURE
Bus is defined as set of parallel wires used for data communication between
different parts of computer. Each wire carries 1 bit of data. There are 3 types of
buses, namely
i. Address bus
ii. Data bus and
iii. Control bus.
1. Address bus :
It is unidirectional.
• The processor (CPU) sends the address of an I/O device or Memory device
by means of this bus.
2. Data bus
• It is a bidirectional bus.
• The CPU sends data from Memory to CPU and vice versa as well as from I/O
to CPU and vice versa by means of this bus
3. Control bus:
This bus carries control signals for Memory and I/O devices. It generates
control signals for Memory namely MEMRD and MEMWR and control signals
for I/O devices namely IORD and IOWR.
The structure of single bus organization is as shown in the figure
3. PERFORMANCE
The performance of a Computer System is based on hardware design of the
processor and the instruction set of the processors.
To obtain high performance of computer system it is necessary to reduce the
execution time of the processor.
Execution time: It is defined as total time required executing one complete
program.
The processing time of a program includes time taken to read inputs, display
outputs, system services, execution time etc.
The performance of the processor is inversely proportional to execution time
of the processor.
More performance = Les Execution time.
Less Performance = More Execution time.
The Performance of the Computer System is based on the following factors
1. Cache Memory
2. Processor clock
3. Basic Performance Equation
4. Instructions
5. Compiler
CACHE MEMORY: It is defined as a fast access memory located in between CPU and
Memory. It is part of the processor as shown in the fig
The processor needs more time to read the data and instructions from main
memory because main memory is away from the processor as shown in the
figure. Hence it slowdown the performance of the system.
The processor needs less time to read the data and instructions from
Cache Memory because it is part of the processor. Hence it improves the
performance of the system.
𝑆𝑃𝐸𝐶 𝑅𝑢𝑛𝑛𝑖𝑛𝑔
𝑅𝑢𝑛𝑛𝑖𝑛𝑔 𝑡𝑖𝑚𝑒 𝑜𝑓 𝑟𝑒𝑓𝑒𝑟𝑒𝑛𝑐𝑒 𝐶𝑜𝑚𝑝𝑢𝑡𝑒𝑟
= 𝑡𝑖𝑚𝑒 𝑜𝑓 𝑐𝑜𝑚𝑝𝑢𝑡𝑒𝑟 𝑢𝑛𝑑𝑒𝑟 𝑡𝑒𝑠𝑡
MULTIPROCESSOR MULTICOMPUTER
1. It is a process of interconnection of two or It is a process of interconnection of two or
more processors by means of system bus. more computers by means of system bus.
2. It uses common memory to hold the data It has its own memory to store data and
and instructions. instructions.
3. Complexity in hardware design. Not much complexity in hardware design.
4. Difficult to program for multiprocessor Easy to program for multiprocessor system
system.
Digital Design &Computer Organization (Bcs302) Module 3
Chapter 02
Machine instruction and programs:
2.2 Memory Locations And Addresses
2.3 Memory Operations
2.3 Instruction And Instruction Sequencing
2.4 Addressing Modes
2.2 MEMORY LOCATIONS AND ADDRESSES
1. Memory is a storage device. It is used to store character operands, data operands and
instructions.
2. It consists of number of semiconductor cells and each cell holds 1 bit of information. A
group of 8 bits is called as byte and a group of 16 or 32 or 64 bits is called as word.
World length = 16 for 16 bit CPU and World length = 32 for 32 bit CPU. Word length is defined
as number of bits in a word.
Memory is organized in terms of bytes or words.
The organization of memory for 32
bit processor is as shown in the fig.
The contents of memory location can be accessed for read and write operation. The memory is
accessed either by specifying address of the memory location or by name of the memory location.
BYTE ADDRESSABILITY
Each byte of the memory are addressed, this addressing used in most
computers are called byte addressability. Hence Byte Addressability is the
process of assignment of address to successive bytes of the memory. The
successive bytes have the addresses 1, 2, 3, 4….....................................2n-1.
The
memory is accessed in words.
In a 32 bit machine, each word is 32 bit and the successive addresses are 0,4,8,12,… and
so on.
Address 32 – bit word
Bigendian -
1000 J O H N
1000 1001 1002 1003
1004 S E N A
1004 1005 1006 1007
Little endian -
1000 J O H N
1003 1002 1001 1000
1004 S E N A
1007 1006 1005 1004
WORD ALLIGNMENT
16 bit
Word 32 bit
size 64 bit
Digital Design &Computer Organization (Bcs302) Module 3
The structure of memory for 16 bit CPU, 32 bit CPU and 64 bit CPU are as
shown in the figures1,2 and 3 respectively
The character occupies 1 byte of memory and hence byte address for
memory. The numbers occupies 2 bytes(word) of memory and hence word
address for numbers.
2.3 MEMORY OPERATION
Both program instructions and operands are in memory. To execute each
instruction has to be read from memory and after execution the results must be
written to memory. Thereare two types of memory operations namely 1. Memory
read and 2. Memory write
Memory read operation [ Load/ Read / Fetch ]
Memory write operation [ Store/ write ]
Memory
Accumulator 32 bits
5000
5004
32 bits
5008
5012
5016
5020
Digital Design &Computer Organization (Bcs302) Module 3
(1) The processor loads MAR (Memory Address Register) with the address of the memory
location.
(2) The Control unit of processor issues memory read control signal to enable the memory
component for read operation.
(3) The processor reads the data from memory into the Accumulator by means of bi-directional
data bus.
It is the process of transferring the 1 word of data from Accumulator into the Memory.
The Memory write operation can be implemented by means of STORE instruction.
The STORE instruction transfers 1 word of data from Accumulator into the Memory
location as shown in the fig.
Accumulator
5000
5004
32 bits
5008
5012
5016
5020
32 bits
Steps for Memory Write Operation
The processor loads MAR with the address of the Memory location.
The Control Unit issues the Memory Write control signal.
The processor transfers 1 word of data from the Accumulator into the
Memory locationby means of bi-directional data bus.
2.4 COMPUTER OPERATIONS (OR) INSTRUCTIONSAND
INSTRUCTION SEQUENCING
The Computer is designed to perform 4 types of operations, namely
Data transfer operations
ALU Operations
I/O Operations.
Program sequencing and control.
Digital Design &Computer Organization (Bcs302) Module 3
2. ALU Operations
3. R2 ← [LOC]
4. R3 ←[R1]+[R2]
5. R3 ←[R1]-[R2]
Digital Design &Computer Organization (Bcs302) Module 3
ASSEMBLY LANGUAGE NOTATION
• Represent machine instructions and programs.
• These Notations use assembly language formats. Register names, names of
memory locations same as register notation.
• Move R2, R1
R1←[R2]
Contains Operaion, Source, Destination.
Consider the second statement to add data between two registers
“Add the contents of R0 with the contents of R1 and result is stored in R2”
The assembly language notation of this statement is given by
ADD R0 , R1, R2
Opcode source1, Source2, Destination
This instruction adds the contents of R0 with the contents of R1 and result is
stored in R2.
The mathematical representation of this statement is given by
R2 ←[R0] + [R1].
Such a notations are called as “Assembly Language Notations”
Destination ← [source-1]+[source-2]
Ex: ADD A, B, Z
Z ← [A] + [B]
b) Two address instruction format : Its format is as follows
MOV A, R0
MOV B, R1
ADD R0, R1
MOV R1, Z
opcode Operand
Ex1: LOAD B
This instruction copies the contents of memory location whose symbolic
name is given by ‘B’ into the Accumulator as shown in the figure.
The mathematical representation of this instruction is as followsACC ← [B]
Accumulator Memory
Ex2: STORE B
This instruction copies the contents of Accumulator into memory location
whose symbolic name is given by ‘B’ as shown in the figure. The mathematical
representation is as follows B ← [ACC].
Accumulator Memory
Ex3: ADD B
This instruction adds the contents of Accumulator with the
contents of Memorylocation ‘B’ and result is stored in Accumulator.
The mathematical representation of this instruction
is as followsACC ←[ACC]+ [B]
INSTRUCTION EXECUTION
There are 4 steps for instruction execution
1. Fetch the instruction from memory into the Instruction Register (IR) whose
addressis stored in PC.
IR ← [PC]
2. Decode the instruction.
3. Perform the operation according to the opcode of an instruction
BRANCHING
Suppose a list of ‘N’ numbers have to be added. Instead of adding one after the
other, the add statement can be put in a loop. The loop is a straight-line of
instructions executed as many times as needed.
The PC value is set to LOOP, if the previous statement value is >0 ie. after
decrementing R1 valueis greater than 0.
C V Z N
1 N (NEGATIVE) Flag:
It is designed to differentiate between positive and negative
result.It is set 1 if the result is negative, and set to 0 if result is
positive.
2 Z (ZERO) Flag:
It is set to 1 when the result of an ALU operation is found to zero,
otherwise it is cleared.
3 V (OVER FLOW) Flag:
In case of 2s Complement number system n-bit number is capable of representing
a range of numbers and is given by -2 n-1 to +2n-1. . The Over-Flow flag is set to 1 if
the resultis found to be out of this range.
4 C (CARRY) Flag :
This flag is set to 1 if there is a carry from addition or borrow from subtraction, otherwise
it is cleared.
a) Register Addressing
b) Direct Addressing
c) Immediate Addressing
d) Indirect Addressing
e) Index Addressing
f) Relative Addressing
g) Auto Increment Addressing
h) Auto Decrement Addressing
21
Digital Design &Computer Organization (Bcs302) Module 3
a. REGISTER ADDRESSING:
In this mode operands are stored in the registers of CPU. The name of the
register is directly specified in the instruction.
Ex: MOVE R1,R2 Where R1 and R2 are the Source and Destination registers
respectively. This instruction transfers 32 bits of data from R1 registerinto R2
register. This instruction does not refer memory for operands. The operands are
directly available in the registers.
b. DIRECT ADDRESSING
It is also called as Absolute Addressing Mode. In this addressing mode operands
are stored in thememory locations. The name of the memory location is directly
specified in the instruction.
Ex: MOVE LOC, R1 : Where LOC is the memory location and R1 is the
Register.This instruction transfers 32 bits of data from memory location X
into the General PurposeRegister R1.
c. IMMEDIATE ADDRESSING
In this Addressing Mode operands are directly specified in the instruction. The
source field is usedto represent the operands. The operands are represented by
# (hash) sign.
EX:MOVE #23,R0
22
Digital Design &Computer Organization (Bcs302) Module 3
d. INDIRECT ADDRESSING
In this Addressing Mode effective address of an operand is stored in the memory location or
General Purpose Register.
23
Digital Design &Computer Organization (Bcs302) Module 3
This instruction adds the data from the memory location whose address is stored in ‘X’memory
location with the contents of R0 and result is stored in R0 register.
24
Digital Design &Computer Organization (Bcs302) Module 3
This instruction adds the contents of memory location whose EA is the sum of contents of R1
with 20 and with the contents of R2 and result is placed in R2 register. The diagrammatic representation of t
Ex: ADD 1000(R1) , R2 R1 holds the offset address of an operand.The EA of an operand is given
by EA = 1000 + [R1]
This instruction adds the data from the memory location whose address is given by [1000 +
[R1] with the contents of R2 and result is placed in R2 register.
25
Digital Design &Computer Organization (Bcs302) Module 3
The symbolic representation of this mode is X (PC).Where X is the offset value and PC is theProgram
Counter to store the address of the next instruction to be executed.
It can be represented as
EA of an operand = X + (PC).
This Addressing Mode is useful to calculate the EA of the target memory location.
26
Digital Design &Computer Organization (Bcs302) Module 3
g. AUTO INCREMENT ADDRESSING MODE
In this Addressing Mode , EA of an operand is stored in the one of the GPRs of the CPU.
This Addressing Mode increment the contents of memory register by 4 memory locations after
Operand access.
The symbolic representation is
(RI)+ Where Ri is the one of the GPR.
27