汇编语言-为什么将字符存储为小尾数? [英] Assembly language - Why are characters stored in register as little endian?

查看:127
本文介绍了汇编语言-为什么将字符存储为小尾数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是汇编语言的新手.我正在尝试下面的代码,如您所见,下面的代码.

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.

我认为仅在内存中,数据存储为Little Endian.但是我不明白为什么字符在寄存器中存储为Little Endian.请让我知道.

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.

谢谢.

推荐答案

谈论CPU寄存器的字节顺序没有多大意义,因为没有将地址分配给组成寄存器的特定字节,即:没有字节才能被考虑.

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.

也就是说,例如alrax的最低字节,而ah是第二低的字节.考虑到这一点,alah的地址是什么? ah的地址是高于还是低于al的地址?它们没有关联的(内存)地址,因此根本没有字节顺序可供考虑.

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.

重要的是这些字节如何存储到内存中(例如:通过mov指令).字节顺序决定了这一点.对于小端机器,寄存器的最低字节将位于目标操作数的最低地址,对于大端机器,其最高地址.字节顺序对于将内存操作数加载到寄存器中也同样重要.

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.

简而言之,为了谈论字节序,字节的 significance 和字节的 highness 之间必须存在一种 mapping 地址.

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.

这篇关于汇编语言-为什么将字符存储为小尾数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆