Z80 Assembly 17: Bitwise State Machines (Managing Flags with BIT/SET/RES)

State Machines: Why Bitwise is Best A State Machine manages the status of a system (e.g., a game character is ‘Jumping’, ‘Firing’, or ‘Hit’). In high-level languages, you might use three separate Boolean variables for these. In Z80 assembly, that’s inefficient. By using a single register (like C) as a status register, you can manage up to eight independent Boolean flags, dedicating one bit to each status. This is the fastest method for context management. ...

September 27, 2025