Some of them were covered, but I will tell you a little more.
The general purpose of the test reg,mask command checks the value of the register against the mask (the value of the register is internal AND with the mask), and then sets the status flags SF, ZF and PF in accordance with the result. [EDIT for comment from @ChrisDodd] It also unconditionally clears the status bit O (overflow) and C (carry). [/ EDIT]
SF = sign flag (1 if sign bit is set (a 2 complement negative value)) ZF = zero flag (1 if result is 0) PF = parity flag (1 if result has an even number of 1 bits)
In this particular example ( test eax,eax ), the command accepts eax AND eax . When this is done, the bits will be:
SF = 1 if EAX has a negative value (since sign bit will not change when ANDed with itself) ZF = 1 if EAX is zero (the only value that yields a zero when ANDed with itself is zero) PF = 1 if EAX has an even number of 1 bits
In other words, this is a simple test for zero or negative. This is a very common compiler code generation pattern.
source share