Addressing Modes and its Types

 Topic Outline

  • Addressing Modes
  • Types
  • Which Addressing Modes are fastest and why?

Addressing Modes

Definition

"The method of specifying the source of operand and output of result in an instruction is known as addressing modes."

Addressing mode is the way of addressing a memory location in instruction. The microcontroller needs data or operands on which the operation is to be performed. The operand may be mentioned directly or specified in the register/memory.

Types of Addressing Modes

(1) Immediate Addressing Mode

  • One of the operands is mentioned directly.
  • Data is available as a part of instruction.
  • Data is 8 or 16 bits long.
  • No memory reference is needed to fetch data.
Shape

Example

MOV CL , 03H

03 -> 8 bit immediate source operand.

CL -> 8-bit register destination operand.

(2) Register Addressing Mode

  • Both the operands are in registers.
  • No memory access.
  • a Limited number of registers.
  • Very small address field is needed to address registers.
  • Shorter instructions.

Register 

Address 

ES 

00 

CS 

01 

SS 

10 

DS 

11 

Example

  • 16-bit register instruction
MOV AX, BX
  • 8-bit register instruction

ADD AX, DI

MOV CL, DL

ADD AL, CL

(3) Direct Addressing Mode

  • One or both the operands are in memory.
  • Operand in memory is specified through its effective address.
  • Default segment register.
  • Data in that location will be used for specified operating.
  • If the instruction contains stack operation segment register will be SS.
  

Example

MOV CX, [0400]

[DS]= 30500

PA: 30500+0400=30540

[30540]-> CL

[30541]-> CH

(4) Register indirect Addressing Mode

  • EA of operands is specified in the register.
  • Physical address is computed using segment register and EA.
  • Data in the physical address is an operand.
Shape 

Example (1)

MOV AX, [BX]

[DS]=5004,[BX]=0020,PA=50060

50060 contain 0015H

0015H is moved to memory AX

Example (2)

MOV [BX],[AX]

Source and destination address is calculated by AX and BX content respectively.
The content of the source address is moved to the destination address.

(5) Register Relative Addressing Mode

  • Effective address=[Base/pointer register] + 8 or 16 bit displacement.
  • Base/pointer register: BX or BP or SI or DI.

Example

MOV AX, 10[BP]

[BP]=0105,[DS]=2020

P.A=20200+0105+10=20315

Content of memory address 20315 is moved to AX

(6) Based Indexed Addressing Mode

  • Effective address=[Base register]+[Index register].
  • Base register-> BX or BP.
  • Index register-> SI or DI.

Example

MOV AX,[BX][SI]

[BX]=1500[SI]=0020[DS]=2020

P.A of source 20200 +1500+0020= 21720

Content of 21720 is moved to AX

(7) Relative Based Indexed Addressing Mode

  • Effective address=[Base register]+[Index register]+8 or 16 bit displacement

Example

MOV CX, 1010[BX][SI]

[BX]=1028[SI]=0003[DS]=2020

PA=20200+102B+0008+1010=2223E

Content of Memory address 2223E is moved to CX

Which  Addressing Mode is fastest and Why?

  • Register addressing mode is fast.
  • Memory reference requires 20 bits.
  • a limited number of registers.
  • Very small address field needed.
  • Shorter instructions.
  • Faster Instructions fetch.
  • Register references require only 2 or 3 bits.

Here are some registers that are used in addressing modes.

  • AX (Accumulator Register )

Favored by CPU for arithmetic operations.

  • BX (Base Register)

Can hold the address of a procedure of variable (SI, DI, BP). It can also perform arithmetic and data movement.

  • CX(Counter Register)

Acts as a counter for repeating or looping instructions.

  • BP ( Base Pointer)

Contains an assumed offset from the SS register.

  • SP (Stack Pointer)

Contains the offset of the top of the stack.

  • SI (Source Index) 

Used in string movement instructions. The source string is pointed to by the SI register.

  • DI (Destination Index)

Acts as the destination for string movement instructions.



Comments

Post a Comment

If you have any doubts, please let me know

Popular Posts

Computer Abbreviation

Transport Layer

Introduction to Database

Types of database

Threads in operating system

Display devices

Shortcut keys of computer

History of Computer