I need help understanding endianness inside CPU registers of x86 processors. I wrote this small assembly program:
section .data
section .bss
section .text
Endianness makes sense only for memory, where each byte have a numeric address. When MSByte of a value is put in higher memory address than the LSByte, it's called Littte endian, and this is the endianness of any x86 processor.
While for integers the distinction between LSByte and MSByte is clear:
0x12345678
MSB---^^ ^^---LSB
It's not defined for string literals! It's not obvious what part of the WXYZ should be considered LSB or MSB:
1) The most obvious way,
'WXYZ' -> 0x5758595A
would lead to memory order ZYXW.
2) The not not so obvious way, when the memory order should match the order of literals:
'WXYZ' -> 0x5A595857
The assembler have to choose one of them, and apparently it chooses the second.