简体   繁体   English

这个加法之后怎么没有设置溢出标志?

[英]How is the overflow flag not set after this addition?

I'm learning about x86 assembly(8086 to be more specific) and I'm confused about the concept of flags, I tried searching about it online and found this image:我正在学习 x86 程序集(更具体地说是 8086),我对标志的概念感到困惑,我尝试在网上搜索并找到这张图片:

图片

According to the image, after the addition operation of the two 16 bit numbers, the OF flag is still clear at 0.如图所示,两个16位数字相加运算后,OF标志位依然清0。

But I've learnt that if the MSB of the two numbers to be added is off (so a 0) and the MSB of the result is a 1, then overflow has occurred.但是我了解到,如果要添加的两个数字的 MSB 关闭(因此为 0)并且结果的 MSB 为 1,则发生溢出。

Link to the webpage I've learned this from: http://teaching.idallen.com/dat2343/10f/notes/040_overflow.txt链接到我从中了解到的网页: http://teaching.idallen.com/dat2343/10f/notes/040_overflow.txt

Can someone explain why the OF is still at 0 please?有人可以解释为什么OF仍然为0吗?

Just do the math by hand用手算算

setup both of them设置它们

  0110 0101 1101 0001
+ 0010 0011 0101 1001
=========================

                    1
  0110 0101 1101 0001
+ 1101 1100 1010 0110
=======================

start working both of them开始工作

              10 0010
  0110 0101 1101 0001
+ 0010 0011 0101 1001
=========================
              10 1010


                 1111
  0110 0101 1101 0001
+ 1101 1100 1010 0110
=======================
                 1000

and already they do not match他们已经不匹配了

 11111 1011 0000 1111
  0110 0101 1101 0001
+ 1101 1100 1010 0110
=======================
  0100 0010 0111 1000

No borrow so borrow flag = 1, carry flag = 1 (inverse of borrow).没有借位,所以借位标志 = 1,进位标志 = 1(借位的倒数)。 The msbit in and out are the same so no signed overflow. msbit in 和 out 相同,因此没有符号溢出。 not zero so no zero flag.不为零,所以没有零标志。 And msbit is zero so negative flag is zero.并且 msbit 为零,因此负标志为零。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ROL 操作后溢出标志设置为 1,即使它应该未定义 - Overflow flag set to 1 after ROL operation even though it should be undefined 理解 IMUL 指令设置的溢出标志的问题 - Problem in understanding the Overflow flag set by IMUL instruction 如何为证书管理器设置标志 - How to set a flag for cert-manager 如何在 dataproc 中使用 --properties-file 标志? - How to use --properties-file flag in dataproc? 如何标记累计总收入的百分比 - how to flag % revenue from a cumulative total 如何添加一个列,该列根据另一列的条件对其他列的值进行字符串加法 - How to add a column which does a string addition of values from other column based on condition from another column 如何在 Go 测试中使用带有 testify/suite 的自定义标志 - How to use custom flag with testify/suite in Go test 如何使用 Terraform 删除现有 GCP 云 function 的“允许未经身份验证”标志? - How to remove 'allow unauthenticated' flag of existing GCP cloud function using Terraform? 如何下载所有存储桶文件。 (-m 标志 gsutil 的问题) - How to download all bucket files. (The issue with the -m flag gsutil) boto3 `list_discovered_resources` 方法返回已删除的资源,即使标志 `includeDeletedResources` 设置为 False - The boto3 `list_discovered_resources` method is returning deleted resources even when flag `includeDeletedResources` is set to False
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM