COA Unit-2
COA Unit-2
(CS304PC)
D.Koteshwar Rao
Assistant Professor,
Department of ECE
Unit-2
Microprogrammed Control
Control Memory
The function of the control unit in a digital computer is to
initiate sequences of microoperations.
When the control signals are generated by hardware, the
control unit is said to be hardwired.
Microprogramming is a second alternative for designing
the control unit of a digital computer. The principle of
microprogramming is controlling the microoperation
sequences in a digital computer. The control unit initiates a
series of sequential steps of microoperations.
Control Memory
The control variables at any given time can be represented
by a string of l's and 0's called a control word. control
words can be programmed to perform various operations on
the components of the system.
A control unit whose binary control variables are stored in
memory is called a Microprogrammed control unit. Each
word in control memory contains a microinstruction.
Microinstruction specifies one or more microoperations
for the system.
A sequence of microinstructions constitutes a
microprogram.
Control Memory
A memory that is part of a control unit is referred to as a
control memory. Alterations of the microprogram are not
needed once the control unit is in operation, the control
memory can be a read-only memory (ROM).
The content of the words in ROM are fixed and cannot be
altered by simple programming since no writing capability
is available in the ROM.
ROM words are made permanent during the hardware
production of the unit.
Control Memory
A computer that employs a microprogrammed control unit
will have two separate memories: a main memory and a
control memory.
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. Main memory consists of machine instructions
and data
Control Memory
Control memory holds a fixed microprogram that cannot be
altered by the user.
Microprogram consists of microinstructions that specify
various internal control signals for execution of register
microoperations. Each machine instruction initiates a series
of microinstructions in control memory.
These microinstructions generate the microoperations to
fetch the instruction from main memory, to evaluate the
effective address, to execute the operation specified by the
instruction.
Control Memory
The general configuration of a microprogrammed control unit
is demonstrated in the following block diagram.
2000
Stack grows
in this
direction
DR
Stack Organization
Memory stack
Figure shows a portion of computer memory partitioned into
three segments: program, data, and stack.
The program counter PC points at the address of the next
instruction in the program. The address register AR points at
an array of data.
Stack pointer SP points at the top of the stack. The three
registers are connected to a common address bus and either
one can provide an address for memory. PC is used during the
fetch phase to read an instruction. AR is used during the
execute phase to read an operand. SP is used to push or pop
items into or from the stack.
Stack Organization
Memory stack
A new item is inserted with the push operation as follows:
SP SP - 1
M[SP] DR
A new item is deleted with a pop operation as follows:
DR M[SP]
SP SP + 1
Stack Organization
Reverse Polish Notation
Consider the simple arithmetic expression A*B+C*D
The Polish mathematician Lukasiewicz showed that arithmetic
expressions can be represented in prefix or polish notation, places
the operator before the operands.
The postfix notation, referred to as Reverse Polish notation (RPN),
places the operator after the operands.
The following examples demonstrate the three representations:
A + B Infix notation
+ AB Prefix or Polish notation
AB + Postfix or reverse Polish notation
The expression is written in reverse Polish notation as AB * CD *
+
In reverse polish notation ,
34*56*+
There are two modes that need no address field at all. These
are the implied and immediate modes.
Addressing Modes
Implied Mode:
In this mode, the operands are specified implicitly in the
definition of the instruction.
For example, the instruction "complement accumulator” is
an implied-mode instruction because the operand in the
accumulator register is implied in the definition of the
instruction.
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.
Addressing Modes
Immediate Mode:
In this mode, the operand is specified in the instruction itself.
In other words, an immediate-mode instruction has an
operand field rather than an address field.
Register Mode:
In this mode, the operands are in registers that reside within
the CPU.
A particular register is selected from a register field in the
instruction. k-bit field can specify any one of 2k registers.
Addressing Modes
Register Indirect Mode:
In this mode, the instruction specifies a register in the CPU
whose contents give the address of the operand in memory.
In other words, the selected register contains the address of
the operand rather than the operand itself.
The advantage of a register indirect mode instruction is that
the address field of the instruction uses fewer bits to select a
register than would have been required to specify a memory
address directly.
Addressing Modes
Autoincrement or Autodecrement Mode:
This is similar to the register indirect mode except that the
register is incremented or decremented after or before its value
is used to access memory.
Direct Address Mode:
In this 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.
Indirect Address Mode:
In this 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.
Addressing Modes
Relative Address Mode:
In this mode, the 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 (in
2's complement representation) which can be either positive or
negative. When this number is added to the content of the program
counter, the result produces an effective address.
Indexed Addressing Mode:
In this mode, the 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
Addressing Modes
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.
This is similar to the indexed addressing mode except that the
register is now called a base register instead of an index
register.
An index register is assumed to hold an index number that is
relative to the address part of the instruction.
A base register is assumed to hold a base address and the
address field of the instruction gives a displacement relative
to this base address.
Addressing Modes
Numerical Example:
Addressing Modes
Numerical Example:
Data Transfer and Manipulation
Most computer instructions can be classified into three
categories:
1. Data transfer instructions
2. Data manipulation instructions
3. Program control instructions
Data transfer instructions cause transfer of data from one
location to another without changing the binary information
content.
Data manipulation instructions are those that perform
arithmetic, logic and shift operations.
Program control instructions provide decision-making
capabilities and change the path taken by the program when
executed in the computer.
Data Transfer Instructions
Data transfer instructions move data from one place in the
computer to another without changing the data content.
The most common transfers are between memory and
processor registers, between processor registers and input or
output, and between the processor registers themselves.
Table gives a list of eight data transfer instructions used in
many computers.
Data Transfer Instructions
LOAD instruction designates a transfer from memory to a
processor register, usually an accumulator.
STORE instruction designates a transfer from a processor
register into memory.
MOVE instruction designate a transfer from one register to
another.
EXCHANGE instruction swaps information between two
registers or a register and a memory word.
INPUT and OUTPUT instructions transfer data among
processor registers and input or output terminals.
PUSH and POP instructions transfer data between processor
registers and a memory stack.
Data Transfer Instructions
Data Transfer Instructions
Table shows the recommended assembly language
convention and the actual transfer accomplished in each case.
Load instruction can occur with eight different addressing
modes.
ADR stands for an address, NBR is a number or operand, X is
an index register, R1 is a processor register and AC is the
accumulator register.
Data Transfer Instructions
@ character symbolizes an indirect address. $ character
before an address makes the address relative to the program
counter PC. # character precedes the operand in an
immediate-mode instruction. An indexed mode instruction is
recognized by a register that is placed in parentheses after the
symbolic address.
The register mode is symbolized by giving the name of a
processor register. In the register indirect mode, the name of
the register that holds the memory address is enclosed in
parentheses.
Autoincrement mode is distinguished from the register
indirect mode by placing a plus after the parenthesized
register. Autodecrement mode would use a minus instead.
Data Manipulation Instructions
Data manipulation instructions perform operations on data.
Data manipulation instructions in a typical computer are
usually divided into three basic types:
1. Arithmetic instructions
2. Logical and bit manipulation instructions
3. Shift instructions
Data Manipulation Instructions
Data Manipulation Instructions
The four basic arithmetic operations are addition, subtraction,
multiplication and division. A list of typical arithmetic
instructions is given in Table.
The increment instruction adds 1 to the value stored in a
register or memory word.
The instruction "add with carry" performs the addition on two
operands plus the value of the carry from the previous
computation.
Similarly, the "subtract with borrow" instruction subtracts
two words and a borrow which may have resulted from a
previous subtract operation.
The negate instruction forms the 2' s complement of a
number.
Data Manipulation Instructions
Data Manipulation Instructions
Individual bits such as a carry can be cleared, set or
complemented with appropriate instructions.
Another example is a flip-flop that controls the interrupt
facility and is either enabled or disabled by means of bit
manipulation instructions.
Data Manipulation Instructions
Data Manipulation Instructions
Individual Shifts are operations in which the bits of a word
are moved to the left or right.
The bit shifted in at the end of the word determines the type
of shift used.
Shift instructions may specify either logical shifts, arithmetic
shifts or rotate-type operations.
The rotate through carry instruction treats a carry bit as an
extension of the register whose word is being rotated.
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.
Program Control
A program control type of instruction when executed, may
change the address value in the program counter and cause
the flow of control to be altered. In other words, program
control instructions specify conditions for altering the content
of the program counter, while data transfer and manipulation
instructions specify conditions for data-processing operations.
The change in value of the program counter as a result of the
execution of a program control instruction causes a break in
the sequence of instruction execution.
This is an important feature in digital computers as it provides
control over the flow of program execution and a capability
for branching to different program segments.
Program Control
Program Control
Some typical program control instructions are listed in Table.
Branch and jump instructions are used interchangeably to mean the
same thing but sometimes they are used to denote different
addressing modes.
Branch instruction causes a transfer of the value of ADR into the
program counter. Branch and jump instructions may be conditional
or unconditional.
The skip instruction does not need an address field and is therefore
a zero-address instruction.
The call and return instructions are used in conjunction with
subroutines.
Compare instruction performs a subtraction between two operands.
Test instruction performs the logical AND of two operands.