问题描述
我们有STC
指令来设置进位标志.我们是否对奇偶校验,溢出,标志标志等有类似的说明?我试过STP
,STS
等,但似乎这些都不存在!
We have the STC
instruction to set the carry flag. Do we have similar instructions for parity, overflow, sign flags etc? I have tried STP
, STS
etc but it seems these don't exist!
推荐答案
否,这些命令不存在.查找方法是仔细阅读说明参考手册.
No, those commands don't exist. The way you find out is by reading the instruction reference manuals carefully.
他们真的不需要存在.您可以轻松有效地实施它们.如果您不介意设置其他位,则可以使用以下方法之一:
They don't really need to exist.You can effectively implement them pretty easily.Here's one of many ways, if you don't mind other bits getting set:
STP: XOR AL,AL ; resets parity bit
XOR AL,1 ; ... then set parity bit
STO: OR AL, 0FFh
SUB AL, 080h ; sets overflow
STS: OR AL, 0FFh ; sets sign bit
如果您坚持只设置特定位:
If you insist on setting just the specific bit:
PUSHFD
OR dword ptr[ESP], <bitmask_for_flag_bit> ; see Intel manual
POPFD
硅空间非常宝贵,CPU设计人员往往不会为容易完成的事情提供说明. (STC保留了8080天,在这里它可用于执行各种多精度算术,并且不损坏寄存器是一件好事.)
Silicon space being precious, CPU designers tend not to provide instructions for things that are easily done. (STC is left over from 8080 days, where it was useful in doing various kinds of multiprecision arithmetic and not damaging registers was a Very Good Thing).
这篇关于设置奇偶校验,溢出和&的x86指令标志标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!