Computer Organization and Architecture Unit - Ii: - K. Prashanth Asst. Professor
Computer Organization and Architecture Unit - Ii: - K. Prashanth Asst. Professor
and Architecture
UNIT -II
-K. Prashanth
Asst. Professor
UNIT – II
• Micro Programmed Control:
• Control memory
• Address sequencing
• Micro program Example
• Design of Control Unit
• Central Processing Unit:
• General Register Organization
• Instruction Formats
• Addressing Modes
• Data Transfer and Manipulation
• Program Control
Control Memory
● A computer with microprogrammed control unit will have 2
memories.
○ Main Memory.
○ Control Memory.
● The main memory is available to the user for storing the
programs.
● The contents of main memory may alter when the data are
manipulated and every time that the program is changed.
● A memory that is part of a control unit is referred to as a control
memory.
● The control memory holds a fixed microprogram that cannot be
altered by the user and contains various control signals.
● The control memory can be a read-only memory (ROM) since
alterations are not needed.
● Writable control memory is used in dynamic programing.
● The function of the control unit in a digital computer is to initiate
sequences of microoperations.
● Two methods of implementing control unit are
○ Hardwired control
○ Microprogrammed control.
● Hardwired Control
○ Design involves the use of fixed instructions, fixed logic blocks,
particular task.
● Microinstructions can be saved by employing subroutines
001 AC ← AC DR XOP
010 AC ← AC CM
101 PC ← PC 1 INCPC
110 PC ← AR ARTPC
111 Reserved
CD Conditio Symbol Comments BR Symbol Function
n
00 JMP CAR ← AD if condition = 1
00 Always 1 U Unconditional CAR ← CAR 1 if condition = 0
branch
01 CALL CAR ← AD, SBR ← CAR 1 if
01 DR(15) I Indirect condition = 1
address bit CAR ← CAR 1 if condition = 0
10 AC(15) S Sign bit of AC 10 RET CAR ← SBR (Return from
subroutine)
11 AC 0 Z Zero value in
AC 11 MAP CAR(25) ← DR(1114),
CAR(0,l,6) ← 0
• The symbols defined in above table can be
used to specify micro instructions in symbolic
form.
• A symbolic micro program can be translated
into its binary equivalent by means of an
assembler.
• Each symbolic micro instruction is divided into
five fields: Label, micro operations, CD, BR and
AD.
• The label field may be empty or it may specify a
symbolic address.
-A label is terminated with a colon (:)
• The micro operations field consists of one, two or
three symbols separated by commas.
• The CD field has one of the letters U, I, S or Z
• The BR field contains one of the 4 symbols
• The AD field specifies a value for the address field
with (i)symbolic address (ii)Next symbol (iii) RET
or MAP symbol
Micro program Example
• The micro programs specified in two ways:
1) Symbolic Micro program
2) Binary Micro program
• The symbolic microprogram is a convenient form
for writing microprograms in a way that people
can read and understand.
• The symbolic microprogram must be translated to
binary to store in the memory.
• The equivalent binary form of the symbolic
microprogram is called Binary Micro Program
Micro program Example
Label MicroOperation CD BR AD
FETCH: PCTAR U JMP NEXT
READ,INCPC U JMP NEXT
DRTAR U MAP
● The register set stores data used during the execution of the
instructions.
● ALU performs the required microoperations for executing the
instructions.
● The control unit supervises the transfer of information among the
registers and instructs the ALU as to which operation to perform.
General Register Organization
● Registers are used to store the intermediate values
during instruction execution.
● Register organization show how registers are selected
and how data flow between register and ALU.
● A decoder is used to select a particular register.
● The output of each register is connected to two
multiplexers to form the two buses A and B.
● The selection lines in each multiplexer select the input
data for the particular bus.
● The A and B buses form the two inputs of an ALU.
● The operation select lines decide the micro operation
to be performed by ALU.
● The result of the micro operation is available at the output bus.
● The output bus connected to the inputs of all registers, thus by
selecting a destination register it is possible to store the result in it.
Example : To perform R1 ← R2 + R3,
1. MUX A selector (SELA): to place the content of R2 into bus A.
2. MUX B selector (SELB): to place the content of R3 into bus B.
3. ALU operation selector (OPR): to provide the arithmetic addition A.
4. Decoder destination selector (SELD): to transfer the content of the
output bus into R1.
Control Word
● The combined value of a binary selection inputs specifies the
control word.
● It consist of four fields SELA, SELB,and SELD contains three bit each
and OPR field contains four bits thus the total bits in the control
word are 13-bits.
● The three bit of SELA select a source registers of the a input of the
ALU.
● The three bits of SELB select a source registers of the b input of the
ALU.
● The three bits of SELD select a destination register using the
decoder.
● The four bits of OPR select the operation to be performed by ALU.
Example : R2=R1+R3
Instruction Formats
● The bits of the instruction are divided into groups called fields.
1. Opcode field - specifies the operation to be performed.
2. Address field - specifies a memory address / processor register.
3. Mode field - specifies the way the operand or the effective address is
determined.
● The number of address fields depends on the internal organization
of registers.
● Three types of CPU organizations:
1. Single accumulator organization.
Eg: ADD X
2. General register organization.
Eg: ADD R1, R2, R3 - MOV R1, R2
3. Stack organization
Eg: PUSH X
● Based on these, instructions are classified into four formats.
Three-Address Instruction
● 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)
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
● Advantage - It results in short programs when
evaluating arithmetic expressions.
● Disadvantage - The binary-coded instructions require
too many bits to specify three addresses.
● Eg: Commercial computer Cyber 170.
Two-Address Instruction
● 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)
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
One-Address Instruction
● Use an implied accumulator (AC) register for all data
manipulation.
● Here we neglect the second register and assume that
the AC contains the result of all operations.
● The program to evaluate X = (A + B) * (C + D)
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
● T is the address of a temporary memory location
required for storing the intermediate result.
Zero-Address Instruction
● Used in stack-organized computers.
● The program to evaluate X = (A + B) * (C + D) for a
stack-organized computer
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
● To evaluate arithmetic expressions in a stack
computer, it is necessary to convert the expression
into reverse Polish notation.
Addressing Modes
● The operation field of an instruction specifies the operation to be
performed.
● This operation must be executed on some data stored in computer
registers or memory words.
● The way the operands are chosen during program execution is
dependent on the addressing mode of the instruction.
● The addressing mode specifies a rule for interpreting or modifying
the address field of the instruction before the operand is actually
referenced.
● Computers use addressing mode techniques for the purpose of
accommodating one or both of the following provisions:
1. To give programming versatility to the user by providing such
facilities as pointers to memory, counters for loop control, indexing
of data, and program relocation.
2. To reduce the number of bits in the addressing field of the
instruction
1. Implied Mode
● The operands are specified implicitly in the
definition of the instruction.
● Eg: CMA - Complement Accumulator.
● All register reference instructions that use an
accumulator are implied-mode instructions.
● Zero-address instructions in a stack-organized
computer are implied-mode instructions
since the operands are implied to be on top
of the stack.
2. Immediate Mode
● The operand is specified in the instruction
itself.
● I has an operand field rather than an address
field.
● The operand field contains the actual
operand to be used in conjunction with the
operation specified in the instruction.
● They are are useful for initializing registers to
a constant value.
● Eg: ADD 7
3. Register Mode
● The address field specifies a processor register.
● In this mode the operands are in registers that reside
within the CPU.
● The particular register is selected from a register field
in the instruction.
● A k-bit field can specify any one of 2k registers.
● Eg: ADD R1
4. Register Indirect Mode
● The instruction specifies a register in the CPU whose contents give the
address of the operand in memory.
● The selected register contains the address of the operand rather than the
operand itself.
● Before using a register indirect mode instruction, the programmer must
ensure that the memory address of the operand is placed in the
processor register with a previous instruction.
● Advantage - The address field of the instruction uses fewer bits to select
a register.
5. Autoincrement or Autodecrement
Mode
● Similar to the register indirect mode except
that the register is incremented or
decremented after (or before) its value is
used to access memory.
● When the address stored in the register refers
to a table of data in memory, it is necessary
to increment or decrement the register after
every access to the table.
● This can be achieved by using the increment
or decrement instruction.
6.Direct Address Mode
● The effective address is equal to the address part of the
instruction.
● The operand resides in memory and its address is given
directly by the address field of the instruction.
● In a branch-type instruction the address field specifies the
actual branch address.
7. Indirect Address Mode
● The address field of the instruction gives the address
where the effective address is stored in memory.
● Control fetches the instruction from memory and uses
its address part to access memory again to read the
effective address.
8. Relative Address Mode
● Content of the program counter is added to the address part of
the instruction in order to obtain the effective address.
● The address part of the instruction is usually a signed number
(positive or negative).
● This number is added to the content of the program counter,
producing an effective address whose position in memory is
relative to the address of the next instruction.
● It is often used with branch-type instructions.
● Example:
Let PC contains the number 825.
The address part of the instruction contains the number 24.
The instruction at location 825 is read from memory during the
fetch phase and the program counter is then incremented by one
to 826.
The effective address computation for the relative address mode is
826 + 24 = 850.
9. Indexed Addressing Mode
● Content of an index register is added to the address part
of the instruction to obtain the effective address.
● The index register is a special CPU register that contains an
index value.
● The address field of the instruction defines the beginning
address of a data array in memory.
● The distance between the beginning address and the
address of the operand is the index value stored in the
index register.
● Any operand in the array can be accessed with the same
instruction if the index register contains the correct index
value.
● The index register can be incremented to facilitate access
to consecutive operands.
10. Base Register Addressing Mode
● In this mode the content of a base register is added to the address
part of the instruction to obtain the effective address.
● Similar to the indexed addressing mode except that the register is
now called a base register.
● The difference between the two modes is in the way they are used
rather than in the way that they are computed.
● A base register holds a base address and the address field of the
instruction gives a displacement relative to this base address.
● This mode is used to facilitate the relocation of programs in
memory.
● When programs and data are moved from one segment of
memory to another, as required in multiprogramming systems, the
address values of instructions must reflect this change of position.
● Here only the value of the base register requires updating to
reflect the beginning of a new memory segment.
Data Transfer & Manipulation
3. Shift instructions.
Arithmetic Instructions
2. Arithmetic Shift
3. Rotate Shift
Logical Shift
● Inserts 0 to the end bit position.
● The end position is the leftmost bit for shift right and the rightmost bit for the shift left.
55
Arithmetic Shift
● Arithmetic Shift Right - Preserve sign bit in the left most position. Sign bit shifted to right along
with other numbers but sign bit remain unchanged.
56
Rotate Shift
● Bits are shifted out one end are not lost but circulated back into other end.
● Rotate Left Through Carry(ROLC), Rotate right through Carry (RORC) treats carry bit as an
extension of register whose word is being rotated.
57
Program Control
58
Program Control Instructions
● Program control instructions specify conditions for altering the
content of the program counter.
● Provides decision making capabilities.
● Branch (BR) : BR ADR, branch the program to Address ADR.
(PC←ADR)
● Jump (JMP)
● Skip (SKP) : Skip instruction(PC←PC + 1) if some condition is
met.
● Call (CALL) : Used with subroutines
● Return (RET)
● Compare (CMP) : Compare by subtraction.
● Test (by ANDing) TST : AND instruction without storing result.
59
END OF UNIT 2