maybe is a newbie question, but i have always emu the CMP/CPX/CPY setting the value of carry if mem <= reg, that implies that i have to do an "if()" so in x86 code a "cmp, jx". Is there some another way so it returns if 6502 carry is 0 or 1?
CMP actually performs subtraction, and sets the C flag in the same manner SBC does. The subtraction is pretty much required anyway, as it's the only way to properly set the N flag.
From my emu:
Code:
#define CMP(r) \ tmp = r - val; \ fC = !(tmp >> 8); \ fN = fZ = (u8)tmp
'r' = A (for CMP), X (for CPX), or Y (for CPY)
'val' = the value being compared
'tmp' = 16-bit or greater temp value
'fC' = C flag set when fC=nonzero
'fN' = N flag set when fN.7=1
'fZ' = Z flag set when fZ=0