位级字节顺序
如何在位级别检查操作系统的“字节顺序”或者操作系统是否关心位的存储顺序?
How to check the 'endianness' of OS at bit-level or Does an OS even care in what order the bits are stored?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
char
是最小的可寻址内存单元,因此您不必关心超出该级别会发生什么 - 无论如何您都无法读取/写入小于char
的内容,因此这个想法“位级字节顺序”没有意义。char
is the smallest addressable unit of memory, so you don't care what happens beyond that level - you can't read/write less thanchar
anyway, hence the idea of "endianness-at-bits-level" makes no sense.由于字节(8 位)是我听说过的任何架构上的最小可寻址单元,因此这个问题是无关紧要的。我总是将“4”位访问为
1 << 2
,这是地址空间中的第三个还是第六个晶体管都无关紧要。然而,字节级字节序非常重要,因为我可以将大字节序架构上的第九个最低有效位设置为
*x | (1 << 9)
或*(x+1) | 1.
.Since a byte (8bits) is the smallest addressable unit on any architecture I have ever heard of, the question is irrelevant. I always access the "4" bit as
1 << 2
, whether this is the 3rd or 6th transistor at the address space is irrelevant.Byte level endianness is however important because I can set the ninth least significant bit on a big endian architecture as
*x | (1 << 9)
or*(x+1) | 1
.