Introduction

The f register consists of eight (semi-)independent bits which give you information about previous instructions' results. Not all instructions set all (or any) bits - see their individual documentation for more information.

Bit 7: Sign (s)

1 if the result is negative (in two's complement representation), 0 otherwise. In other words, it's a copy of bit 7 (the high bit) of the result.

Bit 6: Zero (z)

1 if the result is zero, 0 otherwise.

Bit 5: Copy of bit 5 (5)

Simply a copy of bit 5 of the result, it's not very useful.

Bit 4: Half-carry (h)

Set if there's been a carry between bit 3 and bit 4 of the result. It's used by the daa instruction and isn't useful for much else.

Bit 3: Copy of bit 3 (3)

Simply a copy of bit 3 of the result, it's not very useful.

Bit 2: Parity/overflow (p/v)

It's either the parity of the result (1 if there is an even number of 1s in the binary representation of the result, 0 if odd); or it's the two's complement overflow (1 if the operation caused the result to go past the -128/+127 limit, 0 otherwise).

Bit 1: Subtract (n)

1 if the last daa-compatible instruction was a subtraction, 0 if it was an addition. It's used by the daa instruction and isn't useful for much else.

Bit 0: Carry (c)

1 if there was a carry into or out of the high bit of the result; in other words, if the operation caused the number to go past the 0/255 boundary.