不了解FLAGS状态寄存器 [英] Not understanding FLAGS status register

查看:61
本文介绍了不了解FLAGS状态寄存器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当时正在帮助我的一个朋友进行一些计算机体系结构理论练习.我们偶然发现了这个麦当劳练习一下FLAGS寄存器,并不真正知道如何回答.事情是这样的:

I was helping a friend of mine doing some computer architechture theory exercises. We stumbled on this m.c. exercise about the FLAGS register and don't really know how to answer it. It goes on something like this:

"假定您在两个无符号整数之间执行了ADD操作,并且导致了以下标志设置:CF = 0; OF = 1; ZF = 0; SF = 1.这个设置,为什么?"

"Assume that you've performed an ADD operation between two unsigned integer numbers, and that it resulted in the following flags setting: CF = 0; OF = 1; ZF=0; SF=1 . What can we conclude from this setting and why?"

正确的选择指出该操作的结果正确,并在说出原因时指出因为CF等于零".我的问题是,为什么当其他标志设置为一个时,为什么只需要考虑进位标志呢?而且,当我们在无符号整数之间执行加法运算时,如何将溢出和有符号标志设置为1?

The correct choice states that the result of that operation is correct, and when saying why, it states " because the CF equals zero". My question here is why do we only need to consider the carry flag when there are other flags set to one? And also, how is possible for the overflow and the signed flag to be set to one when we are performing an add operation between to unsigned integers?

提前谢谢!

推荐答案

进位"标志反映了从操作的最高有效位产生的进位.对于无符号操作数,这种进位将反映溢出.

The Carry flag reflects the generation of a carry from the most significant bits of the operation. For unsigned operands, such a carry would reflect an overflow.

对于其他标志,符号标志仅适用于带符号的操作数.对于溢出标志也是如此,因为当由于签名操作的溢出导致符号错误更改时,会置位它.

As for the other flags, the Sign flag is only applicable for signed operands. The same is true for the Overflow flag since it is set when the sign changes incorrectly due to overflow of a signed operation.

当结果为零且与溢出检测无关时,将设置最终标志零.

The final flag, Zero, is set when the result is zero and has no relevance for overflow detect.

在您呈现的示例中,操作数是无符号的,并且清除了进位标志.因此没有发生溢出.

In the example you present, the operands are unsigned and the Carry flag is cleared. So no overflow has occurred.

这篇关于不了解FLAGS状态寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆