Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 22

CHAPTER 4

THE PROCESSING
UNIT

CLO1 : Explain effectively computer function,


input, output and central processing unit in
computer system. (C2, PLO1)
UNDERSTAND THE CENTRAL PROCESSING UNIT (CPU)

Definition of CPU.
Central Processing Unit is referred as CPU, defined to be, the
part of the computer that do bulk of data-processing operations.

In simple word, CPU is the hardware component of the


computer that does most of the work in executing a program.

The CPU is made up from THREE (3) major parts which is:
• register set
• arithmetic-logic unit (ALU)
• control unit
Clock Unit
The clock unit controls the speed of the computer.
Types of instruction cycle
The control unit of a computer is designed to go through an instruction
divided into
cycle that is THREE (3) major Step 1 - Fetch the instruction from
phases. memory
Program Counter (or PC) keeps track of
the instructions in the program stored in
Decod memory. Program counter holds the
address of the instruction to be executed
e next and is incremented each time an
instruction is fetch
from
Step 2 - Decode the instruction
memory.
The decoding is done to determine the
operation to be performed, the addressing
Fetc Execut mode of the instruction, and the location
of the
h e operands.
Step 3 - Execute the
instruction The computer then
executes the instruction and return to
4
step 1 to fetch the next
Understand stack organization

A useful feature that is included in the CPU of most computers is a stack


or last-in, first-out (LIFO) list.
Stack is a storage device that store information in such a manner that the item
stored (in) last, is the first item retrieved (out).

The TWO (2) operation of a stack are:


1. Insertion of item (called push or push-down) because it can be thought of as the
result of pushing new item on top.
2. Deletion of item (called pop or pop-up) because it can be thought of as the
result of removing one item so that the stack pops up.

These operations are stimulated by incrementing or decrementing the stack


pointer register. (because nothing is pushed or popped in a computer stack)
Understand stack organization

• Stack is essential in a memory unit with an address register


that
• can count only (after an initial value is loaded into it).

• The register that holds the address for the stack is called a
stack pointer (SP) because its value always point at the top
item in the stack.
Note!
•The operation of the stack can be compared to a stack of
tray. The last tray placed on the top is the first taken off.

10
Function of register and
memory stack

i.Register Stack
A stack can be placed in a portion of a large memory or it
can be organized as a collection of a finite number of
memory words or registers.The stack pointer register
(SP) contains a binary number whose value is equal to the
address of the word/register that is currently on top of
the stack.

ii.Memory Stack
A stack can exist as a stand-alone unit or can be implemented
in a random-access memory attached to a CPU.The
implementation of a stack in the CPU is done by assigning a
portion of memory to a stack operation and using a processor
Computer Memory with program, data & stack
segment
The three registers are M em o ry U n it
Program 1000
connected to a common PC
(Instructions)
address bus, and either one
can provide an address for AR Data 2000
(Operands)
memory.
PC is used during the fetch
phase Stack 3000

to read instruction
AR is used during the SP
3997
3998
execute 3999

phase to read an operand 4000


4001
SP is used to push or pop
item into or from the stack. DR

SP points at the tops of the


stack
Stack Limit
Most computers do not provide hardware to check for stack
overflow
(full stack) or underflow (empty stack).

The stack limits can be check using two processor register;


one to hold the upper limit, and the other to hold the
lower limit.

After a push operation, SP is compared with the upper-limit


register and after a pop, SP is compared with the lower unit
register.

Example of stack limit:


Describe the use of Reverse Polish Notation

• The Polish mathematician Lukasiewicz show that


arithmetic expression can be represented in prefix
notation.

• This representation often referred to as Polish


notation; place the
operator before the operand.

• The postfix notation, referred to as reverse Polish


notation (RPN),
places the operator after the operand.
Describe the use of Reverse Polish Notation

The following examples demonstrate the three


representations:
A + B Infix notation
+ AB Prefix or Polish notation
AB + Postfix or reverse Polish notation
The reverse Polish notation is in a form suitable for stack
manipulation.The expression,
A*B+C*D
Is written in reverse Polish Notation as,
AB * CD * +
Conversion to RPN (reverse Polish
notation)
• The conversion from infix notation to reverse Polish notation
must take into consideration the operation hierarchy adopted for infix
notation.
• Perform all arithmetic form innermost to outermost parentheses and
brackets.
• Do multiplication and division operation
• Then, finish the addition and subtraction operations
Consider the expression,
(A + B) * [C * (D + E) + F]
• The expression can be converted to reverse Polish notation,
without the use of parentheses, by taking the consideration of
operation hierarchy.
• The converted expression is:
AB + DE + C * F + *
Conversion to RPN (reverse Polish notation) cont..

Proceeding from left to right, we first add A and B, then add


D and
E. At this point we are left with:

(A + B)(D + E)C * F + *

Where (A + B) and (D + E) are each a single number


obtained from the sum.The two operand for next * are C
and (D + E).These two numbers are multiplied and the
product added to F.The final * cause the multiplications of
the two terms.
Evaluation of Arithmetic Expressions

Reverse Polish notation, combined with a stack arrangement of


register, is the most efficient way known for evaluation the arithmetic
expression.
- This procedure employed by some electronic calculators and also
in some computer.
Reason why, the combination of stack and reverse polish notation
is the most efficient way
1.Stack
Particularly, useful for handling long, complex problem involving
chain calculation.
2.Reverse Polish Notation.
Any arithmetic expression can be expressed in parentheses-free Polish
notation. Conversion of arithmetic expression into Polish notation is
the most efficient method for translating arithmetic into machine
Evaluation of Arithmetic Expressions

The procedure consist,


1.Converting arithmetic expression into its equivalent reverse Polish
notation.
2.Reverse Polish Notation.

2.The operand is pushed into the stack in the order in which they
appear.
(a)The two top most operands in the stack are used for the operation.
(b)The stack is popped the result of the operation replace he lower
operand.
Evaluation of Arithmetic Expressions
Complex Instruction Set Computers
(CISC)
Complex Instruction Set Computer (or CISC) is a computer
with a larger number of instruction.

The major characteristic of CISC:


• Large number of instruction from 100 to 250 instructions.
• Some instruction that perform specialized task and
are used infrequently.
• Larger variety of addressing modes – typically from
5 to 20
different modes.
• Variable-length instruction formats
• Instruction that manipulates operands in memory.
Reduced Instruction Set Computer (RISC)

In the early 1980s, a number of computer designer recommended


that computers uses fewer instructions with simple constructs, so
they can be executed much faster within the CPU without having
to use memory often.This type of computer is classified as
reduced instruction set computer or RISC
The major characteristic of RISC:
• Relatively few instruction
• Relatively few addressing modes
• Memory access limited to load and store instructions
• All operation done within the register of the CPU
• Fixed-length, easily decoded instruction format
• Single-cycle instruction execution
• Hardwired rather that micro-programmed control.
Extra....
Register Array part 1

• A register is a memory location within the CPU itself, designed to


be quickly accessed for purposes of fast data retrieval.
Processors normally contain a register array, which houses many
such registers. These contain instructions, data and other values
that may need to be quickly accessed during the execution of a
program. Many different types of registers are common between
most microprocessor designs. These are:
• 1. Program Counter (PC)
This register is used to hold the memory address of the next
instruction that has to executed in a program. This is to ensure
the CPU knows at all times where it has reached, that is able to
resume following an execution at the correct point, and that the
program is executed correctly.
Register Array part 2

• 2. Instruction Register (IR)


This is used to hold the current instruction in the processor while
it is being decoded and executed, in order for the speed of the
whole execution process to be reduced. This is because the time
needed to access the instruction register is much less than
continual checking of the memory location itself.

• 3. Accumulator (A, or ACC)


The accumulator is used to hold the result of operations
performed by the arithmetic and logic unit, as covered in the
section on the ALU.
Register Array part 3

• 4. Memory Address Register (MAR)


Used for storage of memory addresses, usually the
addresses involved in the instructions held in the
instruction register. The control unit then checks this
register when needing to know which memory address
to check or obtain data from.
• 5. Memory Buffer Register (MBR)
When an instruction or data is obtained from the
memory or elsewhere, it is first placed in the memory
buffer register. The next action to take is then
determined and carried out, and the data is moved on
to the desired location.
Register Array part 4

• 6. Flag register / status flags


The flag register is specially designed to contain all the
appropriate 1-bit status flags, which are changed as a result of
operations involving the arithmetic and logic unit. Further
information can be found in the section on the ALU.

• 7. Other general purpose registers


These registers have no specific purpose, but are generally used
for the quick storage of pieces of data that are required later in
the program execution. In the model used here these are
assigned the names A and B, with suffixes of L and U indicating
the lower and upper sections of the register respectively.

You might also like