bogax wrote:
ElEctric_EyE wrote:
Forgive my ignorance,but what is the point of a "CMP #$10" without a branch instruction afterwards?
CMP does a subtract (without barrow) and sets the flags without
affecting the accumulator.
Since in this case all bits to the left of the fourth bit are zero
carry will be set (no barrow) if the accumulator is greater than
or equal to $10 ie if bit four of the accumulator is set, in effect
copying bit four (p) to the carry
BigDumbDinosaur wrote:
Only to condition flags to facilitate or affect a later operation. CoMParisons don't necessarily have to be followed by branches. In the above case, the effect on carry is what is wanted to possibly modify the result of the following ADC #$F0 instruction.
At that point I'm trying to add p to the bit count twice. Shifting it out with ADC leaves inverted copies in A, which would take another instruction to rectify anyway. So I copy p with the CMP then take the second copy destructively with ADC #$F0.
The first copy is taken from C and added into the bottom of A (stu), while simultaneously the second copy is put back into C - so the carry flag doesn't change during the ADC.
--Greg