是否可以设置86标志贯彻= SIGN =溢出= 1一个另外的insn? [英] Is it possible to set the x86 flags to Carry=Sign=Overflow=1 with one addition insn?

查看:146
本文介绍了是否可以设置86标志贯彻= SIGN =溢出= 1一个另外的insn?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是AT&放大器编程。

I am programming using the AT&T notation on the i386 architecture.

是否有可能以设置进位,溢出和注册标志添加两个8位数字来进行设置,使用单个添加指令?

Is it possible to add two 8-bit numbers in order to set the Carry, Overflow, and Sign Flags to be set, using a single add instruction?

我想这是不可能得到这个组合的标志。为了在S-标志被与O形标志一起设置,这两个数字的最显著位必须是0和结果的最显著位必须是1。这使得我们没有办法产生自除最显著位的进位。

I am thinking it is impossible to get this flag combination. In order for the S-flag to be set together with the O-flag, the most significant bits of both numbers would have to be 0 and the most significant bit of the result would have to be 1. That leaves us with no way to generate a carry from the addition of the most significant bits.

这是我第一次问这个网站的一个问题,所以我道歉,如果我做错了什么。先谢谢了。

This is my first time asking a question on this site, so I apologize if I did anything wrong. Thanks in advance.

编辑:我只能用以下三条指令:

I can ONLY use the following three instructions:

movb $_, %ah
movb $_,%al 
addb %ah,%al

我有十进制值修改两个下划线。

I have to modify the two underscores with decimal values.

编辑:出的CF,OF,SF,ZF和我只能有CF,OF,和SF集。我不能有进位标志设置。

Out of CF, OF, SF, and ZF, I can only have CF, OF, and SF set. I cannot have the Carry Flag set.

(编者注:这最后一句话是没有意义的是,对平价或零标志一个错字,或者也许他的意思是CF不能设置的的的 ADDB ?这是添加,而不是 ADC ,因此它不依赖于$ p标志$ pvious状态。把这个作为一个编辑,而不是在评论中要求澄清,因为这是一个老问题,可能无法得到回应,请编辑出本说明如果/当你解决这个句子关于不能有进位标志设置珊)

(editor's note: That last sentence makes no sense. Is that a typo for Parity or Zero Flag, or maybe he means CF can't be set before the addb? It's add, not adc, so it doesn't depend on the previous state of flags. Leaving this as an edit instead of requesting clarification in a comment because it's an old question that might not get a response. Please edit out this note if/when you fix that sentence about "cannot have the Carry Flag set", Shan.)

推荐答案

无法设置CF = SF = OF = ​​1 添加啊,人。正式的证明将是有些冗长,但一个简单的详尽测试证实船旗国这样的组合后是不可能添加指令。

It is impossible to set CF=SF=OF=1 with add ah, al. A formal proof is going to be somewhat lengthy, but a simple exhaustive test confirms the impossibility of such a combination of flag states after an add instruction.

您可以使用 POPF(D)设置算术标志的任意组合。该指令从栈中弹出一个(D)字,并将其写入(E)标志

You can use POPF(D) to set an arbitrary combination of arithmetic flags. This instruction will pop a (d)word from the stack and write it into (E)FLAGS.

请注意,有其他不相关的算术,在旗标志寄存器。你一般不应对其进行修改。所以,你最好先(使用 PUSHF(D)),修改必要的,然后写回正如上文所述读取寄存器的值。

Note that there are other, unrelated to arithmetic, flags in the flags register. You shouldn't generally modify them. So, you'd typically first read the value of the register (using PUSHF(D)), modify that as necessary and then write back as outlined above.

这篇关于是否可以设置86标志贯彻= SIGN =溢出= 1一个另外的insn?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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