0% found this document useful (0 votes)
136 views20 pages

Addressing Modes

The document discusses different addressing modes used in processors to access operands in instructions. It describes common addressing modes like immediate, register, absolute, indirect, index, relative, auto-increment and auto-decrement. It also explains how variables, constants, pointers and arrays are implemented using these addressing modes in assembly language.

Uploaded by

Akhil B Skaria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
136 views20 pages

Addressing Modes

The document discusses different addressing modes used in processors to access operands in instructions. It describes common addressing modes like immediate, register, absolute, indirect, index, relative, auto-increment and auto-decrement. It also explains how variables, constants, pointers and arrays are implemented using these addressing modes in assembly language.

Uploaded by

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

Addressing modes

• The different ways that a processor can access


data are referred to as addressing modes.
or
• The different ways in which the location of an
operand is specified in an instruction are
referred to as addressing modes.
Addressing modes
• Programs are normally written in a high
level language which enables the
programmer to use constants, local and
global variables, pointers and arrays.
• When translating a high level language
program into assembly language, the
compiler must be able to implement these
constructs using the facilities provided in
the instruction set of the computer.
Generic Addressing Modes

• Immediate mode
• Register mode
• Absolute mode
• Indirect mode
• Index mode
• Relative mode
• Auto-increment mode
• Auto-decrement mode
Implementation of variables and
constants
• Variables and constants are the most simplest
and commonly used data types on every
computer.
• A variable is initialized by allocating a register
or memory location to hold its value in
assembly language.
• The addressing modes used for representing
variables are:
• Register mode
• Absolute mode
• Register mode: operand is the contents of a processor
register.
» The name of the register is specified in the instruction.
• Eg: Move R1, R2.
• This instruction copies the contents of register R2 to R1.
• Absolute mode: also known as Direct mode
» The operand is in a memory location.
» The address of the location of the operand is given explicitly as a
part of the instruction.
• Eg: Move A, 2000
• The addressing mode used for representing
constants :
• Immediate mode: operand is given explicitly in the
instruction means operand is part of the instruction itself.
• No memory reference is required to access the operand.
• Eg: Move #200,R0.
• Eg: Move 200 immediate ,R0: It places the value 200 in the
register R0.The immediate mode is used to specify the value
of source operand.
• In assembly language, the immediate subscript is
not appropriate so # symbol is used.
• It can be re-written as : Move #200,R0
• The sharp sign(#) is used in front of the value to
indicate that this value is to be used as an immediate
operand.
• Constant values are used frequently in high level
language programs.
• For eg : A= B+6, this statement contains the constant 6.
• Let us assume that A and B are declared earlier as variables
and may be accessed using absolute mode.

• The compilation of this statement can be done as follows:


• Move B, R1
• Add #6,R1
• Move R1,A
Indirection and Pointers:
• Instruction does not give the operand or its
address explicitly.
• Instead it provides information from which the
new address of the operand can be
determined.
• This address is called effective Address(EA) of
the operand.
• Indirect mode: the effective address of the operand
is the contents of a register or the main memory
location whose address is given explicitly in the
instruction.
• Indirection is denoted by placing the name of the
register or the memory address given in the
instruction in parentheses.
• Indirect mode through a general-purpose register
• Indirect mode through a memory location
Fig 2.11(a) : through a general-purpose
register
• ADD (R1), R0:
• The processor uses the value B, which is in
register R1.
• Then the processor adds this to the contents
of register R0.
• The register or memory location which
provides the address of operand is known as
pointers.
Fig 2.11(b) : through a memory
location
• ADD (A), R0
• Here processor first reads the contents of
memory location A, then requests a second
read operation using the value B as an address
to obtain the operand.
Indexing and Arrays
• Technique that allows programmer to point or
refer the data (operand) stored in sequential
memory locations one by one.
• This type of addressing mode is used in lists
and arrays.
• Index mode: effective address of the operand
is generated by adding a constant value to the
contents of a register. The register used here is
referred to as an index register.
• Symbolic representation of index mode is
• X(Ri)
Where X denotes a constant value in the instruction and
Ri is the name of the register involved.

The effective address of the operand is


EA= X +[Ri]
• To access operand,
• First go to Reg R1 (using address)-read the content from
R1 ie 1000

• Add the content 1000 with offset 20 get the result,


1000+20=1020
Relative addressing
• If we use index addressing mode using PC
instead of general purpose register, we have
relative addressing mode.
• Most commonly used to specify the target
address in branch instruction.
Auto increment mode
• The effective address of the operand is the
contents of a register specified in the
instruction.
• After accessing the operand, the contents of
this register are automatically incremented to
point to the next item in the list.

• (Ri)+
• To access successive words in a byte –addressable
memory with a 32-bit word length, the increment must
be 4.
Auto decrement mode
• The contents of the register are to be
decremented before being used as the
effective address.
• -(Ri)

You might also like