Slide 5.10: Defining other data
Slide 5.12: Symbolic constants
Home

Little Endian Order


Intel processors store and retrieve data from memory using the little endian order. This means that the least significant byte of a variable is stored at the lowest address, that is, the word is stored “little-end-first.” The remaining bytes are stored in the next consecutive memory positions.
Assume the starting offset is 0. A doubleword 12345678h is stored as:
Little Endian Order
Definition X SDWORD 12345678h
 Offset  0000 0001 0002 0003
 Value  78 56 34 12

 Retriving the Third Byte   Clearing the Value 12   Switching the Lower
  and Upper Words 
 .data
 X   SDWORD  12345678h
 .code
 mov  ebx, OFFSET X + 2
 sub  eax, eax
 mov  al, [ebx]
 call WriteHex


 .data
 X  SDWORD   12345678h
 .code
 
 mov   eax, X
 call  WriteHex

 


 .data
 X  DWORD   12345678h
 
 .code
 mov   ebx, OFFSET X
 mov   ax, [ebx+2]
 mov   Y, ax
 mov   ax, [ebx]
 
 mov   ebx, OFFSET Y
 mov   eax, [ebx]
 call  WriteHex
 

 Output  Output  Output
   



  00345678h     56781234h  

Some computers use the big endian order, which is the reverse of the little endian order.
Assume the starting offset is 0. A doubleword 12345678h is stored as:
Big Endian Order
Definition X SDWORD 12345678h
Offset 0000 0001 0002 0003
Value 12 34 56 78