Professional Documents
Culture Documents
UNIT- 3
CENTRAL PROCESSING UNIT
INTRODUCTION
The part of the computer that performs the bulk of data-processing
operations is called the central processing unit and is referred to as
the CPU.
The CPU is made up of three major parts, as shown in Fig.
⚫ The register set stores intermediate data used during the execution of the
instructions.
⚫ The arithmetic logic unit (ALU) performs the required micro-operations
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.
CONTD…
The control unit that operates the CPU bus system directs the
information flow through the registers and ALU by selecting the
various components in the system. For example, to perform the
operation:
R1 ← R2 + R3
The control must provide bi9nary selection variables to the
following selector inputs:
⚫ MUX A selector (SELA): to place the content of R2 into bus A.
⚫ MUX B selector (SELB): to place the content of R3 into bus B.
⚫ ALU operation selector (OPR): to provide the arithmetic addition A +
B.
⚫ Decoder destination selector (SELD): to transfer the content of the
output bus into R1.
CONTROL WORD
There are 14 binary selection inputs in the unit, and their combined value
specifies a control word. The 14-bit control word is defined in Fig.
A new item is deleted from the stack if the stack is not empty (if pop
EMTY = 0).
The pop operation consists of the following sequence of micro-
operations:
DR←M[SP] Read item from the top of stack
SP←SP - 1 Decrement stack pointer
If (SP = 0) then (EMTY ←1) Check if stack is empty
FULL ← 0 Mark the stack not full
MEMORY STACK
The implementation of a stack in
the CPU is done by assigning a
portion of memory to a stack
operation and using a processor
register as a stack pointer.
Following 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.
The stack pointer SP points at the
top of the stack.
CONTD…
We assume that the items in the stack communicate with a data register
DR. A new item is inserted with the push operation as follows:
SP←SP- 1
M[SP]←DR
The stack pointer is decremented so that it points at the address of the next
word. A memory write operation inserts the word from DR into the top of
the stack. A new item is deleted with a pop operation as follows:
DR←M[SP]
SP←SP + 1
The top item is read from the stack into DR. The stack pointer is then
incremented to point at the next item in the stack.
The advantage of a memory stack is that the CPU can refer to it without
having to specify an address, since the address is always available and
automatically updated in the stack pointer.
REVERSE POLISH NOTATION
AB*CD--EF+/
EVALUATION OF ARITHMETIC EXPRESSIONS
The instruction
ADD
In a stack computer consists of an operation code 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.
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 Rl, A, B R1←M[A]+M[B]
ADD R2, C, D R2←M[C]+M[D]
MUL X, Rl, R2 M[X]←R1*R2
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.
It is assumed that the computer has two processor registers, Rl and
R2. The symbol M[A] denotes the operand at memory address
symbolized by A.
CONTD…
The mode field is used to locate the operands needed for the
operation.
The different types of modes are:
⚫ Implied mode
⚫ Immediate mode
⚫ Register mode
⚫ Register Indirect mode
⚫ Auto increment or Auto decrement mode
⚫ Direct Address mode
⚫ Indirect Address mode
⚫ Relative Address mode
⚫ Indexed Address mode
⚫ Basic Register Addressing mode
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.
In fact, all register reference instructions that use an accumulator are
implied-mode instructions.
For example-
CMA: Take complement of content of AC
Similarly, the instruction,
RLC: Rotate the content of Accumulator is an implied mode
instruction.
IMMEDIATE MODE
In Immediate Addressing Mode operand is specified in the
instruction itself.
In other words, an immediate mode instruction has an operand field
rather than an address field, which contain actual operand to be used
in conjunction with the operand specified in the instruction
As an example: The Instruction:
MVI 06 Move 06 to the accumulator
ADD 05 ADD 05 to the content of accumulator
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.
These modes are required because when the address stored in
register refers to a table of data in memory, then it is necessary to
increment or decrement the register after every access to table so
that next value is accessed from memory. Thus, these addressing
modes are common requirements in computer.
Now, we will discuss each separately in detail.
Auto-increment Addressing Mode:
Auto-increment Addressing Mode are similar to Register Indirect Addressing
Mode except that the register is incremented after its value is loaded (or
accessed) at another location like accumulator(AC).
That is, in this case also, the Effective Address is equal to
EA=(R). But, after accessing operand, register is incremented by 1.
Auto-decrement Addressing Mode:
Auto-decrement Addressing Mode is reverse of auto-increment , as
in it the register is decrement before the execution of the instruction.
That is, in this case, effective address is equal to EA=(R) - 1
The effective address is defined to be the memory address obtained
from the computation dictated by the given addressing mode.
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.
A few addressing modes require that the address field of the instruction be added to the
content of a specific register in the CPU.
The effective address in these modes is obtained from the following computation:
effective address = address part of instruction + content of CPU register
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.
Assume that PC contains the no.- 825 and the address part of
instruction contain the no.- 24, then the instruction at location 825 is
read from memory during fetch phase and the Program Counter is
then incremented by one to 826.
The effective address computation for relative address mode is
826+24=850
INDEX REGISTER ADDRESSING MODE