汇编语言:cbw

发布于 2024-12-12 17:17:58 字数 113 浏览 5 评论 0原文

我不确定 cbw 命令实际上是做什么的。我有一段代码:

mov  ax,0FF0h
cbw
idiv ah

cbw 之后 ax 的值如何变化?

I am unsure of what the cbw command actually does. I have a snippet of code:

mov  ax,0FF0h
cbw
idiv ah

How does the value of ax change after cbw?

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

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

发布评论

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

评论(1

水中月 2024-12-19 17:17:58

cbw 指令将一个字节符号扩展为一个字。在这种情况下,它将获取 AL 的符号位(恰好为 1)并将其复制到 AH 的每一位中。

这意味着 AX 的补码值将相同,但二进制表示形式将不同。

cbw 指令之后的 AX 的值为 FFF0h(一个 16 位 -16 值,就像 AL 原本是8位-16)

The cbw instruction sign-extends a byte into a word. In this case, it'll take the sign bit of AL (which happens to be 1) and copy it into every bit of AH.

This means that the two's-complement value of AX will be the same, but the binary representation will be different.

The value of AX after the cbw instruction will be FFF0h (a 16-bit -16 value, just like AL was originally an 8-bit -16)

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