Addressing Modes
Addressing Modes
MODES
Addressing modes
◻ Processor allows programmer to refer data stored in the memory or I/O device in different
ways.
◻ The different ways that a processor can access data are referred as addressing modes.
◻ An addressing mode specifies how to calculate the effective of an operand by using elements
of effective information held in registers and/or constants contained within a machine
instruction.
◻ Addressing Modes are an instruction set used for communicating with the central processing
unit (CPU) for performing any specific task.
Addressing modes
◻ Addressing modes refers to the way in which the operand of an instruction is specified.
◻ The addressing mode specifies a rule for interpreting or modifying the address field of the
instruction before the operand is actually executed.
◻ An address computed by the processor when executing a memory access or branch
instruction or when fetching the next sequential instruction is known as Effective
Address.
◻ An effective address can be made from 3 elements: the base, index and displacement.
Need for addressing modes
◻ To give the programming versatility to the user.
◻ To reduce the number of bits in addressing field of
instruction.
Types of addressing modes
◻
◻ Immediate
Relative
◻ Absolute or direct ◻ Base
register
◻ Register ◻ Index
◻ Indirect ◻ Auto-increment
◻ Register indirect ◻ Auto-decrement
◻
◻ Displacement
Stack
Immediate addressing mode
◻ Operand is part of instruction.
◻ Operand = operand field.
◻ It is used for constants.
◻ No memory reference to fetch
data
◻ Fast
◻ Limited range
Direct addressing mode
◻ The address field contains the effective address of the
operand.
◻ EA = R
◻ Advantages:
◻ EA = (A) —Look in A, find address (A) and look there for operand
◻ EA = A + (R)
◻ In this the address field holds two values, A(which is the base
value) and R(that holds the displacement)
◻ That is, the next instruction address is added to the address field to produce the EA.
◻ R = PC(Program Counter)
◻ EA = A + (PC)
◻ R1 = R1 +M[R2]
◻ R2 = R2 + d
Auto-decrement addressing mode
◻ Effective address of the operand is the contents of a register specified in the instruction.
◻ Before accessingthe operand, the contents of this register
are automatically decremented to point to the previous consecutive memory
location.
◻ R2 = R2-d
◻ R1 = R1 + M[R2]
Stack addressing mode
◻ Operand is (implicitly) on top of the stack
◻ E.g. ADD
◻ Pop top two items from stack, Add them,
Push result on top of stack
Examples
Examples
Examples
Examples
Problems
◻ Find the effective memory
address
■ Add r2, 200(r1)
■ Add r2, (r1)
■ Add r2, @(r1)
Problems
◻ Find the effective memory address