z80 - What is the behavior of the carry flag for CP on a Game Boy? -
on page 87 of the game boy cpu manual claimed cp n
instruction sets carry flag when there no borrow , means a < n
. seems conflict itself, because carry flag set when a > n
.
an example: if a=0
, b=1
, cp b
sets flags sub a, b
, 0 - 1. becomes 0 + 255 = 255 , carry flag not set, though a < b
.
i came across same issue in other z80 documents well, don't believe typo.
am misunderstanding how borrow , sub
work or there else going on? sub
not equal add
two's complement in terms of flags?
the gameboy cpu manual has backwards. sub
, sbc
, cp
set carry flag when there borrow. if sub/sbc/cp a,n
executed carry set if n > a
otherwise clear.
this consistent z-80 (and 8080) operation. mame , mess implement carry the same way.
Comments
Post a Comment