negsets all flags identical to what you would get with subfrom 0.
This sequence of instructions sets all flags (including AF) identically neg %eax:
xor %ecx, %ecx
sub %eax, %ecx
Intel's documentation actually indicates this, but not in the โWorking with Pseudo-Codeโ section or in the flag-related section of the help record for the instruction set (Volume 2) for neg.
The text of the description section forneg this nugget includes:
This operation is equivalent to subtracting the operand from 0.
And in Volume 1 :
7.3.2.4 Instructions for changing and changing the sign
[paragraph on CMP]
The NEG command (negation) subtracts the signed integer operand.
, .
, vol.1 , . , , Intel , 2- .
, neg , sub Intel. (, neg [mem] ALU op, - . inc [mem] , 3 ).