Reputation: 53
Suppose
andl %ecx %edx
is carried out, with the above assembly code in GAS syntax. Would this code set ZF/SF/PF flags using the AND result? Or would this code just AND two operands and do nothing about flags?
I know there is TEST and CMP instructions that set flags, but the code would be shorter if I can just use AND to set flags.
Upvotes: 1
Views: 5797
Reputation: 4873
Flags will be affected. In fact, just about any instruction that performs some arithmetic/bitwise/logical operation will modify the flags register.
I suggest you read the Intel Developer's Manual to find this information. Most, if not all, questions about the x86 architecture and instructions can be answered by using it.
The AND
instruction leaves the AF flag undefined, clears the CF and OF flags, sets PF if the low byte of the result has odd parity, sets SF if the result is negative (viewed as two's complement), and sets ZF if the result is zero.
Upvotes: 2