一道简单的组装题

发布于 2024-10-11 15:54:56 字数 136 浏览 6 评论 0原文

我是组装新手,这很有趣。无论如何,我有一个问题......

cmpw cr7, %r29, %r8

该代码是否相当于 if cr7 > %r29 和 %r8

I'm new to assembly, and it's quite fun. Anyways I have one question...

cmpw cr7, %r29, %r8

Is that code the equivalent of if cr7 > %r29 and %r8?

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

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

发布评论

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

评论(1

波浪屿的海角声 2024-10-18 15:54:56

我相信它将 r29 与 r8 进行比较并将结果放入 cr7 中。

换句话说:

cr7 = r29 - r8

读了一些PPC文档后,看起来像cr(比较寄存器),得到一个编码值,代表小于、大于、等于。

less:    0x100
greater: 0x010
equal:   0x001

在其他体系结构中,例如 x86,本身没有 CR,而是一组标志,例如 ZF、SF 和 CF(零、符号和进位标志)。这些总是在算术运算(例如减法)期间设置。因此,比较基本上与减法相同。

It compares r29 to r8 and places the result in cr7 I believe.

In other words:

cr7 = r29 - r8

After reading some PPC docs, it looks like cr (the comparison register), gets a coded value, representing less, greater, equal.

less:    0x100
greater: 0x010
equal:   0x001

In other architectures, such as x86, there is no CR per se, but a group of flags, such as ZF, SF, and CF (zero, sign, and carry flags). Those are always set during arithmetic operations, such as subtraction. Hence a compare is basically the same as a subtract.

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