REP (REset Processor status bits) and SEP (SEt) take an 8-bit mask and clear or set exactly those status bits. Their headline use is switching register widths: REP #$30 clears the M and X bits (0x30) — go 16-bit — and SEP #$30 sets them — go 8-bit. One instruction, any subset of flags, in either direction. They are the everyday tool of 65816 programming: bracket a routine with REP/SEP to run it wide, then restore. The width system of darts 456-457, made operable.
The demo clears bits 4,5 with REP #$30 (entering 16-bit) then sets them with SEP #$30 (back to 8-bit): live demo
“You flip status flags one at a time.” — REP/SEP change any masked subset in a single instruction. cited
Any subset of the status flags cleared or set in one stroke — the width system made operable. masking
On the canonical compiler, REP #$30 turns P=0xFF into 0xCF (bits 4,5 cleared), and SEP #$30 restores 0xFF: