All the Flags
You already know all the flags that are important and used the most but
here is the full list. Remember these are all bits in the f
register and only six of them are used.
Symbol | Flag Name | Bit |
S | sign | 7 |
Z | zero | 6 |
unused | unused | 5 |
Ac | Auxiliary Carry | 4 |
unused | unused | 3 |
P | Parity Even or Odd | 2 |
N | add/subtract | 1 |
C | carry | 0 |
The only flags that really matter here have already been discussed in the
Flags and Conditions Section so you don't
have to really worry. There is,
however, one flag here that you might want to know about: the parity flag. The instruction
cpir
can be used with this.
This instruction is called Block Search
instruction. It is used to search starting at hl
's address for
bc
amount of bytes after until the byte at address hl
matches the byte in a
. It keeps
on searching (and decreasing bc
every time it increases hl
) until it either
finds a match or bc
is down to zero. You can't really tell which of those two happened
without checking the status of bc
.
Here's some code that will start looking for
the value 69
in a 50 byte table
starting at the label numbers
. If it doesn't find 69
in the table before bc
runs out, it'll jump to the routine not_found
;
else, it'll continue.
ld hl,numbers ld bc,50 ld a,69 cpir jp po,not_found
Cpir
has a twin instruction named cpdr
.
The only difference between these two
instructions is that cpdr
decreases the address hl
each iteration whereas cpir
increases it.
More from z80 » Intermediate
All the Flags // Debugging // Down-Left Bug // _GetKey Codes // Logical Operators // Memory, ROM, RAM, and Safe Areas // Miscellaneous Instructions // PC and SP // Random Numbers // TI's ROM Calls // Restart Commands // Simulated 16-bit Addition // The Stack // Tables and Arrays // Text Display // Variables