assembly - My Sign flag value is showing wrong? Am I wrong about how sign flag works?
问题描述
I am adding ax
and bx
. So if MSB of the result is 1 then the sign flag=1 or else sign flag=0. Am I right? If I'm right why sign flag=0 is showing in output? Shouldn't it be SF=1? If I am wrong please correct me. I am confused
mov ax,20h
mov bx,80h
add ax,bx
解决方案
因此,如果结果的 MSB 为 1,则符号标志 = 1,否则符号标志 = 0。我对吗?
您对反映结果最重要位的标志标志是正确的,但是在您的添加中,add ax, bx
您添加了 2 个单词,这就是所有不同之处。
考虑添加字节:
mov al, 20h
mov bl, 80h
add al, bl ; -> AL = 20h + 80h = A0h
结果设置AL
了最高有效位(位 7),因此 SF=1
考虑添加单词:
mov ax, 0020h
mov bx, 0080h
add ax, bx ; -> AX = 0020h + 0080h = 00A0h
结果中AX
的最高有效位(第 15 位)被清除,因此 SF=0
小费
使用所涉及的寄存器可以容纳的尽可能多的数字写入十六进制数字可能会有所帮助。
写mov ax, 0020h
而不是mov ax, 20h
.
推荐阅读
- powershell - 使用 PowerShell 修改具有最高权限的任务的触发器
- firebase - 'GoogleUtilities/AppDelegateSwizzler/Private/GULApplication.h' 文件未找到在反应原生中添加 rnfirebase 时出错
- elasticsearch - 如何改进我的 GeoPoint ElasticSearch 索引以获得更好的响应时间?
- oracle-sqldeveloper - 将 2 个表与表 1 中的子字符串匹配以匹配表 2
- python - 我们如何在 Django 上表示 pandas.series 值?
- ios - 如何创建无限水平滚动视图?
- numpy - 如何在 seaborn 包函数的热图中操作 xticklabels 和 yticklabels?
- python - Python列表:IndexError:列表索引超出范围
- c# - 如何找到数组中的最低ID
- c# - 从真正的随机字节生成的新字节,仍然是真正的随机?