6COA Slides
6COA Slides
CPU Organization
A instruction is of various length depending upon the number of addresses it contain.
Generally CPU organization are of three types on the basis of number of address fields:
• Single accumulator organization
• General register Organization
• Stack organization
1
10/1/2023
2
10/1/2023
Stack Organization
• The computers which use Stack-based CPU Organization are
based on a data structure called stack. The stack is a list of
data words. It uses Last In First Out (LIFO) access method
which is the most popular access method in most of the CPU.
• A register is used to store the address of the topmost element
of the stack which is known as Stack pointer (SP).
• In this organization, ALU operations are performed on stack
data. It means both the operands are always required on the
stack. After manipulation, the result is placed in the stack.
Zero Address instructions:
• Can be found in a stack-organized computer.
Push Operation: Pop Operation:
Stack Organization
• A stack based computer do not use address field in instruction. To evaluate a expression
first it is converted to revere Polish Notation i.e. Post fix Notation.
• Expression: X = (A+B)*(C+D)
• Postfix : X = AB+CD+*
• TOS means top of stack
• M[X] is any memory location
3
10/1/2023
Addressing Modes
• Addressing modes are the ways by which the operand of an instruction is
specified. It is a rule for interpreting or modifying the address field of the
instruction before the operand is actually executed.
• Implied Mode: (Stack Oriented Addressing Mode)
Operands implicitly specified in the definition of the instruction.
All register reference instruction that use accumulator are implied-mode
instruction.
Zero address instructions in a stack organized computer are implied mode
instructions.
Example: CLA, CMA, INC,CLE
4
10/1/2023
Addressing Modes
• Immediate Mode:
• Operands is specified in the instruction itself.
• Immediate mode instruction has an operand field rather
than an address field.
• Useful for initializing registers to a constant value.
• Operand field: Actual Operand + Operation
Example: 1
MOV AL, 35H (move the data 35H into AL register)
ADD, 7
Addressing Modes
• Register Mode:
• Operands are in Registers that reside with in the CPU.
• Any one of 2k Registers are selected from the k-bit of the
register field in the instruction.
Example: AC ← AC + [R]
5
10/1/2023
Addressing Modes
• Register Indirect Mode:
• Instruction specifies a register in the CPU whose
content give the address of the operand in the memory.
• Selected register contains the address of the operand
rather than the operand itself.
• Example: AC ← AC + M[R]
Addressing Modes
• Auto-increment or Auto-decrement Mode:
• Register is incremented (after) or decremented (before) its value is used to
access memory (the execution of the instruction).
• Special mode that automatically increments or decrements the register
content.
• Add R1, -(R2) // OR R2 = R2 - d , R1 = R1 + M[R2]
• Add R1, (R2)+ // OR R1 = R1 +M[R2], R2 = R2 + d
6
10/1/2023
Addressing Modes
• Direct Addressing Mode:
• The operand resides in memory and its address is given
directly by the address field of the instruction (Effective
address).
• Single memory reference to access data.
• Effective address is equal to the address part of the
instruction.
Addressing Modes
• Indirect Address Mode:
• Address field of the instruction gives the address where the
effective address is stored in memory.
• Two references to memory are required to fetch the
operand.
7
10/1/2023
Addressing Modes
• Displacement addressing Mode:
• In this the contents of the indexed register is added to the Address part of the
instruction, to obtain the effective address of operand.
• EA = A + (R), In this the address field holds two values, A(which is the base
value) and R(that holds the displacement), or vice versa.
Addressing Modes
• Relative Addressing Mode:
• It is a modified version of Displacement addressing mode.
• In this the contents of PC(Program Counter) is added to address part of
instruction to obtain the effective address.
• EA = A + (PC), where EA is effective address and PC is program counter.
(Relative to the address of the next instruction).
• The operand is A cells away from the current cell (the one pointed to by PC)
8
10/1/2023
Addressing Modes
• Base register addressing mode:
• It is again a version of Displacement addressing mode.
• Effective address : address part of the instruction + content of a
base register.
• This can be defined as EA = A + (R), where A is displacement
and R holds pointer to base address.
9
10/1/2023
10