[英]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.