Code: Select all
CP 177
JP NC,_somewhere
What about negative numbers?
Code: Select all
LD A,-10
CP -5
JP C,_somewhere
Explanations gratefully received!
Code: Select all
CP 177
JP NC,_somewhere
Code: Select all
LD A,-10
CP -5
JP C,_somewhere
Code: Select all
ld a,246 ; this is -10
cp 251 ; this is -5
What A will be after that? it can be 257 because A can contain values only from 0-255.LD A,254
LD B.3
ADD A,B
Code: Select all
LD A,(IX+1)
SUB B
NEG
CP 6
JR NC,_something
Code: Select all
C 76543210
0 11111111 = 255
Add 1 and you get
1 00000000 = 0 but with carry set, so the overall value is equivalent to 256
Code: Select all
C 76543210
0 00000001 = 1
Subtract 4 and you get
1 11111101 = 253 but with carry set, so the overall value is equivalent to 509 or -3 depending on how you interpret the binary number (where bit 7 is treated as a sign bit)