You are on page 1of 20

Addressing Modes

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University


Outline
• Addressing Modes
• Addressing Mode
• 1) To give programming versatility to the user
• pointers to memory, counters for loop control, indexing of data, ….
• 2) To reduce the number of bits in the addressing field of the instruction
• Instruction Cycle
• 1) Fetch the instruction from memory and PC + 1
• 2) Decode the instruction
• 3) Execute the instruction

• Program Counter (PC)


• PC keeps track of the instructions in the program stored in memory
• PC holds the address of the instruction to be executed next
• PC is incremented each time an instruction is fetched from memory

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University


Addressing Mode -Classification

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University


Types of Addressing Mode
• Implied Mode
• Operands are specified implicitly in definition of the instruction
• Examples
• COM : Complement Accumulator
• Operand in AC is implied in the definition of the
instruction
• PUSH : Stack push
• Operand is implied to be on top of the stack
• Immediate Mode
• Operand field contains the actual operand
• Useful for initializing registers to a constant value
• Example : LD #NBR

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University


Register Addressing Mode
• Register Mode
• Operands are in
registers
• Register is selected
from a register field in
the instruction
• k-bit register field can
specify any one of 2k
registers
• Example : LD R1

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University


Register Indirect
Addressing Mode
• Register Indirect Mode
• Selected register
contains the address
of the operand rather
than the operand itself
• Address field of the
instruction uses fewer
bits to select a
memory address
• Register select bit
• Example : LD (R1)
AC  R1 Implied Mode

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University


Direct Addressing Mode

• Direct Addressing Mode


• Effective address is
equal to the address
field of the instruction
(Operand)
• Address field specifies
the actual branch
address in a branch-type
instruction AC  M [ ADR]
ADR = Address part of Instruction
• Example : LD ADR

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University


Indirect
Addressing Mode
• Indirect Addressing Mode
• Address field of instruction
gives the address where the
effective address is stored in
memory
• Example : LD @ADR
AC  M [ M [ ADR]]

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University


Auto increment or
Autodecrement Mode
• Autoincrement or Autodecrement Mode
• Similar to the register indirect mode except that
• the register is incremented after its value is used to access memory
• the register is decrement before its value is used to access memory
• Example (Autoincrement) : LD (R1)+ AC  M [ R1], R1  R1  1

• Extension to Register indirect addressing mode.


• Register incremented or decremented before or after accessing
memory
• Useful while transferring large chunks of contiguous data.
Relative Addressing
Mode
• Relative Addressing
Mode
• PC is added to the
address part of the
instruction to obtain
the effective address
AC  M: [LD
• Example PC  ADR]
$ADR

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University


Based and Indexed Addressing
Mode
• Indexed Addressing Mode
• XR (Index register) is added to the address part of the instruction to obtain
the effective address
• Example : LD ADR(XR)
AC  M [ ADR  XR]
• Base Register Addressing Mode
• the content of a base register is added to the address part of the instruction
to obtain the effective address
• base register (BR) : LD ADR(BR
• base register hold a base address AC  M [ BR  ADR]
• the address field of the instruction gives a displacement relative to this base address

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University


Basic Addressing Modes
Differences

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University


Problems
• Find the effective address and the content of AC for the given
data.

V.Saritha, SCSE, VIT University


Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University
Addressing Mode Effective Content of AC
Address
Direct Address 500 AC ← (500) 800
Immediate operand 201 AC ← 500 500
Indirect address 800 AC ← ((500)) 300
Relative address 702 AC ← (PC + 500) 325
Indexed address 600 AC ← (XR + 500) 900
Register - AC ← R1 400
Register Indirect 400 AC ← (R1) 700
Autoincrement 400 AC ← (R1)+ 700
Autodecrement 399 AC ← -(R1) 450

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University


Questions
• An instruction is stored at location 300 with its address field at
location 301. The address field has the value 400. A processor
register R1 contains the number 200. Evaluate the effective
address if the addressing mode of the instruction is (a) direct; (b)
immediate (c) relative (d) register indirect; (e) index with R1 as
the index register.

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University


Cont ‘

• An address field in an instruction contains decimal value


14. where is the corresponding operand located for:
• Immediate addressing?
• Direct addressing?
• Indirect addressing?
• Register addressing?
• Register indirect addressing?

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University


Problems
• A two-word instruction is stored in memory at an address
designated by the symbol W. The address field of the
instruction (stored at W + 1) is designated by the symbol Y.
The operand used during the execution of the instruction is
stored at an address symbolized by Z. An index register
contains the value X. State how Z is calculated from the
other addresses if the addressing mode of the instruction is
– Direct
– Indirect
– Relative
– Indexed

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University


• Assume that in a certain byte-addressed machine all
instructions are 32 bits long. Assume the following state of
affairs for the machine: Fill in the following table:

Immediate
Direct

Indirect
Register
Register Indirect
Based
Relative

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University


• Given the following memory values and a one-address machine with an
accumulator, what values do the following instructions load into the
accumulator?
– Word 20 contains 40
– Word 30 contains 50
– Word 40 contains 60
– Word 50 contains 70
• Load immediate 20
• Load direct 20
• Load indirect 20
• Load immediate 30
• Load direct 30
• Load indirect 30
• Let the address stored in the program counter be designated by the symbol
X1. The instruction stored in X1 has the address part (operand reference)
X2. The operand needed to execute the instruction is stored in the memory
word with address X3. An index register contains the value X4. What is
the relationship between these various quantities if the addressing mode of
the instruction is (a) direct (b) indirect (c) PC relative (d) indexed?

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University


References
• W. Stallings, Computer organization and architecture,
Prentice-Hall,2000
• M. M. Mano, Computer System Architecture, Prentice-Hall

Prepared by I. Mala Serene, AP(SG), SCOPE, VIT University

You might also like