The flags register is a 16-bit register in which nine bits have a meaning. Six are status flags: arithmetic and logic instructions set or clear them to describe their result, and conditional jumps test them. Three are control flags that change how the CPU behaves. The other bits hold no flag.

BitFlagSet (1) when
0CF carryan unsigned result carried out of, or borrowed into, the top bit; also the last bit shifted out
2PF paritythe low byte of the result has an even number of 1 bits
4AF auxiliary carrya carry out of, or borrow into, bit 3 (used by the decimal adjust instructions)
6ZF zerothe result is 0
7SF signthe top bit of the result is 1 (negative if signed)
8TF trapcontrol: INT 1 after each instruction (single step)
9IF interruptcontrol: maskable hardware interrupts are accepted
10DF directioncontrol: string instructions count down instead of up
11OF overflowa signed result does not fit the destination
Prints 110: CF = 1, ZF = 1, SF = 0.
MOV AL, 0FFh
ADD AL, 1 ; FFh + 1 = 100h: AL = 0, a carry out
LAHF ; AH = SF ZF - AF - PF - CF
MOV BL, AH
MOV AL, BL
AND AL, 1 ; CF, bit 0
ADD AL, '0' ; digit -> character
MOV DL, AL
MOV AH, 02h ; DOS: print DL
INT 21h
MOV AL, BL
MOV CL, 6
SHR AL, CL
AND AL, 1 ; ZF, bit 6
ADD AL, '0' ; digit -> character
MOV DL, AL
MOV AH, 02h ; DOS: print DL
INT 21h
MOV AL, BL
MOV CL, 7
SHR AL, CL ; SF, bit 7
ADD AL, '0' ; digit -> character
MOV DL, AL
MOV AH, 02h ; DOS: print DL
INT 21h

Who changes what

InstructionsFlags
MOV XCHG LEA PUSH POP, jumps, LOOPnone
ADD ADC SUB SBB CMP NEGOF SF ZF AF PF CF
INC DECOF SF ZF AF PF; CF unchanged
AND OR XOR TESTSF ZF PF; CF = OF = 0
MUL IMULCF OF; the others undefined
DIV IDIVall undefined

Signed and unsigned

The CPU does not know whether a byte is signed. It sets both CF (meaningful for unsigned numbers) and OF (meaningful for signed ones), and you pick the jump that matches your data: JB / JA read CF, JL / JG read SF and OF. FFh + 1 sets CF, since 255 + 1 does not fit; 7Fh + 1 sets OF, since 127 + 1 is not a signed byte.

Setting flags directly

CLC / STC / CMC change CF, CLD / STD change DF, CLI / STI change IF. LAHF / SAHF copy the low byte to and from AH; PUSHF / POPF save and load all of them, and are the only way to change TF.

Later CPUs

The 80286 uses bits 12-14 for the I/O privilege level and the nested task flag. The 80386 widens the register to 32-bit EFLAGS with the resume and virtual-8086 flags; later models add more.