0

Consider the following code (x86-64):

MOV DWORD PTR [rbp-4], 43777  ; 43777 -> 00 00 AB 01
MOV EAX, DWORD PTR [rbp-4]

If we have little-endian, then 00 00 AB 01 will be stored in RAM as 01 AB 00 00.

But what about register EAX? Is it stores number as 00 00 AB 01 or as 01 AB 00 00?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
No Name QA
  • 724
  • 1
  • 6
  • 20
  • 4
    `eax` doesn't have a byte order as a register. `al` and `ah` and `ax` are defined as parts, but `eax` cannot in general be accessed byte by byte. The endianness only shows up in byte-addressable storage, that is, memory. – ecm Aug 14 '20 at 09:24
  • bit 31 is bit 31 and bit 0 is bit 0 so if the 32 bit number is 0x0000AB01, then that is how it is stored, no bit nor byte modifications. Endianness has to do with byte addressing not how it is stored in memory nor registers. (it doesnt affect ram either since it has been a long time since we have used an 8 bit data bus) – old_timer Aug 14 '20 at 13:38
  • 4
    Registers do not have addresses. They cannot be indexed by software; they can only be named in machine code instructions. As a consequence, we cannot observe the endianness of registers; therefore the concept of endianness does not apply to registers. – Erik Eidt Aug 14 '20 at 15:32

0 Answers0