0% found this document useful (0 votes)
266 views

Addressing Modes

Addressing modes refer to the different ways that a processor can access operands in memory or I/O devices. Some common addressing modes include immediate, where the operand is contained in the instruction; register, where the operand is in a register; direct, where the effective address is contained in the instruction; and indirect, where the effective address is obtained by reading the contents of a register or memory location. Addressing modes provide flexibility and efficiency in how instructions specify operands.

Uploaded by

Cineboy SkV
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
266 views

Addressing Modes

Addressing modes refer to the different ways that a processor can access operands in memory or I/O devices. Some common addressing modes include immediate, where the operand is contained in the instruction; register, where the operand is in a register; direct, where the effective address is contained in the instruction; and indirect, where the effective address is obtained by reading the contents of a register or memory location. Addressing modes provide flexibility and efficiency in how instructions specify operands.

Uploaded by

Cineboy SkV
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 26

ADDRESSING

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.

◻ Effective address = Address field

◻ Single memory reference to access data.

◻ No additional calculations to find the effective address


of the operand.
Register addressing mode
◻ The operand is the contents of a processor register; the name
(address) of the register is given in the instruction.

◻ EA = R

◻ Advantages:

□ Only a small address field is needed – Shorter


instructions

□ No memory access – Fast execution is possible


Indirect addressing mode
◻ In this mode address field of instruction contains the address of effective
address.
◻ Here two references are required.
■ 1st reference to get effective address.
■ 2nd reference to access the data.
◻ 2 types of indirect addressing
■ Register indirect
■ Memory indirect
Memory Indirect addressing mode
◻ The effective address of the operand is the contents of the memory
location whose address appears in the instruction.

◻ Memory cell pointed to by address field contains the address of


(pointer to) the operand.

◻ EA = (A) —Look in A, find address (A) and look there for operand

◻ Advantage: Large address space —2n where n = word length

◻ Disadvantage: Multiple memory accesses to find operand slower


Register Indirect addressing mode
◻ The effective address of the operand is the contents of a
register whose address appears in the instruction.
◻ EA = (R)
◻ Operand is in memory cell pointed to by contents of
register R
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)

◻ Use direct and register indirect


Relative addressing mode
◻ For relative addressing, also called PC-relative addressing, the implicitly referenced register is the
program counter (PC).

◻ That is, the next instruction address is added to the address field to produce the EA.

◻ R = PC(Program Counter)

◻ EA = A + (PC)

◻ Current instruction address is added to the address field to produce the EA

■ address field is treated as a twos complement number for this operation

■ Effective address is a displacement relative to the address of the instruction


Base Register addressing mode
◻ It’s a generalized relative addressing, where other registers can play the role of
PC
◻ This can be defined as EA = A + (R)
◻ where A is displacement and R holds pointer to base address.
Indexed addressing mode
◻ It’s a version of displacement addressing.
◻ The address field references a main memory address, and the referenced register
contains a positive displacement from that address.
◻ Opposite of base-register addressing
◻ A = base
◻ (R) = displacement
◻ EA = A + (R), but roles are reversed!
Auto-increment addressing mode
◻ Effective address of the operand is the contents of a register specified in the instruction.
◻ After accessingthe operand, the contents of this register
are automatically incremented to point to the next consecutive memory location.

◻ Add R1, (R2)+ // OR

◻ 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.

◻ Add R1,-(R2) //OR

◻ 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

□ Add r2, 200(r1)


■ r2 = r2 + Mem[300]
□ Add r2, (r1)
■ r2 = r2 + Mem[100]

□ Add r2, @(r1)


■ r2 = r2 + Mem[400]
Summary
Addressing modes
2 marks
□What is the need for indirect addressing mode?
□What is register indirect addressing mode?
8 mark / 13 mark
□What is the need for addressing modes in a computer? Explain in detail about different addressing modes.
Part C
□Examine the following sequence of instructions and identify the addressing modes used and the operation
done in every instruction

a. Move (R5)+, R0 b. Add(R5)+, R0


c. Move R0, (R5) d. Move 16(R5),R3
e. Add #40, R5

You might also like