Search code examples
assemblyx86cpu-architectureeflags

Why doesn't bitwise NOT affect the ZF bit or any other FLAGS?


NOT on a register holding binary 11111111 will produce 00000000, but ZF will still have its old value, so it might not be 1 even though the output value is all zero.

XOR reg, -1 would do the same thing but will set FLAGS according to the result.

Why does bitwise NOT don't affect the ZF bit? Hope someone can explain why, or it was originally designed like this.


Solution

  • Actually, we can let the designer of the 8086, Steve Morse, answer this himself. I hope he'll forgive me for quoting from his book, The 8086/8088 Primer, which he has made available on his website. The following is taken from page 98:

    One Boolean instruction, NOT, is missing from the list of Boolean instructions that affect the flags. NOT does not affect the flags. This was a result of an oversight (I goofed!) when the processor was being defined.