Professional Documents
Culture Documents
UNIT3
UNIT3
micro operations for the computer. Instruction codes together with data are stored
in memory. The computer reads each instruction from memory and places it in a
control register. The control then interprets the binary code of the instruction and
proceeds to execute it by issuing a sequence of micro operations. Every computer
has its own unique instruction set
An instruction code is a group of bits that instruct the computer to perform a
specific operation. It is usually divided into parts, each having its own particular
interpretation. The most basic part of an instruction code is its operation part. The
operation code of an instruction is a group of bits that define such operations as
add, subtract, multiply, shift, and complement. The number of bits required for the
operation code of an instruction depends on the total number of operations
available in the computer
Instruction types
Data transfer instructions: Data transfer instructions perform data transfer between
the various storage places in the computer system, viz. registers, memory and I/O.
Since, both the instructions as well as data are stored in memory, the processor needs
to read the instructions and data from memory. After processing, the results must be
stored in memory. Therefore, two basic operations involving the memory are needed,
namely, Load (or Read or Fetch) and Store (or Write). The Load operation transfers a
copy of the data from the memory to the processor and the Store operation moves the
data from the processor to memory. Other data transfer instructions are needed to
transfer data from one register to another or from/to I/O devices and the processor.
Input and output instructions: Input and Output instructions are used for
transferring information between the registers, memory and the input / output devices.
It is possible to use special instructions that exclusively perform I/O transfers, or use
memory – related instructions itself to do I/O transfers.
PUSH A TOP = A
PUSH B TOP = B
PUSH C TOP = C
PUSH D TOP = D
Expression: X = (A+B)*(C+D)
AC is accumulator
M[X] is any memory location
M[T] is temporary location
LOAD A AC = M[A]
ADD B AC = AC + M[B]
STORE T M[T] = AC
LOAD C AC = M[C]
ADD D AC = AC + M[D]
MUL T AC = AC * M[T]
STORE X M[X] = AC
ADD R2, D R2 = R2 + D
MUL R1, R2 R1 = R1 * R2
MOV X, R1 M[X] = R1
Expression: X = (A+B)*(C+D)
R1, R2 are registers
M[X] is any memory location
INSTRUCTION CYCLE
Registers Involved In Each Instruction Cycle:
Memory address registers (MAR) : It is connected to the address lines of
the system bus. It specifies the address in memory for a read or write
operation.
Memory Buffer Register (MBR) : It is connected to the data lines of the
system bus. It contains the value to be stored in memory or the last value read
from the memory.
Program Counter (PC) : Holds the address of the next instruction to be
fetched.
Instruction Register (IR) : Holds the last instruction fetched.
Instruction Cycle:
The main execution process is done by the processor. The processing of instruction
involves two steps, instruction fetch and instruction execution. Each instruction is
fetched from the memory separately and executed. Depending on the nature of the
instruction its execution may deal with a number of operations.
1. The CPU sends the contents of the PC to the MAR and sends a read
command on the address bus
2. In response to the read command (with address equal to PC), the memory
returns the data stored at the memory location indicated by PC on the data
bus
3. The CPU copies the data from the data bus into its MDR (also known as
MBR; see section Role of components above)
4. A fraction of a second later, the CPU copies the data from the MDR to the
instruction register for instruction decoding
5. The PC is incremented so that it points to the next instruction. This step
prepares the CPU for the next cycle.
The control unit fetches the instruction's address from the memory unit.
Decode the Instruction
The decoding process allows the CPU to determine what instruction is to be
performed so that the CPU can tell how many operands it needs to fetch in order to
perform the instruction. The opcode fetched from the memory is decoded for the
next steps and moved to the appropriate registers. The decoding is done by
the CPU's Control Unit.
The Control Unit passes the information in the form of control signals to the
functional unit of CPU. The result generated is stored in main memory or sent to
an output device.
The cycle is then repeated by fetching the next instruction. Thus in this way the
instruction cycle is repeated continuously.
MICRO OPERATION
The operations executed on data stored in register are called as micro operations.
A micro operation is an elementary operation performed on the information stored
in one or more registers. The result of the operation may replace the previous
binary information of a register or may be transferred to another register. Examples
of micro operations are shift, count, clear and load.
Micro-operations (also known as micro-ops) are the functional or atomic,
operations of a processor. These are low level instructions used in some designs to
implement complex machine instructions. They transfer data between registers or
between external buses of the CPU, also performs arithmetic and logical operations
on registers. In executing a program, operation of a computer consists of a
sequence of instruction cycles, with one machine instruction per cycle. Each
instruction cycle is made up of a number of smaller units – Fetch, DECODE
Execute and store. Each of these cycles involves series of steps, each of which
involves the processor registers. These steps are referred as micro-operations. The
prefix micro refers to the fact that each of the step is very simple and accomplishes
very little. Figure below depicts the concept being discussed here.
Program Control Instructions are the machine codes that are used by machine or
in assembly language by user to command the processor act accordingly. These
instructions are of various types. These are used in assembly language by user also.
But in level language, user code is translated into machine code and thus
instructions are passed to instruct the processor do the task.
Types of Program Control Instructions:
There are different types of Program Control Instructions:
1. Compare Instruction:
Compare instruction is specifically provided, which is similar t a subtract
instruction except the result is not stored anywhere, but flags are set according to
the result.
Example:
CMP R1, R2 ;
2. Unconditional Branch Instruction:
It causes an unconditional change of execution sequence to a new location.
Example:
JUMP L2
Mov R3, R1 goto L2
3. Conditional Branch Instruction:
A conditional branch instruction is used to examine the values stored in the
condition code register to determine whether the specific condition exists and to
branch if it does.
Example:
Assembly Code : BE R1, R2, L1
Compiler allocates R1 for x and R2 for y
High Level Code: if (x==y) goto L1;
4. Subroutines:
A subroutine is a program fragment that lives in user space, performs a well-
defined task. It is invoked by another user program and returns control to the
calling program when finished.
Example:
CALL and RET
5. Halting Instructions:
NOP Instruction – NOP is no operation. It cause no change in the processor
state other than an advancement of the program counter. It can be used to
synchronize timing.
HALT – It brings the processor to an orderly halt, remaining in an idle state
until restarted by interrupt, trace, reset or external action.
6. Interrupt Instructions:
Interrupt is a mechanism by which an I/O or an instruction can suspend the normal
execution of processor and get itself serviced.
RESET – It reset the processor. This may include any or all setting registers
to an initial value or setting program counter to standard starting location.
TRAP – It is non-maskable edge and level triggered interrupt. TRAP has the
highest priority and vectored interrupt.
INTR – It is level triggered and maskable interrupt. It has the lowest
priority. It can be disabled by resetting the processor.
RISC
In the early 1980s, a number of computer designers recommended that
computers use fewer instructions with simple constructs so they can be
executed much faster within the CPU without having to use memory as often.
This type of computer is classified as a reduced instruction set computer or
RISC.
RISC is an abbreviation of Reduced Instruction Set Computer. RISC
processor has ‘instruction sets’ that is simple and has simple ‘addressing
modes’.
RISC Processor Architecture (Block diagram)
RISC processor is implemented using the hardwired control unit. The hardwired
control unit produces control signals which regulate the working of processors
hardware. RISC architecture emphasizes on using the registers rather than memory.
This is because the registers are the ‘fastest’ available memory source. The registers
are physically small and are placed on the same chip where the ALU and the control
unit are placed on the processor. The RISC instructions operate on the operands
present in processor’s registers.
Add R2, R3
But initially, at the start of execution of the program, all the operands are
in memory. So, to access the memory operands, the RISC instruction set
has Load and Store instruction.
The Load instruction loads the operand present in memory to the processor register.
The load instruction is of the form:
The load instruction above will load the operand present at memory location A to the
processor register R2.
The Store instruction stores the operand back to the memory. Generally, the Store
instruction is used to store the intermediate result or the final result in the memory. It
is of the form:
The Store instruction above will store the content in register R2 into the A a memory
location.
You can observe that in the example of Load and Store instruction operand side of
both instructions appears the same as R2, A. But, the source and destination order of
Store instruction is reversed in Load instruction.
RISC instruction has simple addressing modes. Below we have a list of RISC
instruction type addressing modes. Let us discuss them one by one.
Immediate addressing mode: This addressing mode explicitly specifies the operand
in the instruction. Like
The above instruction will add 200 to the content of R2 and store the result in R4.
Register addressing mode: This addressing mode describes the registers holding the
operands.
The above instruction will add the content of register R4 to the content of register R3
and store the result in R3.
Absolute addressing mode: This addressing mode describes a name for a memory
location in the instruction. It is used to declare global variables in the program.
Integer A, B, SUM;
Register Indirect addressing mode: This addressing mode describes the register
which has the address of the actual operand in the instruction. It is similar
to pointers in HLL.
This instruction will load the register R2 with the content, whose address is mentioned
in register R3.
Index addressing mode: This addressing mode provides a register in the instruction,
to which when we add a constant, obtain the address of the actual operand. It is
similar to the array of HLL.
Load R2, 4(R3)
This instruction will load the register R2 with the content present at the location
obtained by adding 4 to the content of register R3.
The control units access the control signals produced by the micro program
control unit & operate the functioning of processors hardware.
Instruction and data path fetches the opcode and operands of the instructions
from the memory.
Cache and main memory is the location where the program instructions and
operands are stored.
CISC instructions are complex in nature and occupy more than a single word in
memory. Like RISC uses Load/Store for accessing the memory operands, CISC
has Move instruction to access memory operands.
But, unlike Load and Store, the Move operation in CISC has wider scope. The
CISC instructions can “directly access memory operands”.
Move A, 100
Move R, 100
Move A, B
It can transfer the operand between two registers.
Move R1, R2
Immediate mode, direct/absolute mode, register mode, Indirect mode and Index
mode.
CISC instruction set has some additional addressing modes. Those are “auto
increment mode”, “auto decrement mode” and “relative mode”.
Here, the effective address of an operand is the content of the register. After
accessing the register’s content, it is automatically incremented to point the
memory location of next operand.
Here also, the effective address of an operand is the content of the register. But,
here initially, the content of register is decremented and then the content of register
is used as an effective address for an operand.
Relative Mode:
Now above we have mentioned that the CISC processor minimizes the number of
instructions which turns the length of code relatively shorter.
Let us see how the CISC style instructions minimize the code length?
A= B+C
Load R3, C
Store R4, A
Now, let us see the CISC instruction set for the same operation.
Move A, B
Add A, C
The objective of four RISC style instructions is fulfilled by only two instructions of
the CISC style.
CISC RISC
Some instructions with long execution No instruction with a long execution time
times. These include instructions that due to very simple instruction set. Some
copy an entire block from one part of early RISC machines did not even have an
memory to another and others that copy integer multiply instruction, requiring
CISC RISC
Example: IA32 instruction size can Example: In IA32, generally all instructions
operand specifier can have many Simple addressing formats are supported.
Arithmetic and logical operations can be i.e. reading from memory into a register and
operands. respectively.
from machine level programs. The ISA machine level programs. Few RISC
CISC RISC
The stack is being used for procedure references can be avoided by some
A hardwired circuit organization is shown in the figure below. Let us discuss all the components
one by one, in order to understand the “generation of control signals” from this circuitry
organization.
The instruction register is a processors register that has the ‘instruction’
which is currently in execution. The instruction register generates the OP-code
bits respective of the operation and the addressing modes of the operands,
mentioned in the instruction.
Instruction decoder receives the Op-code bits generated by the instruction
register and interprets the operation and addressing modes of the instruction.
Now, based on operation and addressing mode of the instruction in instruction
register it set the corresponding Instruction signal INSi to 1.
Each instruction is executed in step-like, instruction fetch, decode, operand
fetch, ALU, memory store.
Step Counter is implemented which has signals from T1, …, T5. The step counter
sets one of the signals T1 to T5 to 1 on the basis of the step, the instruction is in.
A clock is designed such that for each step the clock must complete its one clock
cycle.
So, consider if the step counter has set T3 signal 1 then after a clock cycle
completes step counter will set T4 to 1.
It also produces the control signal but using the programs. This approach was very
popular in past during the evolution of CISC architecture. The program that
creates the ‘control signals’ is called Microprogram. This micro program is
placed on the processor chip which is fast memory, it is also called control
memory or control store.
Instruction execution is performed in steps. So, for each step there is a control
word/ microinstruction in the micro program. A sequence of microinstructions
required to execute a particular instruction is called micro routine.
In the figure below, you can understand the organization of a control word/
microinstruction, microroutine and microprogram.
Now let us discuss the organization of the microprogram control unit. We will
discuss the flow of instruction execution in terms of instruction execution steps.
1. In the first step (instruction fetch) the Microinstruction address
generator would fetch the instruction from ‘instruction register’ (IR).
Mapping Logic:
An external address is transferred into control memory via a mapping logic circuit.
Incrementer:
Incrementer increments the content of the control address register by one, to select
the next micro-instruction in sequence.
Subroutine Register (SBR) :
The return address for a subroutine is stored in a special register called Subroutine
Register whose value is then used when the micro-program wishes to return from
the subroutine.
Control Memory:
Control memory is a type of memory which contains addressable storage registers.
Data is temporarily stored in control memory. Control memory can be accessed
quicker than main memory.
required. signals.
in the control field attaches to a performed and the decoder translates this
HORIZONTAL Μ-PROGRAMMED CU VERTICAL Μ-PROGRAMMED CU
Horizontal micro-programmed
Example: Consider a hypothetical Control Unit which supports 4 k words. The Hardware
contains 64 control signals and 16 Flags. What is the size of control word used in bits and control
memory in byte using:
a) Horizontal Programming
b) Vertical programming
Solution:
a) For Horizontal