Endianness inside CPU registers
- by Abhishek Tamhane
I need help understanding endianness inside CPU registers of x86 processors. I wrote this small assembly program:
section .data
section .bss
section .text
global _start
_start:
nop
mov eax, 0x78FF5ABC
mov ebx,'WXYZ'
nop ; GDB breakpoint here.
mov eax, 1
mov ebx, 0
int 0x80
I ran this program in GDB with a breakpoint on line number 10 (commented in the source above). At this breakpoint, info registers shows the value of eax=0x78ff5abc and ebx=0x5a595857.
Since the ASCII codes for W, X, Y, Z are 57, 58, 59, 5A respectively; and intel is little endian, 0x5a595857 seems like the correct byte order (least significant byte first). Why isn't then the output for eax register 0xbc5aff78 (least significant byte of the number 0x78ff5abc first) instead of 0x78ff5abc?