一条指令清除PF(奇偶校验标志)-在结果寄存器中获得奇数位数 [英] One instruction to clear PF (Parity Flag) -- get odd number of bits in result register

查看:257
本文介绍了一条指令清除PF(奇偶校验标志)-在结果寄存器中获得奇数位数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在x86汇编中,是否可以在任何初始寄存器配置下工作,并且仅用一条指令清除奇偶校验标志?

In x86 assembly, is it possible to clear the Parity Flag in one and only one instruction, working under any initial register configuration?

这等效于使用位数设置为 odd 的结果寄存器,并执行任何设置标志的操作(明确表示不包括mov).

This is equivalent to creating a result register with an odd number of bits, with any operation that sets flags (expressly excluding mov).

为了对比,可以通过一条指令设置奇偶校验标志:

For contrast, setting the parity flag can be done in one instruction:

cmp bl, bl

有两种方法可以清除两条指令的奇偶校验标志:

And there are many ways to clear the parity flag with two instructions:

and bl, 0 
or  bl, 1

但是,单指令方法仍然难以捉摸.

However, the one-instruction method remains elusive.

推荐答案

不可能.

当应用于两个副本或一个寄存器(如或al,al )时,任何PF更改命令都不会无条件地产生奇偶校验结果.同样,当应用到寄存器时,所有算术命令都不会产生奇偶校验结果,并且不会完全定义该结果的常数(例如和al,0 或al,ffh ).对于第二个操作数是任何其他常量的命令,结果将取决于寄存器的初始值,我们对此无法控制.

None of the PF-changing commands can unconditionally produce an odd-parity result when applied to two copies or a register (like or al, al). Likewise, none of the arithmetic commands produces an odd-parity result when applied to a register and a constant that completely defines the result (like and al, 0 or or al, ffh). As for commands where the second operand is any other constant, the result would depend on the initial value of the register, and we have no control over that.

如果我们知道执行环境的某些细节,则有可能在众所周知的地址使用内存的内容.在实模式下与PC兼容的计算机上,您可以依赖BIOS数据结构.在MS-DOS中,同为可执行标头.

If we knew some details of the execution environment, it could be possible to use the contents of memory at a well-known address. On PC compatibles in real mode, you can rely on BIOS data structures. In MS-DOS, ditto for executable header.

这篇关于一条指令清除PF(奇偶校验标志)-在结果寄存器中获得奇数位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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