COA Unit-3
COA Unit-3
Computer Instructions
An instruction details the CPU of "What to Execute?", "Where to Execute?" and "How
to Execute?".
Task to be performed, called the operation code (Opcode), and the data
to be operated upon, called the operand.
The operands include the input data of the operation and the results
that are produced.
Types of Instructions in Computer Architecture
A computer’s instructions can be any length and have any number of addresses. The
arrangement of a computer’s registers determines the different address fields in the
instruction format.
The instruction can be classified as three, two, and one address instruction or zero
address instruction, depending on the number of address fields.
PUSH B TOP = B
PUSH C TOP = C
PUSH D TOP = D
Expression: X = (A+B)*(C+D)
Postfixed : X = AB+CD+*
TOP means top of stack
M[X] is any memory location
One Address Instructions
These instructions specify one operand or address, which typically refers to a memory
location or register. The instruction operates on the contents of that operand, and the
result may be stored in the same or a different location.
This uses an implied ACCUMULATOR register for data manipulation. One operand is in
the accumulator and the other is in the register or memory location. Implied means that
the CPU already knows that one operand is in the accumulator so there is no need to
specify it.
Expression: X = (A+B)*(C+D)
AC is accumulator
M[ ] 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
Two Address Instructions
These instructions specify two operands or addresses, which may be memory locations
or registers. The instruction operates on the contents of both operands, and the result
may be stored in the same or a different location.
For example, a two-address instruction might add the contents of two registers together
and store the result in one of the registers.
Expression: X = (A+B)*(C+D)
R1, R2 are registers
M[ ] is any memory location
These instructions specify three operands or addresses, which may be memory locations
or registers. The instruction operates on the contents of all three operands, and the result
may be stored in the same or a different location. For example, a three-address instruction
might multiply the contents of two registers together and add the contents of a third
register, storing the result in a fourth register.
Expression: X = (A+B)*(C+D)
R1, R2 are registers
M[] is any memory location
The execution instructions define the instruction cycle. This is the thorough methodology computer
processors use for executing a given instruction.
Every processor shows a three-step instruction cycle. These three steps of the instruction execution
cycle are,
1.Fetch:
The processor copies the instruction data captured from the RAM.
2. Decode:
Decoded captured data is transferred to the unit for execution.
3. Execute:
Instruction is finally executed. The result is then registered in the processor or RAM (memory
address).
Registers Involved In Each Instruction Cycle:
Step 1: The address in the program counter is transferred to the Memory Address Register(MAR), as
this is the only register that is connected to the system bus address lines.
Step 2: The address in MAR is put on the address bus, now a Read order is provided by the control
unit on the control bus, and the result appears on the data bus and is then copied into the memory
buffer register. Program counter is incremented by one, to get ready for the next instruction. These
two acts can be carried out concurrently to save time.
Step 3: The content of the MBR is moved to the instruction register(IR).
T1: MAR PC
T2: MBR memory
PC PC + stepsize or length of instruction
T3: IR MBR
Decode instruction cycle:
The next move is to fetch source operands once an instruction is fetched. Indirect addressing (it
can be obtained by any addressing mode, here it is done by indirect addressing) is obtained by
Source Operand. You don't need to fetch register-based operands. If the opcode is executed, it will
require a similar process to store the result in main memory.
Step 1: The instruction address field is passed to the MAR. This is used to fetch the operand's
address.
Step 2: The address field of the IR is updated from the MBR.
Step 3: The IR is now in the state. Now IR is ready for the execute cycle.
Execute instruction Cycle
The initial cycles are predictable and quick. Each requires simple , small, and fixed micro-operation
sequences. The same micro-operation is repeated every time around in each event. Execute
instruction cycle is different from them. Like, there is N different series of micro-operations that
can occur for a computer with different N opcodes.
Example:
ADD R , X
1. Register transfer micro-operations: These type of micro operations are used to transfer binary
information from one register to another.
3. Logic micro-operations: These micro operations are used to perform bit style operations /
manipulations on non numeric data.
4. Shift micro operations: As their name suggests they are used to perform shift operations in
data store in registers.
1. Register transfer micro-operations
• Information transfer from one register to another is designated in symbolic form by means of a replacement
operator.
• The statement R2← R1 denotes a transfer of the content of register R1 into register R2. It designates a
replacement of the content of R2 by the content of R1. By definition, the content of the source register R 1
does not change after the transfer.
• If we want the transfer to occur only under a predetermined control condition then it can be shown by an if-
then statement.
if (P=1) then R2← R1
P is the control signal generated by a control section.
• We can separate the control variables from the register transfer operation by specifying a Control Function.
Control function is a Boolean variable that is equal to 0 or 1. Control function is included in the statement as
P: R2← R1
Control condition is terminated by a colon implies transfer operation be executed by the hardware only if P=1.
The letter n will be used to indicate any number of bits for the register. It will be replaced by an actual number
when the length of the register is known. Register R2 has a load input that is activated by the control variable P.
2. Arithmetic micro-operations
The basic arithmetic micro-operations are
• Addition
R3 ← R1 + R2
It states that the contents of R1 are added to contents of R2 and sum is transferred to R3.
To implement this statement hardware requires 3 registers and digital component that performs
addition
• Subtraction
Subtraction is most often implemented through complementation and addition.
The subtract operation is specified by the following statement
R3 ← R1 + R2 + 1
Adding the contents of R1 to the 2's complement of R2 is equivalent to R1-R2.
• Increment
D=A+1
Firstly we have a direct transfer from input A to output D, then the value of A is incremented by 1.
• Decrement:
D = A -1 + 1=A, which causes a direct transfer from input A to output D.
3. Logic micro-operations
Logic microoperations specify binary operations for strings of bits stored in registers.
These operations consider each bit of the register separately and treat them as binary variables.
For example, the exclusive-OR microoperation with the contents of two registers R1 and R2 is symbolized by the statement
It specifies a logic microoperation to be executed on the individual bits of the registers provided that the control variable P = 1.
For example, the content of R1 is 1010 and content of R2 is 1100. The logic computation :
1 0 1 0 content of R1
1 1 0 0 content of R2
0 1 1 0 content of R1 after P = 1
There are 16 different logic operations that can be performed with two binary variables.
Shift Microoperations:
➢ Shift microoperations are used for serial transfer of data.
➢ The contents of a register can be shifted to the left or the right.
➢ During a shift-left operation the serial input transfers a bit into the rightmost position.
➢ During a shift-right operation the serial input transfers a bit into the leftmost position.
➢ There are three types of shifts: logical, circular, and arithmetic.
➢ The symbolic notation for the shift microoperations is shown in Table
PROGRAM CONTROL
The change in the content of the program counter can cause an interrupt/break in the instruction execution. However, the
program control instructions control the flow of program execution and are capable of branching to different program
segments.
RISC and CISC are two different types of computer architectures that are used to design the
microprocessors that are found in computers. The fundamental difference between RISC and
CISC is that RISC (Reduced Instruction Set Computer) includes simple instructions and
takes one cycle, while the CISC (Complex Instruction Set Computer) includes complex
instructions and takes multiple cycles.
The CISC processor architecture comprises a complex instruction set. A CISC processor has a
variable-length instruction format. In this processor architecture, the instructions that require
register operands can take only two bytes.
In a CISC processor architecture, the instructions which require two memory addresses can take
five bytes to comprise the complete instruction code. Therefore, in a CISC processor, the execution
of instructions may take a varying number of clock cycles. The CISC processor also provides direct
manipulation of operands that are stored in the memory.
Characteristics of a CISC processor architecture
Create a pipeline
The processor creates a pipeline, which is a logical structure of stages connected to each
other. Instructions enter the pipeline from one end and exit from the other.
Execute instructions
The processor executes instructions in an orderly, somewhat overlapped manner. Different
stages of instruction processing, such as fetching, decoding, executing, and writing back,
occur simultaneously across different instructions.
ETpipeline = k + n – 1 cycles
= (k + n – 1)Tp
In the same case, for a non-pipelined processor, the execution time of ‘n’ instructions will be:
ETnon-pipeline = n * k * Tp
Speedup (S) of the pipelined processor over the non-pipelined processor, when ‘n’ tasks are
executed on the same processor is:
S = Performance of non-pipelined processor /
Performance of pipelined processor
Types of pipelines
There are two types of pipelines in computer processing.
Instruction pipeline
The instruction pipeline represents the stages in which an instruction is moved through the various segments of the
processor, starting from fetching and then buffering, decoding and executing. One segment reads instructions from the
memory, while, simultaneously, previous instructions are executed in other segments. Since these processes happen in an
overlapping manner, the throughput of the entire system increases. The pipeline's efficiency can be further increased by
dividing the instruction cycle into equal-duration segments.
Arithmetic pipeline
The arithmetic pipeline represents the parts of an arithmetic operation that can be broken down and overlapped as they are
performed. It can be used for arithmetic operations, such as floating-point operations, multiplication of fixed-point numbers,
etc. Registers are used to store any intermediate results that are then passed on to the next stage for further processing.