The Zero Flag (Z) is bit 1 of the Processor Status Register. The zero flag is set to 1 whenever an arithmetic, storage, or logical operation produces a result equal to zero, otherwise it is cleared to 0.
This example loads the accumulator with 0, then with 1, which sets the zero flag to 1 and then 0 respectively.
0001:A9 00 LDA #$00 ; Load A with $00. Since the result is zero, the Z flag is set to 1. 0002:A9 01 LDA #$0F ; Load A with $0F. Since the result is not zero, the Z flag is cleared to 0.
The following opcodes affect the zero flag.