问题
I am new to assembly language. I am trying the below code and as you can see the below code.
bits 64
global _start
section .text
_start:
mov rcx, 1234567890
xor rcx, rcx
mov rcx, 'wxyz'
mov rax, 60
mov rdi, 0
syscall
I would like to know why digits are stored as Big endian in register and characters are stored in registers as Little-endian
Below screenshots are from the debugger.
I thought only in the memory, data is stored as Little endian. But I don't understand why the characters are stored as Little endian in the register. Kindly let me know.
Thank you.
回答1:
Speaking about CPU registers' endianness doesn't make much sense because addresses are not assigned to the particular bytes that made up the registers, i.e.: there is no byte order to be considered.
That is, for example al is the lowest byte of rax, and ah the second lowest. With this in mind, what is the address of al and ah? Is ah's address higher or lower than al address? They don't have (memory) addresses associated, and therefore there is no byte order at all to consider.
What is relevant is how those bytes are stored into memory (e.g.: by means of a mov instruction). The endianness determines that. For a little-endian machine, the lowest byte of the register will be placed at the lowest address of the destination operand, for a big-endian machine at the highest address. The endianness is similarly relevant for loading a memory operand into a register.
In short, in order to speak about endianness there must be a kind of mapping between bytes' significance and the highness of their corresponding addresses.
来源:https://stackoverflow.com/questions/48645360/assembly-language-why-are-characters-stored-in-register-as-little-endian