SlideShare a Scribd company logo
1 of 70
Download to read offline
Central Processing Unit
Dr. Heman Pathak
Associate Professor
Dept. of Comp. Sc.
Kanya Gurukul - Dehradun
Block Diagram of Computer
Central Processing Unit
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.
Central Processing Unit
• 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.
The CPU is made up of three major parts-
Central Processing Unit
Memory Unit
• The memory stores binary information in groups of bits called
words.
• A word in memory is an entity of bits that move in and out of
storage as a unit.
• A group of eight bits is called a byte.
• Most computer memories use words whose number of bits is a
multiple of 8. Thus a 16-bit word contains two bytes, and a 32-
bit word is made up of four bytes.
• The capacity of memories in commercial computers is usually
stated as the total number of bytes that can be stored.
Memory Unit
• The internal structure of a memory unit is specified by the
number of words it contains and the number of bits in
each word.
• Special input lines called address lines select one
particular word.
• Each word in memory is assigned an identification
number, called an address, starting from 0 and continuing
with 1, 2, 3, up to 2k - 1 where k is the number of address
lines.
Memory Unit
• The selection of a specific word inside the memory is done by
applying the k-bit binary address to the address lines.
• A decoder inside the memory accepts this address and opens the
paths needed to select the bits of the specified word.
• Computer memories may range from 1024 words, requiring an
address of 10 bits, to 232 words, requiring 32 address bits.
• It is customary to refer to the number of words (or bytes) in a
memory with one of the letters K (kilo), M (mega), or G (giga).
• K is equal to 210, M is equal to 220, and G is equal to 230*
• Thus 64K = 216, 2M = 221, and 4G = 232 .
Memory Unit
#include <stdio.h>
int main() {
int num1, num2;
printf("Enter two numbers: ");
scanf("%d%d", &num1, &num2
if(num1 > num2) {
printf("%d is maximum", num1);
}
if(num2 > num1) {
printf("%d is maximum", num2);
}
if(num1 == num2) {
printf("Both are equal");
}
return 0;
}
R1 = R2 + R3
R1 = R2 - A
R1 = A * B
C = A / B
C = R1 XOR B
General Register Organization
Control Word
• There are 14 binary selection inputs in the unit, and their combined value specifies
a control word.
• It consists of four fields.
• Three fields contain three bits each, and one field has five bits.
• The three bits of SELA select a source register for the A input of the ALU.
• The three bits of SELB select a register for the B input of the ALU.
• The three bits of SELD select a destination register using the decoder and its seven
load outputs.
• The five bits of OPR select one of the operations in the ALU.
• The14-bit control word when applied to the selection inputs specify a particular
• Micro-operation.
General Register Organization
R 1  R2 + R3
• the control must provide binary selection variables to the following
selector inputs:
• 1. MUX A selector (SELA): to place the content of R2 into bus A .
• 2 . MUX B selector (SELB): to place the content o f R3 into bus B .
• 3 . ALU operation selector (OPR): to provide the arithmetic addition.
• 4. Decoder destination selector (SELD): to transfer the content of the
output bus into R1.
R 1  R 2 - R3
Stack Organization
A stack is an ordered collection of items where the addition
of new items and the removal of existing items always takes
place at the same end.
This end is commonly referred to as the “top”, and the
opposite end is known as the “base”.
Stack Organization
• A useful feature that is included in the CPU of most computers is a
stack or last-in, first-out (LIFO) list.
• A stack is a storage device that stores information in such a manner
that the item stored last is the first item retrieved.
• The operation of a stack can be compared to a stack of trays. The
last tray placed on top of the stack is the first to be taken off.
Stack Pointer
• The register that holds the address for the stack is called a stack pointer
(SP) because its value always points at the top item in the stack.
• The physical registers of a stack are always available for reading or
writing. It is the content of the word that is inserted or deleted.
• The two operations of a stack are the insertion and deletion of items.
• The operation of insertion is called push (or push-down).
• The operation of deletion is called pop (or pop-up).
• These operations are simulated by incrementing or decrementing the
stack pointer register.
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.
Register Stack
• In a 64-word stack, the stack pointer contains 6 bits because 26 = 64.
• SP cannot exceed a number greater than 63 (111111 in binary).
• When 63 is incremented by 1, the result is 0 since 111111 + 1 = 1000000
in binary, but SP can accommodate only the six least significant bits.
• Similarly, when 000000 is decremented by 1, the result is 111111.
• The one-bit register FULL is set to 1 when the stack is full, and the one-
bit register EMTY is set to 1 when the stack is empty of items.
• DR is the data register that holds the binary data to be written into or
read out of the stack.
Register Stack
• Initially, SP is cleared to 0, EMTY is set to 1, and FULL is cleared to 0.
• If the stack is not full (if FULL = 0), a new item is inserted with a
push operation. The push operation is implemented with the
following sequence of micro-operations;
SP  SP + 1
R[SP]  DR
If (SP = 0) then (FULL 1)
EMTY  0
Register Stack
• A new item is deleted from the stack if the stack is not empty (if EMTY = 0).
• The pop operation consists of the following sequence of micro-operations:
DR  R[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
• A stack 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 register as a stack pointer.
Memory Stack
• The initial value of SP is 4001 and the stack grows with
decreasing addresses.
• Thus the first item stored in the stack is at address 4000.
• The second item is stored at address 3999.
• The last address that can be used for the stack is 3000.
• No provisions are available for stack limit checks.
Memory Stack
PUSH()
SP  SP - 1
M[SP]  DR
POP()
DR  M[SP]
SP  SP + 1
Memory Stack
• Most computers do not provide hardware to check for stack
overflow (fullstack) or underflow (empty stack).
• The stack limits can be checked by using two processor registers:
one to hold the upper limit (3000 in this case), and the other to hold
the lower limit (4001 in this case).
• After a push operation, SP is compared with the upper-limit register
and after a pop operation, SP is comparedwith the lower-limit
register.
Memory Stack
• The two micro-operations needed for either the push or pop are –
1. an access to memory through SP, and
2. updating SP.
• Which of the two micro-operations is done first and whether SP is
updated by incrementing or decrementing depends on the
organization of 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
• A stack organization is very effective for evaluating arithmetic expressions.
• The common arithmetic expressions are written in infix notation, with
each operator written between the operands. A * B + C * D
• The Polish mathematician showed that AE expressions can be represented
in prefix notation. The postfix notation, referred to as reverse Polish
notation (RPN), places the operator after the operands.
A + B Infix notation
+ AB Prefix or Polish notation
AB + Postfix or reverse Polish notation
Reverse Polish Notation
• (A + B) * [C * (D + E) + F]
• AB + DE + C * F + *
Reverse Polish Notation
• Algorithm
• Step 1 : Scan the Infix Expression from left to right.
• Step 2 : If the scanned character is an operand, append it with final Infix to Postfix string.
• Step 3 : Else,
• Step 3.1 : If the precedence order of the scanned(incoming) operator is greater than the precedence order of the
operator in the stack (or the stack is empty or the stack contains a „(„ or „[„ or „{„), push it on stack.
• Step 3.2 : Else, Pop all the operators from the stack which are greater than or equal to in precedence than that of the
scanned operator. After doing that Push the scanned operator to the stack. (If you encounter parenthesis while
popping then stop there and push the scanned operator in the stack.)
• Step 4 : If the scanned character is an „(„ or „[„ or „{„, push it to the stack.
• Step 5 : If the scanned character is an „)‟or „]‟ or „}‟, pop the stack and output it until a „(„ or „[„ or „{„ respectively is
encountered, and discard both the parenthesis.
• Step 6 : Repeat steps 2-6 until infix expression is scanned.
• Step 7 : Print the output
• Step 8 : Pop and output from the stack until it is not empty.
Reverse Polish Notation
(A + B) * [C * (D + E) + F]
( Push Stack:(
A Postfix:A
+ Push Stack:(+
B AB
) Pop Stack: AB+
* Push Stack:*
[ Push Stack:* [
C AB+C
* Push Stack:* [*
(A + B) * [C * (D + E) + F]
( Push Stack:* [*(
D AB+CD
+ Push Stack:* [*(+
E AB+CDE
) Pop Stack:* [* AB+CDE+
+ Push Stack:* [+ AB+CDE+*
F AB+CDE+*F
] Pop Stack:* AB+CDE+*F+
- Pop Stack: AB+CDE+*F+*
Evaluation of Arithmetic Expressions
• (3 * 4) + (5 * 6)
• 34 * 56 * +
Instruction Formats
• The physical and logical structure of computers is normally
described in reference manuals provided with the system.
• Such manuals explain the internal construction of the CPU,
including the processor registers available and their logical
capabilities.
• They list all hardware-implemented instructions, specify their
binary code format, and provide a precise definition of each
instruction.
• A computer will usually have a variety of instruction code
formats. It is the function of the control unit within the CPU to
interpret each instruction code and provide the necessary
control functions needed to process the instruction.
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 operand
or the effective address is determined.
Mode Opcode Operand Address
Instruction Formats
• Computers may have instructions of several different lengths
containing varying number of addresses.
• The number of address fields in the instruction format of a
computer depends on the internal organization of its registers. Most
computers fall into one of three types of CPU organizations:
• 1. Single accumulator organization.
• 2. General register organization.
• 3. Stack organization.
Single accumulator organization
In this type of CPU organization, the accumulator register is used
implicitly for processing all instructions of a program and store the
results into the accumulator.
The main points about Single Accumulator based CPU Organisation
are:
• the first ALU operand is always stored into the Accumulator and
the second operand is present either in Registers or in the Memory.
• Accumulator is the default address thus after data manipulation
the results are stored into the accumulator.
• One address instruction is used in this type of organization.
Single accumulator organization
The instruction format in this type of computer uses one address
field. For example, the instruction that specifies an arithmetic
addition is defined by an assembly language instruction as
ADD X
where X is the address of the operand. The ADD instruction in this
case results in the operation
AC  AC + M [X]
AC is the accumulator register and M [X] symbolizes the memory
word located at address X.
General Register Organization
The instruction format in this type of computer needs three
register address fields. Thus the instruction for an arithmetic
addition may be written in an assembly language as
ADD R1, R2, R3
to denote the operation
R1  R2 + R 3 .
The number of address fields in the instruction can be reduced
from three to two if the destination register is the same as one of
the source registers. Thus the instruction
ADD R1 , R2
would denote the operation
R 1  R 1 + R2.
General Register Organization
General register-type computers employ two or three
address fields in their instruction format.
Each address field may specify a processor register or a
memory word. An instruction symbolized by
ADD R1, X
would specify the operation
Rl R l + M[X]
It has two address fields, one for register R1 and the other
for the memory address X.
Stack Organization
Computers with stack organization would have PUSH and POP instructions which
require an address field. Thus the instruction
PUSH X POP X
will push the word at address X to the top of the stack. The stack pointer is
updated automatically.
Operation-type instructions do not need an address field. The operation is
performed on the two items that are on top of the stack. The instruction
ADD
Pops the two top numbers from the stack, add the numbers, and push the sum into
the stack.
Three-Address Instructions
X = (A + B) • (C + D)
ADD R1, A, B R 1 M [ A ] + M [ B ]
ADD R2, C, D R 2 M [ C ] + M [ D ]
MUL X, R1, R2 M [ X ]  R 1 * R 2
Two Address Instructions
X = (A + B) * (C + D)
One Address Instructions
X = (A + B) * (C + D)
Zero-Address Instructions
X = (A + B) * (C + D)
Complex Instruction Set
Computer (CISC)
• An important aspect of computer architecture is the design of the instruction set
for the processor.
• The instruction set chosen for a particular computer determines the way that
machine language programs are constructed.
• Early computers had small and simple instruction sets, forced mainly by the need
to minimize the hardware.
• As digital hardware became cheaper with the advent of integrated circuits,
computer instructions tended to increase both in number and complexity.
• A computer with a large number of instructions is classified as a Complex
Instruction Set Computer, abbreviated CISC.
Major Characteristics
of CISC Archltecture are:
1. A large number of instructions-typically from 100 to 250
instructions.
2. Some instructions that perform specialized tasks and are used
infrequently.
3. A large variety of addressing modes-typically from 5 to 20
different modes
4. Variable-length instruction formats
5. Instructions that manipulate operands in memory
Reduced Instruction Set
Computer (RISC )
• In the early 1980s, a number of computer designers recommended
that computers use fewer instructions with simple constructs so
they can be executed much faster within the CPU without having to
use memory as often.
• This type of computer is classified as a reduced instruction set
computer or RISC.
Major Characteristics
of RISC Archltecture are:
1. Relatively few instructions
2. Relatively few addressing modes
3. Memory access limited to load and store instructions
4. All operations done within the registers of the CPU
5. Fixed-length, easily decoded instruction format
6. Single-cycle instruction execution
7. Hardwired rather than microprogrammed control
RISC Instructions
X = (A + B) * (C + D)
Addressing Modes
• 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.
Mode Opcode Operand Address
Addressing Modes
• The control unit of a computer is designed to go through
an instruction cycle that is divided into three major
phases:
1. Fetch the instruction from memory.
2. Decode the instruction.
3. Execute the instruction.
Mode Opcode Operand Address
Addressing Modes
• In some computers the addressing mode of the instruction is
specified with a distinct binary code, just like the operation code is
specified.
• Other computers use a single binary code that designates both the
operation and the mode of the instruction.
• Instructions may be defined with a variety of addressing modes,
and sometimes, two or more addressing modes are combined in one
instruction.
Mode Opcode Operand Address
Implied Mode
• Although most addressing modes modify the address field of the
instruction, there are two modes that need no address field at all. These
are the implied and immediate modes.
• 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.
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.
• The operand field contains the actual operand to be used in
conjunction with the operation specified in the instruction.
• Immediate-mode instructions are useful for initializing registers to a
constant value.
• ADD 4 MOV 5 MUL 10
Register Mode:
• When the address field specifies a processor register, the instruction
is said to be in the register mode.
• 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.
ADD R1 MUL R2
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.
• ADD M[R1] MUL M[R2]
Auto-increment or Auto-decrement 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.
• 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.
• However, because it is such a common requirement, some
computers incorporate a special mode that automatically increments
or decrements the content of the register after data access.
Auto-increment or Auto-decrement Mode:
Auto-increment or Auto-decrement Mode:
Effective Address
• Sometimes the value given in the address field is the address of the
operand, but sometimes it is just an address from which the address
of the operand is calculated.
• To differentiate among the various addressing modes it is necessary
to distinguish between the address part of the instruction and the
effective address used by the control when executing the
instruction.
• 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.
• Control fetches the instruction from memory and uses its address
part to access memory again to read the effective address.
• 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
• The CPU register used in the computation may be the program
counter, an index register, or a base register.
• In either case we have a different addressing mode which is used
for a different application.
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.
• To clarify with an example, assume that the program counter contains the number
825 and 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.
• This is 24 memory locations forward from the address of the next instruction.
Relative Address Mode:
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.
• Each operand in the array is stored in memory relative to the
beginning address. The distance between the beginning address and
the address of the operand is the index value stored in the index
register. ADD A[5]
Indexed Addressing Mode:
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.
• 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 is assumed to hold a base address and the address
field of the instruction gives a displacement relative to this base
address.
Base Register Addressing Mode:
Addressing Mode
Direct address
500 800
Immediate operand
201 500
Indirect address
800 300
Relative address
702 325
Indexed address
600 900
Register
R1 400
Register indirect
400 700
Autoincrement
400 700
Autodecrement
399 450

More Related Content

What's hot (20)

Registers-shift register
Registers-shift registerRegisters-shift register
Registers-shift register
 
Module 4 registers and counters
Module 4 registers and counters Module 4 registers and counters
Module 4 registers and counters
 
Chapter 6 register
Chapter 6 registerChapter 6 register
Chapter 6 register
 
Overview of Shift register and applications
Overview of Shift register and applicationsOverview of Shift register and applications
Overview of Shift register and applications
 
Counters
CountersCounters
Counters
 
Chapter7
Chapter7Chapter7
Chapter7
 
Registers
RegistersRegisters
Registers
 
Ece221 Ch7 Part1
Ece221 Ch7 Part1Ece221 Ch7 Part1
Ece221 Ch7 Part1
 
Group 11 introduction to registers and counters
Group 11 introduction to registers and countersGroup 11 introduction to registers and counters
Group 11 introduction to registers and counters
 
Registers
RegistersRegisters
Registers
 
Shift Registers
Shift RegistersShift Registers
Shift Registers
 
Shift Register
Shift RegisterShift Register
Shift Register
 
DELD Unit IV ring and twisted ring counter
DELD Unit IV ring and twisted ring counterDELD Unit IV ring and twisted ring counter
DELD Unit IV ring and twisted ring counter
 
Registers siso, sipo
Registers siso, sipoRegisters siso, sipo
Registers siso, sipo
 
Ring counter
Ring counterRing counter
Ring counter
 
Registers-shift registers
Registers-shift registersRegisters-shift registers
Registers-shift registers
 
Shift registers
Shift registersShift registers
Shift registers
 
Registers
RegistersRegisters
Registers
 
Registers
RegistersRegisters
Registers
 
Register counters.readonly
Register counters.readonlyRegister counters.readonly
Register counters.readonly
 

Similar to Central processing unit

Computer Organization and 8085 microprocessor notes
Computer Organization and 8085 microprocessor notesComputer Organization and 8085 microprocessor notes
Computer Organization and 8085 microprocessor notesLakshmi Sarvani Videla
 
Central processing unit
Central processing unitCentral processing unit
Central processing unitjyoti_lakhani
 
Computer Organization : CPU, Memory and I/O organization
Computer Organization : CPU, Memory and I/O organizationComputer Organization : CPU, Memory and I/O organization
Computer Organization : CPU, Memory and I/O organizationAmrutaMehata
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessoradnanqayum
 
Addressing modes (detailed data path)
Addressing modes (detailed data path)Addressing modes (detailed data path)
Addressing modes (detailed data path)Mahesh Kumar Attri
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
Chapter 2-8085 Microprocessor Architecture and Microcomputer Systems
Chapter 2-8085 Microprocessor Architecture and Microcomputer SystemsChapter 2-8085 Microprocessor Architecture and Microcomputer Systems
Chapter 2-8085 Microprocessor Architecture and Microcomputer Systemscmkandemir
 
Presentation of mpu
Presentation of mpuPresentation of mpu
Presentation of mpuKyawthu Koko
 
5th unit Microprocessor 8085
5th unit Microprocessor 80855th unit Microprocessor 8085
5th unit Microprocessor 8085Mani Afranzio
 

Similar to Central processing unit (20)

COA (Unit_2.pptx)
COA (Unit_2.pptx)COA (Unit_2.pptx)
COA (Unit_2.pptx)
 
Computer Organization and 8085 microprocessor notes
Computer Organization and 8085 microprocessor notesComputer Organization and 8085 microprocessor notes
Computer Organization and 8085 microprocessor notes
 
Arithmetic & Logic Unit
Arithmetic & Logic UnitArithmetic & Logic Unit
Arithmetic & Logic Unit
 
THE PROCESSOR
THE PROCESSORTHE PROCESSOR
THE PROCESSOR
 
Unit 3 The processor
Unit 3 The processorUnit 3 The processor
Unit 3 The processor
 
UNIT-3.pptx
UNIT-3.pptxUNIT-3.pptx
UNIT-3.pptx
 
Central processing unit
Central processing unitCentral processing unit
Central processing unit
 
Computer Organization : CPU, Memory and I/O organization
Computer Organization : CPU, Memory and I/O organizationComputer Organization : CPU, Memory and I/O organization
Computer Organization : CPU, Memory and I/O organization
 
Amp
AmpAmp
Amp
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessor
 
Addressing modes (detailed data path)
Addressing modes (detailed data path)Addressing modes (detailed data path)
Addressing modes (detailed data path)
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
module-2.pptx
module-2.pptxmodule-2.pptx
module-2.pptx
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Chapter 2-8085 Microprocessor Architecture and Microcomputer Systems
Chapter 2-8085 Microprocessor Architecture and Microcomputer SystemsChapter 2-8085 Microprocessor Architecture and Microcomputer Systems
Chapter 2-8085 Microprocessor Architecture and Microcomputer Systems
 
class-Stacks.pptx
class-Stacks.pptxclass-Stacks.pptx
class-Stacks.pptx
 
Presentation of mpu
Presentation of mpuPresentation of mpu
Presentation of mpu
 
5th unit Microprocessor 8085
5th unit Microprocessor 80855th unit Microprocessor 8085
5th unit Microprocessor 8085
 

More from Heman Pathak

Interconnection Network
Interconnection NetworkInterconnection Network
Interconnection NetworkHeman Pathak
 
Sequential Circuit
Sequential CircuitSequential Circuit
Sequential CircuitHeman Pathak
 
Combinational logic 2
Combinational logic 2Combinational logic 2
Combinational logic 2Heman Pathak
 
Combinational logic 1
Combinational logic 1Combinational logic 1
Combinational logic 1Heman Pathak
 
Simplification of Boolean Function
Simplification of Boolean FunctionSimplification of Boolean Function
Simplification of Boolean FunctionHeman Pathak
 
Chapter 2: Boolean Algebra and Logic Gates
Chapter 2: Boolean Algebra and Logic GatesChapter 2: Boolean Algebra and Logic Gates
Chapter 2: Boolean Algebra and Logic GatesHeman Pathak
 
Chapter 7: Matrix Multiplication
Chapter 7: Matrix MultiplicationChapter 7: Matrix Multiplication
Chapter 7: Matrix MultiplicationHeman Pathak
 
Elementary Parallel Algorithms
Elementary Parallel AlgorithmsElementary Parallel Algorithms
Elementary Parallel AlgorithmsHeman Pathak
 
Chapter 5: Mapping and Scheduling
Chapter  5: Mapping and SchedulingChapter  5: Mapping and Scheduling
Chapter 5: Mapping and SchedulingHeman Pathak
 
Cost optimal algorithm
Cost optimal algorithmCost optimal algorithm
Cost optimal algorithmHeman Pathak
 
Chapter 4: Parallel Programming Languages
Chapter 4: Parallel Programming LanguagesChapter 4: Parallel Programming Languages
Chapter 4: Parallel Programming LanguagesHeman Pathak
 
Parallel Algorithm for Graph Coloring
Parallel Algorithm for Graph Coloring Parallel Algorithm for Graph Coloring
Parallel Algorithm for Graph Coloring Heman Pathak
 
Parallel Algorithms
Parallel AlgorithmsParallel Algorithms
Parallel AlgorithmsHeman Pathak
 
Chapter 1 - introduction - parallel computing
Chapter  1 - introduction - parallel computingChapter  1 - introduction - parallel computing
Chapter 1 - introduction - parallel computingHeman Pathak
 

More from Heman Pathak (14)

Interconnection Network
Interconnection NetworkInterconnection Network
Interconnection Network
 
Sequential Circuit
Sequential CircuitSequential Circuit
Sequential Circuit
 
Combinational logic 2
Combinational logic 2Combinational logic 2
Combinational logic 2
 
Combinational logic 1
Combinational logic 1Combinational logic 1
Combinational logic 1
 
Simplification of Boolean Function
Simplification of Boolean FunctionSimplification of Boolean Function
Simplification of Boolean Function
 
Chapter 2: Boolean Algebra and Logic Gates
Chapter 2: Boolean Algebra and Logic GatesChapter 2: Boolean Algebra and Logic Gates
Chapter 2: Boolean Algebra and Logic Gates
 
Chapter 7: Matrix Multiplication
Chapter 7: Matrix MultiplicationChapter 7: Matrix Multiplication
Chapter 7: Matrix Multiplication
 
Elementary Parallel Algorithms
Elementary Parallel AlgorithmsElementary Parallel Algorithms
Elementary Parallel Algorithms
 
Chapter 5: Mapping and Scheduling
Chapter  5: Mapping and SchedulingChapter  5: Mapping and Scheduling
Chapter 5: Mapping and Scheduling
 
Cost optimal algorithm
Cost optimal algorithmCost optimal algorithm
Cost optimal algorithm
 
Chapter 4: Parallel Programming Languages
Chapter 4: Parallel Programming LanguagesChapter 4: Parallel Programming Languages
Chapter 4: Parallel Programming Languages
 
Parallel Algorithm for Graph Coloring
Parallel Algorithm for Graph Coloring Parallel Algorithm for Graph Coloring
Parallel Algorithm for Graph Coloring
 
Parallel Algorithms
Parallel AlgorithmsParallel Algorithms
Parallel Algorithms
 
Chapter 1 - introduction - parallel computing
Chapter  1 - introduction - parallel computingChapter  1 - introduction - parallel computing
Chapter 1 - introduction - parallel computing
 

Recently uploaded

Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 

Recently uploaded (20)

Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 

Central processing unit

  • 1. Central Processing Unit Dr. Heman Pathak Associate Professor Dept. of Comp. Sc. Kanya Gurukul - Dehradun
  • 2. Block Diagram of Computer
  • 3. Central Processing Unit 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.
  • 4. Central Processing Unit • 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. The CPU is made up of three major parts-
  • 6. Memory Unit • The memory stores binary information in groups of bits called words. • A word in memory is an entity of bits that move in and out of storage as a unit. • A group of eight bits is called a byte. • Most computer memories use words whose number of bits is a multiple of 8. Thus a 16-bit word contains two bytes, and a 32- bit word is made up of four bytes. • The capacity of memories in commercial computers is usually stated as the total number of bytes that can be stored.
  • 7. Memory Unit • The internal structure of a memory unit is specified by the number of words it contains and the number of bits in each word. • Special input lines called address lines select one particular word. • Each word in memory is assigned an identification number, called an address, starting from 0 and continuing with 1, 2, 3, up to 2k - 1 where k is the number of address lines.
  • 8. Memory Unit • The selection of a specific word inside the memory is done by applying the k-bit binary address to the address lines. • A decoder inside the memory accepts this address and opens the paths needed to select the bits of the specified word. • Computer memories may range from 1024 words, requiring an address of 10 bits, to 232 words, requiring 32 address bits. • It is customary to refer to the number of words (or bytes) in a memory with one of the letters K (kilo), M (mega), or G (giga). • K is equal to 210, M is equal to 220, and G is equal to 230* • Thus 64K = 216, 2M = 221, and 4G = 232 .
  • 10. #include <stdio.h> int main() { int num1, num2; printf("Enter two numbers: "); scanf("%d%d", &num1, &num2 if(num1 > num2) { printf("%d is maximum", num1); } if(num2 > num1) { printf("%d is maximum", num2); } if(num1 == num2) { printf("Both are equal"); } return 0; }
  • 11. R1 = R2 + R3 R1 = R2 - A R1 = A * B C = A / B C = R1 XOR B General Register Organization
  • 12. Control Word • There are 14 binary selection inputs in the unit, and their combined value specifies a control word. • It consists of four fields. • Three fields contain three bits each, and one field has five bits. • The three bits of SELA select a source register for the A input of the ALU. • The three bits of SELB select a register for the B input of the ALU. • The three bits of SELD select a destination register using the decoder and its seven load outputs. • The five bits of OPR select one of the operations in the ALU. • The14-bit control word when applied to the selection inputs specify a particular • Micro-operation.
  • 13. General Register Organization R 1  R2 + R3 • the control must provide binary selection variables to the following selector inputs: • 1. MUX A selector (SELA): to place the content of R2 into bus A . • 2 . MUX B selector (SELB): to place the content o f R3 into bus B . • 3 . ALU operation selector (OPR): to provide the arithmetic addition. • 4. Decoder destination selector (SELD): to transfer the content of the output bus into R1.
  • 14. R 1  R 2 - R3
  • 15.
  • 16. Stack Organization A stack is an ordered collection of items where the addition of new items and the removal of existing items always takes place at the same end. This end is commonly referred to as the “top”, and the opposite end is known as the “base”.
  • 17. Stack Organization • A useful feature that is included in the CPU of most computers is a stack or last-in, first-out (LIFO) list. • A stack is a storage device that stores information in such a manner that the item stored last is the first item retrieved. • The operation of a stack can be compared to a stack of trays. The last tray placed on top of the stack is the first to be taken off.
  • 18. Stack Pointer • The register that holds the address for the stack is called a stack pointer (SP) because its value always points at the top item in the stack. • The physical registers of a stack are always available for reading or writing. It is the content of the word that is inserted or deleted. • The two operations of a stack are the insertion and deletion of items. • The operation of insertion is called push (or push-down). • The operation of deletion is called pop (or pop-up). • These operations are simulated by incrementing or decrementing the stack pointer register.
  • 19. 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.
  • 20. Register Stack • In a 64-word stack, the stack pointer contains 6 bits because 26 = 64. • SP cannot exceed a number greater than 63 (111111 in binary). • When 63 is incremented by 1, the result is 0 since 111111 + 1 = 1000000 in binary, but SP can accommodate only the six least significant bits. • Similarly, when 000000 is decremented by 1, the result is 111111. • The one-bit register FULL is set to 1 when the stack is full, and the one- bit register EMTY is set to 1 when the stack is empty of items. • DR is the data register that holds the binary data to be written into or read out of the stack.
  • 21. Register Stack • Initially, SP is cleared to 0, EMTY is set to 1, and FULL is cleared to 0. • If the stack is not full (if FULL = 0), a new item is inserted with a push operation. The push operation is implemented with the following sequence of micro-operations; SP  SP + 1 R[SP]  DR If (SP = 0) then (FULL 1) EMTY  0
  • 22. Register Stack • A new item is deleted from the stack if the stack is not empty (if EMTY = 0). • The pop operation consists of the following sequence of micro-operations: DR  R[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
  • 23. Memory Stack • A stack 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 register as a stack pointer.
  • 24. Memory Stack • The initial value of SP is 4001 and the stack grows with decreasing addresses. • Thus the first item stored in the stack is at address 4000. • The second item is stored at address 3999. • The last address that can be used for the stack is 3000. • No provisions are available for stack limit checks.
  • 25. Memory Stack PUSH() SP  SP - 1 M[SP]  DR POP() DR  M[SP] SP  SP + 1
  • 26. Memory Stack • Most computers do not provide hardware to check for stack overflow (fullstack) or underflow (empty stack). • The stack limits can be checked by using two processor registers: one to hold the upper limit (3000 in this case), and the other to hold the lower limit (4001 in this case). • After a push operation, SP is compared with the upper-limit register and after a pop operation, SP is comparedwith the lower-limit register.
  • 27. Memory Stack • The two micro-operations needed for either the push or pop are – 1. an access to memory through SP, and 2. updating SP. • Which of the two micro-operations is done first and whether SP is updated by incrementing or decrementing depends on the organization of 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.
  • 28. Reverse Polish Notation • A stack organization is very effective for evaluating arithmetic expressions. • The common arithmetic expressions are written in infix notation, with each operator written between the operands. A * B + C * D • The Polish mathematician showed that AE expressions can be represented in prefix notation. The postfix notation, referred to as reverse Polish notation (RPN), places the operator after the operands. A + B Infix notation + AB Prefix or Polish notation AB + Postfix or reverse Polish notation
  • 29. Reverse Polish Notation • (A + B) * [C * (D + E) + F] • AB + DE + C * F + *
  • 30. Reverse Polish Notation • Algorithm • Step 1 : Scan the Infix Expression from left to right. • Step 2 : If the scanned character is an operand, append it with final Infix to Postfix string. • Step 3 : Else, • Step 3.1 : If the precedence order of the scanned(incoming) operator is greater than the precedence order of the operator in the stack (or the stack is empty or the stack contains a „(„ or „[„ or „{„), push it on stack. • Step 3.2 : Else, Pop all the operators from the stack which are greater than or equal to in precedence than that of the scanned operator. After doing that Push the scanned operator to the stack. (If you encounter parenthesis while popping then stop there and push the scanned operator in the stack.) • Step 4 : If the scanned character is an „(„ or „[„ or „{„, push it to the stack. • Step 5 : If the scanned character is an „)‟or „]‟ or „}‟, pop the stack and output it until a „(„ or „[„ or „{„ respectively is encountered, and discard both the parenthesis. • Step 6 : Repeat steps 2-6 until infix expression is scanned. • Step 7 : Print the output • Step 8 : Pop and output from the stack until it is not empty.
  • 31. Reverse Polish Notation (A + B) * [C * (D + E) + F] ( Push Stack:( A Postfix:A + Push Stack:(+ B AB ) Pop Stack: AB+ * Push Stack:* [ Push Stack:* [ C AB+C * Push Stack:* [* (A + B) * [C * (D + E) + F] ( Push Stack:* [*( D AB+CD + Push Stack:* [*(+ E AB+CDE ) Pop Stack:* [* AB+CDE+ + Push Stack:* [+ AB+CDE+* F AB+CDE+*F ] Pop Stack:* AB+CDE+*F+ - Pop Stack: AB+CDE+*F+*
  • 32. Evaluation of Arithmetic Expressions • (3 * 4) + (5 * 6) • 34 * 56 * +
  • 33. Instruction Formats • The physical and logical structure of computers is normally described in reference manuals provided with the system. • Such manuals explain the internal construction of the CPU, including the processor registers available and their logical capabilities. • They list all hardware-implemented instructions, specify their binary code format, and provide a precise definition of each instruction. • A computer will usually have a variety of instruction code formats. It is the function of the control unit within the CPU to interpret each instruction code and provide the necessary control functions needed to process the instruction.
  • 34. 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 operand or the effective address is determined. Mode Opcode Operand Address
  • 35. Instruction Formats • Computers may have instructions of several different lengths containing varying number of addresses. • The number of address fields in the instruction format of a computer depends on the internal organization of its registers. Most computers fall into one of three types of CPU organizations: • 1. Single accumulator organization. • 2. General register organization. • 3. Stack organization.
  • 36. Single accumulator organization In this type of CPU organization, the accumulator register is used implicitly for processing all instructions of a program and store the results into the accumulator. The main points about Single Accumulator based CPU Organisation are: • the first ALU operand is always stored into the Accumulator and the second operand is present either in Registers or in the Memory. • Accumulator is the default address thus after data manipulation the results are stored into the accumulator. • One address instruction is used in this type of organization.
  • 37. Single accumulator organization The instruction format in this type of computer uses one address field. For example, the instruction that specifies an arithmetic addition is defined by an assembly language instruction as ADD X where X is the address of the operand. The ADD instruction in this case results in the operation AC  AC + M [X] AC is the accumulator register and M [X] symbolizes the memory word located at address X.
  • 38. General Register Organization The instruction format in this type of computer needs three register address fields. Thus the instruction for an arithmetic addition may be written in an assembly language as ADD R1, R2, R3 to denote the operation R1  R2 + R 3 . The number of address fields in the instruction can be reduced from three to two if the destination register is the same as one of the source registers. Thus the instruction ADD R1 , R2 would denote the operation R 1  R 1 + R2.
  • 39. General Register Organization General register-type computers employ two or three address fields in their instruction format. Each address field may specify a processor register or a memory word. An instruction symbolized by ADD R1, X would specify the operation Rl R l + M[X] It has two address fields, one for register R1 and the other for the memory address X.
  • 40. Stack Organization Computers with stack organization would have PUSH and POP instructions which require an address field. Thus the instruction PUSH X POP X will push the word at address X to the top of the stack. The stack pointer is updated automatically. Operation-type instructions do not need an address field. The operation is performed on the two items that are on top of the stack. The instruction ADD Pops the two top numbers from the stack, add the numbers, and push the sum into the stack.
  • 41. Three-Address Instructions X = (A + B) • (C + D) ADD R1, A, B R 1 M [ A ] + M [ B ] ADD R2, C, D R 2 M [ C ] + M [ D ] MUL X, R1, R2 M [ X ]  R 1 * R 2
  • 42. Two Address Instructions X = (A + B) * (C + D)
  • 43. One Address Instructions X = (A + B) * (C + D)
  • 44. Zero-Address Instructions X = (A + B) * (C + D)
  • 45. Complex Instruction Set Computer (CISC) • An important aspect of computer architecture is the design of the instruction set for the processor. • The instruction set chosen for a particular computer determines the way that machine language programs are constructed. • Early computers had small and simple instruction sets, forced mainly by the need to minimize the hardware. • As digital hardware became cheaper with the advent of integrated circuits, computer instructions tended to increase both in number and complexity. • A computer with a large number of instructions is classified as a Complex Instruction Set Computer, abbreviated CISC.
  • 46. Major Characteristics of CISC Archltecture are: 1. A large number of instructions-typically from 100 to 250 instructions. 2. Some instructions that perform specialized tasks and are used infrequently. 3. A large variety of addressing modes-typically from 5 to 20 different modes 4. Variable-length instruction formats 5. Instructions that manipulate operands in memory
  • 47. Reduced Instruction Set Computer (RISC ) • In the early 1980s, a number of computer designers recommended that computers use fewer instructions with simple constructs so they can be executed much faster within the CPU without having to use memory as often. • This type of computer is classified as a reduced instruction set computer or RISC.
  • 48. Major Characteristics of RISC Archltecture are: 1. Relatively few instructions 2. Relatively few addressing modes 3. Memory access limited to load and store instructions 4. All operations done within the registers of the CPU 5. Fixed-length, easily decoded instruction format 6. Single-cycle instruction execution 7. Hardwired rather than microprogrammed control
  • 49. RISC Instructions X = (A + B) * (C + D)
  • 50. Addressing Modes • 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. Mode Opcode Operand Address
  • 51. Addressing Modes • The control unit of a computer is designed to go through an instruction cycle that is divided into three major phases: 1. Fetch the instruction from memory. 2. Decode the instruction. 3. Execute the instruction. Mode Opcode Operand Address
  • 52. Addressing Modes • In some computers the addressing mode of the instruction is specified with a distinct binary code, just like the operation code is specified. • Other computers use a single binary code that designates both the operation and the mode of the instruction. • Instructions may be defined with a variety of addressing modes, and sometimes, two or more addressing modes are combined in one instruction. Mode Opcode Operand Address
  • 53. Implied Mode • Although most addressing modes modify the address field of the instruction, there are two modes that need no address field at all. These are the implied and immediate modes. • 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.
  • 54. 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. • The operand field contains the actual operand to be used in conjunction with the operation specified in the instruction. • Immediate-mode instructions are useful for initializing registers to a constant value. • ADD 4 MOV 5 MUL 10
  • 55. Register Mode: • When the address field specifies a processor register, the instruction is said to be in the register mode. • 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. ADD R1 MUL R2
  • 56. 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. • ADD M[R1] MUL M[R2]
  • 57. Auto-increment or Auto-decrement 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. • 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. • However, because it is such a common requirement, some computers incorporate a special mode that automatically increments or decrements the content of the register after data access.
  • 60. Effective Address • Sometimes the value given in the address field is the address of the operand, but sometimes it is just an address from which the address of the operand is calculated. • To differentiate among the various addressing modes it is necessary to distinguish between the address part of the instruction and the effective address used by the control when executing the instruction. • The effective address is defined to be the memory address obtained from the computation dictated by the given addressing mode.
  • 61. 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.
  • 62. 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.
  • 63. • 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 • The CPU register used in the computation may be the program counter, an index register, or a base register. • In either case we have a different addressing mode which is used for a different application.
  • 64. 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. • To clarify with an example, assume that the program counter contains the number 825 and 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. • This is 24 memory locations forward from the address of the next instruction.
  • 66. 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. • Each operand in the array is stored in memory relative to the beginning address. The distance between the beginning address and the address of the operand is the index value stored in the index register. ADD A[5]
  • 68. 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. • 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 is assumed to hold a base address and the address field of the instruction gives a displacement relative to this base address.
  • 70. Addressing Mode Direct address 500 800 Immediate operand 201 500 Indirect address 800 300 Relative address 702 325 Indexed address 600 900 Register R1 400 Register indirect 400 700 Autoincrement 400 700 Autodecrement 399 450