字节序仅在访问双字和八字节相同数据时才重要
Endianness only important when accessing identical data both as a doubleword and as eight bytes
我想我至少了解字节顺序的基础知识,但我无法理解我的计算机组织文本中这一段的最后一句话。有人可以提供一个例子来说明这里提出的观点吗?
Computers divide into those that use the address of the leftmost or “big end” byte as the doubleword address versus those that use the rightmost or “little end” byte. LEGv8 can work either as big-endian or little-endian. Since the order matters only if you access the identical data both as a doubleword and as eight bytes, few need to be aware of the “endianness”.
我应该指出 "LEGv8" 是 ARMv8 指令集的一个子集。
第一部分考虑处理器如何从内存访问数据。它使用某种加载和存储指令结合长度将内存内容传输到寄存器和从寄存器传输。你不需要考虑字节顺序,你只是指示处理器加载,执行其他操作然后存储结果。当使用数据类型的大小时,字节顺序在加载和存储期间是相同的,所以你不关心它是什么。
现在考虑您需要做一些事情,例如通过网络发送相同的双字或保存到文件,例如您可能需要将双字作为单个字节访问的地方。也许网络连接的另一端运行不同的字节顺序。也许文件格式为互操作性指定了某种字节顺序。在这种情况下,您需要知道字节顺序,以便保持正确。
我想我至少了解字节顺序的基础知识,但我无法理解我的计算机组织文本中这一段的最后一句话。有人可以提供一个例子来说明这里提出的观点吗?
Computers divide into those that use the address of the leftmost or “big end” byte as the doubleword address versus those that use the rightmost or “little end” byte. LEGv8 can work either as big-endian or little-endian. Since the order matters only if you access the identical data both as a doubleword and as eight bytes, few need to be aware of the “endianness”.
我应该指出 "LEGv8" 是 ARMv8 指令集的一个子集。
第一部分考虑处理器如何从内存访问数据。它使用某种加载和存储指令结合长度将内存内容传输到寄存器和从寄存器传输。你不需要考虑字节顺序,你只是指示处理器加载,执行其他操作然后存储结果。当使用数据类型的大小时,字节顺序在加载和存储期间是相同的,所以你不关心它是什么。
现在考虑您需要做一些事情,例如通过网络发送相同的双字或保存到文件,例如您可能需要将双字作为单个字节访问的地方。也许网络连接的另一端运行不同的字节顺序。也许文件格式为互操作性指定了某种字节顺序。在这种情况下,您需要知道字节顺序,以便保持正确。