Explain how the AF flag works in an x86 instructions?

。_饼干妹妹 提交于 2019-12-04 05:57:00
flags.af = (((base-subt) & ~0xf) != 0);

Checks to see if the upper bits are anything except zero, which would indicate an overflow or underflow out of the bottom 4 bits.

Here's a version that's a little closer to your original. Note that the difference between two 4-bit quantities will never be greater than 15. Likewise the addition will never be less than 0.

flags.af = ((int16_t)base-subt < -15);

flags.af = ((int16_t)base+adder > 15);

Putting parentheses around a boolean expression is just a style preference of mine, I know they're redundant.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!