Professional Documents
Culture Documents
Disadvantage:
1. The address space is very limited.
Register Indirect Addressing
Just as register addressing is analogous to direct addressing, register
indirect addressing is analogous to indirect addressing. In both cases,
the only difference is whether the address field refers to a memory
location or a register. Thus, for register indirect address,
EA = (R)
• The advantages and limitations of register indirect addressing are
basically the same as for indirect addressing. In both cases, the
address space limitation of the address field is overcome by having
that field refer to a word length location containing an address.
• In addition, register indirect addressing uses one less memory
reference than indirect addressing.
Displacement Addressing
• A very powerful mode of addressing combines the capabilities of direct
addressing and register indirect addressing.
• It is known by a variety of names depending on the context of its use, but
the basic mechanism is the same.
• We will refer to this as displacement addressing:
EA = A + (R)
• Displacement addressing requires that the instruction have two address
fields, at least one of which is explicit.
• The value contained in one address field (value = A) is used directly.
• The other address field, or an implicit reference based on opcode, refers to
a register whose contents are added to A to produce the effective address.
Contd..
• Three of the most common uses of displacement addressing:
Relative addressing
Base-register addressing
Indexing
Stack Addressing
• A stack is a linear array of locations. It is sometimes referred to as a
pushdown list or last-in-first-out queue.
• The stack is a reserved block of locations. Items are appended to the
top of the stack so that, at any given time, the block is partially filled.
• Associated with the stack is a pointer whose value is the address of
the top of the stack.
• Alternatively, the top two elements of the stack may be in processor
registers, in which case the stack pointer references the third element
of the stack.
• The stack pointer is maintained in a register. Thus, references to stack
locations in memory are in fact register indirect addresses.
Stack Organization
• A stack is a data storage structure in which the most recent thing
deposited is the most recent item retrieved.
• It is based on the LIFO concept (Last-in-first-out).
• The stack is a collection of memory locations containing a register
that stores the top-of-element address in digital computers.
Stack's operations are:
Push: Adds an item to the top of the stack.
Pop: Removes one item from the stack's top.
Contd..
What is Stack Organization?
• The Last In First Out (LIFO) list is another name for stack. It is the
CPU's most crucial feature. It saves information so that the last
element saved is retrieved first. A memory space with an address
register is called a stack. This register, known as the Stack Pointer,
affects the stack's address (SP). The address of the element at the top
of the stack is continuously influenced by the stack pointer.
Implementation of Stack
The stack can be implemented using two ways:
1. Register Stack
2. Memory Stack
Stack Organization
Contd..
Register Stack
• The stack can be arranged as a set of memory words or registers.
Consider a 64-word register stack arranged as displayed in the figure.
The stack pointer register includes a binary number, which is the
address of the element present at the top of the stack. The three-
element A, B, and C are located in the stack. See Figure on next Slide.
• The element C is at the top of the stack and the stack pointer holds
the address of C that is 3. The top element is popped from the stack
through reading memory word at address 3 and decrementing the
stack pointer by 1. Then, B is at the top of the stack and the SP holds
the address of B that is 2. It can insert a new word, the stack is
pushed by incrementing the stack pointer by 1 and inserting a word in
that incremented location.
Figure: Register Stack
Contd..
• Because 26 = 64 and the SP cannot exceed 63, the stack pointer has 6
bits (111111 in binary). After all, if you multiply 63 by 1, the outcome
is 0(111111 + 1 = 1000000). Only the six least important bits are
stored in SP. The result of decrementing 000000 by one is 111111.
• As a result, the one-bit register 'FULL' is set to 1 when the stack is full.
The binary information constructed into or readout of the stack is
stored in the data register DR.
• First, the SP is set to 0, the EMTY to 1, and the FULL to 0. The push
operation is used to insert a new piece because the stack is not yet
full (FULL = 0).
Contd..
Memory Stack:
A stack may be implemented in a computer's random access memory
(RAM). A stack is implemented in the CPU by allocating a chunk of
memory to a stack operation and utilizing a processor register as a
stack pointer. The stack pointer is a CPU register that specifies the
stack's initial memory address.
Reverse Polish Notation In Stack
• The reverse polish notation in the stack is also known as postfix
expression. Here, we use stack to solve the postfix expression.
• From the postfix expression, when some operand is found, we push it
into the stack, and when some operator is found, we pop elements
from the stack, and after that, the operation is performed in the
correct sequence, and the result is also stored in the stack.
Contd..
For example, we are given this expression in the form of an array