Notes COA Unit III (Complete)
Notes COA Unit III (Complete)
Name Mnemonic
Load LD
Store ST
Move MOV
Exchange XCH
Input IN
Output OUT
Push PUSH
Pop POP
The logical shift inserts 0 to the end bit position. The end position is the leftmost bit for shift right
and the rightmost bit position for the shift left.
The arithmetic shift-right instruction must preserve the sign bit in the leftmost position. The sign
bit is shifted to the right together with the rest of the number, but the sign bit itself remains
unchanged. This is a shift-right operation with the end bit remaining the same.
The arithmetic shift-left instruction inserts 0 to the end position and is identical to the logical shift-
left instruction.
The rotate instructions produce a circular shift. Bits shifted out at one end of the word are not lost
as in a logical shift but are circulated back into the other end.
The rotate through carry instruction treats a carry bit as an extension of the register whose word
is being rotated. Thus a rotate-left through carry instruction transfers the carry bit into the rightmost
bit position of the register, transfers the leftmost bit position into the carry, and at the same time,
shifts the entire register to the left.
The arithmetic shift-left inserts a 0 into R0, and shifts all other bits to the left. The initial bit of Rn-1
is lost and replaced by the bit from Rn-2. A sign reversal occurs if the bit in Rn-1 changes in value
after the shift. This happens if the multiplication by 2 causes an overflow. An overflow occurs after
an arithmetic shift left if initially, before the shift, Rn-1 is not equal to Rn-2. An overflow flip-flop V,
can be used to detect an arithmetic shift-left overflow.
If Vs = 0, there is no overflow, but if Vs = 1, there is an overflow and a sign reversal after the shift.
Vs must be transferred into the overflow flip-flop with the same clock pulse that shifts the register.
Example
An 8-bit register contains the binary value 10011100. What is the register value after an arithmetic
shift right? Starting from the initial number 10011100, determine the register value after an
arithmetic shift left, and state whether there is an overflow ?
Stack organization
✓ Computers with stack organization would have PUSH and POP instructions which require an
address field. Thus the instruction
PUSH X
will push the word at address X to the top of the stack.
✓ The stack pointer is updated automatically.
✓ Operation-type instructions do not need an address field in stack-organized computers.
✓ This is because the operation is performed on the two items that are on top of the stack. The
instruction
ADD
in a stack computer consists of an operation code only with no address field.
✓ This operation has the effect of popping the two top numbers from the stack, adding the
numbers, and pushing the sum into the stack.
✓ There is no need to specify operands with an address field since all operands are implied
to be in the stack.
Example
To illustrate the influence of the number of addresses on computer programs, we will
evaluate the arithmetic statement
X = (A + B) * (C + D)
using zero, one, two, or three address instructions.
We will use the symbols ADD, SUB, MUL, and DIV for the four arithmetic operations;
MOV for the transfer-type operation; and LOAD and STORE for transfers to and from
memory and AC register.
We will assume that the operands are in memory addresses A, B, C, and D, and the
result must be stored in memory at address X.
Three-Address Instructions
Computers with three-address instruction formats can use each address
field to specify either a processor register or a memory operand.
The program in assembly language that evaluates X = (A + B) * (C + D) is shown below, together
with comments that explain the register transfer operation of each instruction.
ADD R1, A, B R1 ← M[A]+M[B]
ADD R2, C, D R2 ← M[C]+M[D]
MUL X, R1, R2 M[X] ← R1* R2
It is assumed that the computer has two processor registers, R1 and R2. The symbol M[A]
denotes the operand at memory address symbolized by A.
The advantage of the three-address format is that it results in short programs when evaluating
arithmetic expressions.
The disadvantage is that the binary-coded instructions require too many bits to specify three
addresses.
Two-Address Instructions
Two-address instructions are the most common in commercial computers. Here again each
address field can specify either a processor register or a memory word.
The program to evaluate X = (A + B) * (C + D) is as follows:
MOV R1, A R1 ← M[A]
ADD R1, B R1 ← R1 + M[B]
MOV R2, C R2 ← M[C]
ADD R2, D R2 ← R2 + M[D]
MUL R1, R2 R1 ← R1*R2
MOV X, R1 M[X] ← R1
The MOV instruction moves or transfers the operands to and from memory and processor
registers. The first symbol listed in an instruction is assumed to be both a source and the
destination where the result of the operation is transferred.
One-Address Instructions
One-address instructions use an implied accumulator(AC) register for all data manipulation.
For multiplication and division there is a need for a second register.
However, here we will neglect the second register and assume
that the AC contains the result of all operations.
The program to evaluate X = (A + B) * (C + D) is as follows
LOAD A AC ← M[A]
ADD B AC ← AC + M[B]
STORE T M[T] ← ΑC
LOAD C AC ← M[C]
ADD D AC ← AC + M[D]
MUL T AC ← AC * M[T]
STORE X M[X] ← AC
All operations are done between the AC register and a memory operand.
T is the address of a temporary memory location required for storing the intermediate result.
Zero-Address Instructions
A stack-organized computer does not use an address field for the instructions ADD and MUL.
The PUSH and POP instructions, however, need an address field to specify the operand that
communicates with the stack.
The program to evaluate X = (A + B) * (C + D) for a stack organized computer. (TOS stands
for top of stack).
PUSH A TOS ← A
PUSH B TOS ← B
ADD TOS ← (A + B)
PUSH C TOS ← C
PUSH D TOS ← D
ADD TOS ← (C + D)
MUL TOS ← (C + D)*(A + B)
POP X M[X] ← TOS
CISC Characteristics
The design of an instruction set for a computer must take into consideration not only machine
language constructs, but also the requirements imposed on the use of high-level programming
languages. The translation from high-level to machine language programs is done by means of a
compiler program.
One reason for the trend to provide a complex instruction set is the desire to simplify the
compilation and improve the overall computer performance.
The task of a compiler is to generate a sequence of machine instructions for each high-level
language statement. The task is simplified if there are machine instructions that implement the
statements directly.
The essential goal of a CISC architecture is to attempt to provide a single machine instruction for
each statement that is written in a high-level language. Examples of CISC architectures are the
Digital Equipment Corporation VAX computer and the IBM 370 computer.
Fetch Cycle
During the fetch cycle, an instruction is read from memory
1. The PC contains the address of the next instruction to be fetched.
2. This address is moved to the MAR and placed on the address bus.
3. The control unit requests a memory read, and the result is placed on the data
bus
4. and copied into the MBR and then moved to the IR.
Meanwhile, the PC is incremented by 1, preparatory for the next fetch.
Once the fetch cycle is over, the control unit examines the contents of the IR to determine if it
contains an operand specifier using indirect addressing. If so, an indirect cycle is performed
Indirect Cycle
Once the fetch cycle is over, the control unit examines the contents of the IR to determine if it
contains an operand specifier using indirect addressing. If so, an indirect cycle is performed. The
rightmost N bits of the MBR, which contain the address reference, are transferred to the MAR.
Then the control unit requests a memory read, to get the desired address of the operand into the
MBR.
Execute Cycle
The execute cycle takes many forms; the form depends on which of the various machine
instruction is in the IR. This cycle may involve transferring data among registers. read or write
from memory or I/O, and/or the invocation of the ALU.
Interrupt Cycle
The current contents of the PC must be saved so that the processor can resume normal activity
after the interrupt. Thus, the contents of the PC are transferred to the MBR to be written into
memory. The special memory location reserved for this purpose is loaded into the MAR from the
control unit. It might, for example be a stack pointer. The PC is loaded with the address of the
interrupt routine. As a result, the next instruction cycle will begin by fetching the appropriate
instruction.
Processing an Instruction
To execute a program, the processor fetches one instruction at a time and performs the operations
specified. Instructions are fetched from successive memory locations until a branch or a jump
instruction is encountered. The processor keeps track of the address of the memory location
containing the next instruction to be fetched using the program counter, PC. After fetching an
instruction, the contents of the PC are updated to point to the next instruction in the sequence. A
branch instruction may load a different value into the PC. Another key register in the processor is
the instruction register, IR. Suppose that each instruction comprises 4 bytes, and that it is stored
in one memory word.
To execute an instruction, the processor has to perform the following three steps:
➢ Fetch the contents of the memory location pointed to by the PC. The contents of this
location are loaded into the IR (fetch phase).
IR ← [[PC]]
➢ Assuming that the memory is byte addressable, increment the contents of the PC by 4
(fetch phase).
PC ← [PC] + 4
➢ Carry out the actions specified by the instruction in the IR (execution phase).
With few exceptions, an instruction can be executed by performing one or more of the
following operations in some specified sequence:
➢ Transfer a word of data from one processor register to another or to the ALU
➢ Perform an arithmetic or a logic operation and store the result in a processor
register
➢ Fetch the contents of a given memory location and load them into a processor
register
➢ Store a word of data from a processor register into a given memory location
Single Bus Organization
MAR ← [R1]
Start a Read operation on the memory bus
Wait for the MFC response from the memory
Load MDR from the memory bus
R2 ← [MDR]
MFC → Memory Function Completed
R1out, MARin
R2out, MDRin, Write
MDRoutE, WMFC
WMFC → Wait for Memory Function Completed
Execution of a Complete Instruction
Consider the instruction
Add (R3), R1
which adds the contents of a memory location pointed to by R3 to register R1.
Executing this instruction requires the following actions:
➢ Fetch the instruction
➢ Fetch the first operand (the contents of memory location pointed to by R3)
➢ Perform the addition
➢ Load the result into R1
Each suboperation is to be implemented in a segment within a pipeline. Each segment has one
or two registers and a combinational circuit as shown in Fig. R1 through R5 are registers that
receive new data with every clock pulse. The multiplier and adder are combinational circuits. The
suboperations performed in each segment of the pipeline are as follows:
The five registers are loaded with new data every clock pulse. The effect of each clock is shown
in Table . The first clock pulse transfers A1 and B1 into
The first clock pulse transfers A1 and B1 into R1 and R2. The second clock pulse transfers the
product of R1 and R2 into R3 and C1 into R4. The same clock pulse transfers A2 and B2 into R1
and R2. The third clock pulse operates on all three segments simultaneously. It places A3 and B3
into R1 and R2, transfers the product of R1 and R2 into R3, transfers C2 into R4, and places the
sum of R3 and R4 into R5. It takes three clock pulses to fill up the pipe and retrieve the first output
from R5. From there on, each clock produces a new output and moves the data one step down
the pipeline. This happens as long as new input data flow into the system. When no more input
data are available, the clock must continue until the last output emerges out of the pipeline.
Hardwired and Micro-programmed Control Unit
In a computer system, most of the tasks are controlled with the help of a processor or CPU, which
is the main component of a computer. The CPU usually has two main segments: control unit (CU)
and arithmetic and logic unit (ALU). The control unit (CU) is used to synchronize the tasks with
the help of sending timings and control signals. On the other hand, mathematical and logical
operations can be handled with the help of ALU. Micro programmed control units and hardwired
control units can be called two types of control units. We can execute an instruction with the help
of these two control units.
In the hardwired control unit, the execution of operations is much faster, but the implementation,
modification, and decoding are difficult. In contrast, implementing, modifying, decoding micro-
programmed control units is very easy. The micro-programmed control unit is also able to handle
complex instructions. With the help of control signals generated by micro-programmed and
hardwired control units, we are able to fetch and execute the instructions.
So in the micro-programmed control unit, the micro-programs are stored with the help of
Control memory or Control store. The implementation of this CU is very easy and flexible,
but it is slower as compared to the Hardwired control unit.
Hardwired vs Micro-programmed Control Unit