汇编语言:cbw
我不确定 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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 ofAL
(which happens to be 1) and copy it into every bit ofAH
.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 thecbw
instruction will beFFF0h
(a 16-bit -16 value, just likeAL
was originally an 8-bit -16)