Memory Addressing


There are total eight addressing modes. Six of the modes are memory addressing: Direct Memory Addressing
In most instructions, one of the operands references a memory location and the other operand references a register. The only instructions that allow both operands to address memory directly are Direct-Offset Addressing
This addressing mode, a variation of direct addressing, uses arithmetic operators to modify an address.

mov eax, X+2 mov eax, X[2] mov eax, [X+2]
 INCLUDE Irvine32.inc
 .data
  X  DWORD  12345678h
 .code
 main PROC
  mov   eax, 0
  mov   eax, X+2
  call  WriteHex
  exit
 main ENDP
 END main
 INCLUDE Irvine32.inc
 .data
  X  DWORD  12345678h
 .code
 main PROC
  mov   eax, 0
  mov   eax, X[2]
  call  WriteHex
  exit
 main ENDP
 END main
 INCLUDE Irvine32.inc
 .data
  X  DWORD  12345678h
 .code
 main PROC
 mov   eax, 0
 mov   eax, [X+2]
 call  WriteHex
  exit
 main ENDP
 END main
Output Output Output

 

 

 

 

 

 




      “I’m not arguing, I’m just explaining why I’m right.”    
      ― Unknown