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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -