Z80 Assembly 05: Logic Operations and Bit Manipulation

Logic Operations: AND, OR, and XOR These instructions perform bitwise logic operations between the Accumulator (A) and a source (another register or immediate value), storing the result back in A. They are crucial for filtering or combining specific data flags. The Core Logic Commands: Instruction Action Purpose AND N Bitwise AND (A = A & N) Filtering/Masking: Clears (forces to 0) any bits in A that are 0 in N. OR N Bitwise OR (A = A | N) Setting: Sets (forces to 1) any bits in A that are 1 in N. XOR N Bitwise XOR (A = A ^ N) Toggling: Flips the state (0→1, 1→0) of any bits in A that are 1 in N. Example: Filtering a Status Register If we only care about the highest two bits of a status register read into A: ...

September 27, 2025