Coa Unit III Part II
Coa Unit III Part II
Coa Unit III Part II
2. Instruction Formats
1. An operation code field that specifies the operation to be performed.
2. An address field that designates a memory address or a processor register.
3. A mode field that specifies the way the operands or the effective address is determined.
Number of Addresses:
The division operation produces two outputs: a quotient and a remainder. Since most
operations are binary, we need a total of three addresses: two addresses to specify the two input
operands and one to specify where the result should go.
a. Three-Address Instructions:
In three-address machines, instructions carry all three addresses explicitly. The RISC
processors use three addresses. Table X1 gives some sample instructions of a three-address
machine. In these machines, the C statement X = (A + B) ∗ (C + D) is converted to the
following code:
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 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.
c. 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 and assume that the AC contains the result of tall operations.
The program to evaluate X = (A + B) ∗ (C + D) is
LOAD A AC ← M [A]
ADD B AC ← A [C] + 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
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.
d. 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 following program shows how X = (A + B) ∗ (C + D)
will be written for a stack organized computer. (TOS stands for top of stack)
PUSH A TOS ← A
PUSH B TOS ← B
EA=Not defined.
3. Register Mode
Address specified in the instruction is the register address.
- Designated operand need to be in a register
- Shorter address than the memory address
- Saving address field in the instruction
- Faster to acquire an operand than the memory addressing
EA = IR(R) (IR(R): Register field of IR)
Numerical Example:
Addressing Sequencing
Microinstructions are stored in control memory in groups, with each group specifying a
routine.
Each computer instruction has its own microprogram routine in control memory to
generate the microoperations that execute the instruction.
To appreciate the address sequencing in a microprogram control unit:
o An initial address is loaded into the control address register when power is
turned on in the computer.
Symbolic Microinstructions
The symbols defined in Table 3-1 cab be used to specify microinstructions in symbolic
form.
Symbols are used in microinstructions as in assembly language
The simplest and most straightforward way to formulate an assembly language for a
microprogram is to define symbols for each field of the microinstruction and to give
users the capability for defining their own symbolic addresses.
A symbolic microprogram can be translated into its binary equivalent by a microprogram
assembler.
Sample Format
Five fields: label; micro-ops; CD; BR; AD
The label field: may be empty or it may specify a symbolic address terminated with a
colon
The microoperations field: of one, two, or three symbols separated by commas , the
NOP symbol is used when the microinstruction has no microoperations
The CD field: one of the letters {U, I, S, Z} can be chosen where
o U: Unconditional Branch
o I: Indirect address bit
o S: Sign of AC
o Z: Zero value in AC
The BR field: contains one of the four symbols {JMP, CALL, RET, MAP}
The AD field: specifies a value for the address field of the microinstruction with one of
{Symbolic address, NEXT, empty}
o When the BR field contains a RET or MAP symbol, the AD field is left empty
Fetch Subroutine
During FETCH, Read an instruction from memory and decode the instruction and update PC.
The first 64 words are to be occupied by the routines for the 16 instructions.
The last 64 words may be used for any other purpose.
o A convenient starting location for the fetch routine is address 64.
The three microinstructions that constitute the fetch routine have been listed in three
different representations.
o The register transfer representation:
Symbolic Microprogram
Control Storage: 128 20-bit words
The first 64 words: Routines for the 16 machine instructions 0, 4, 8, …, 60 gives four
words in control memory for each routine.
The last 64 words: Used for other purpose (e.g., fetch routine and other subroutines)
The execution of the third (MAP) microinstruction in the fetch routine results in a
branch to address 0xxxx00, were xxxx are the four bits of the operation code. e.g. ADD
is 0000
In each routine we must provide microinstructions for evaluating the effective address
and for executing the instruction.
The indirect address mode is associated with all memory-reference instructions.
A saving in the number of control memory words may be achieved if the
microinstructions for the indirect address are stored as a subroutine.
This subroutine, INDRCT, is located right after the fetch routine, as shown in Table.
Mapping: OP-code XXXX into 0XXXX00, the first address for the 16 routines are 0(0
0000 00), 4(0 0001 00), 8, 12, 16, 20, ..., 60
To see how the transfer and return from the indirect subroutine occurs:
o MAP microinstruction caused a branch to address 0
o The first microinstruction in the ADD routine calls subroutine INDRCT when
I=1
o The return address is stored in the subroutine register SBR.
o The INDRCT subroutine has two microinstructions:
INDRCT: READ U JMP NEXT
DRTAR U RET
o Therefore, the memory has to be accessed to get the effective address, which is
then transferred to AR.
o The execution of the ADD instruction is carried out by the microinstructions at
addresses 1 and 2
o The first microinstruction reads the operand from memory into DR.
o The second microinstruction performs an add microoperation with the content
of DR and AC and then jumps back to the beginning of the fetch routine.
The bit values for S1 and S0 are determined from the stated function and the path in the
multiplexer that establishes the required transfer.
Note that the incrementer circuit in the sequencer diagram is not a counter constructed
with flip-flops but rather a combinational circuit constructed with gates.