A83: CP & flags


[Prev][Next][Index][Thread]

A83: CP & flags




Well CP is temporary ComPare.  And depending on the outcome, different 
flags are set.  These can be the carry, zero, and/or parity flag(I might 
have missed one).  The carry flag is set when something like:
ld hl,$FFFE
ld de,$0002
add hl,de

this would set the carry flag.  You probably know how to set the zero 
flag through cp's, but just for good measure:
ld a,$FF
cp $FF
sets the zero flag,
ld a,$FE
ld b,$FE
cp b
also sets the zero flag, and
ld hl,$0001
ld de,$0001
sub hl,de
sets the zero flag.
This can also be reversely done:
ld a,$FF
cp $FE
jp NZ,not_zero
this checks if the prior execution did NOT set the zero flag, hense NZ.
Hope this helps,
-Phelan 'Amen' Wolf

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com