Endianness inside CPU registers

Posted by Abhishek Tamhane on Stack Overflow See other posts from Stack Overflow or by Abhishek Tamhane
Published on 2010-12-21T23:01:42Z Indexed on 2010/12/22 2:54 UTC
Read the original article Hit count: 367

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?

© Stack Overflow or respective owner

Related posts about x86

Related posts about endianness