将单词放入记忆中

发布于 2024-08-19 23:52:04 字数 227 浏览 2 评论 0原文

我正在使用 pcspim 模拟器,我的处理器是 Intel x86(小端)

据我了解,声明 .word -5 应该将 以下字节 1111 1011 1111 1111 1111 1111 1111 1111(小端)。但是模拟器 pcspim 以大端顺序将该单词放入内存中 意思是:1111 1111 1111 1111 1111 1111 1111 1011。 谁能解释一下这个? 预先感谢,

xyoavx

I'm using pcspim simulator and my processor is an Intel x86 (little endian)

As I understand, the declaration .word -5 should place in memory the
following bytes
1111 1011 1111 1111 1111 1111 1111 1111 (little endian). But the simulator
pcspim places this word in memory in a big-endian order it
means: 1111 1111 1111 1111 1111 1111 1111 1011.
Who can explain this ?
Thanks in advance,

xyoavx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傻比既视感 2024-08-26 23:52:04

spim 文档 说:

SPIM 的字节顺序与运行模拟器的底层机器的字节顺序相同。

所以你是对的,字节顺序在你的机器上应该是小尾数。您确定正在查看字节顺序视图吗?如果您一次查看内存中的一个字,那么您正在查看的视图通常会混合字节。例如:

按字节:

fb ff ff ff ff ff ff ff
ef cd ab 89 67 45 23 01

按字:

fffffffffffffffb
0123456789abcdef

另一种可能性是您构建的 pcspim 实际上是在模拟大端处理器。

The spim docs say:

SPIM’s byte order is the same as the byte order of the underlying machine that runs the simulator.

So you're right, the byte order should be little endian on your machine. Are you sure you're looking at a byte ordered view? If you're looking at the memory word-at-a-time, the view you're looking at usually swizzles the bytes around. For example:

By byte:

fb ff ff ff ff ff ff ff
ef cd ab 89 67 45 23 01

By word:

fffffffffffffffb
0123456789abcdef

The other possibility is that your build of pcspim is actually simulating a big-endian processor.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文