Ah, yes, the comments are backwards, was just writing freehand.
I have looked at the code more to narrow it down, my orginal thoughts of the issue were clearly off. the above examples both work, it was the bit I left out causing the problem:
This is the code (Writen free hand to show the idea)
Code:
//main.c//Some global register used for bit flagsbyte FlagsRegister#define MaskSomeFlag 2main{ byte Temp1,Temp2; if(FlagsRegister & MaskSomeFlag) Temp1 = 1; else Temp1 = 0; if(Temp1 ^ PTAD_PTAD2){...} //THIS LINE WORKS AS EXPECTED if((FlagsRegister & MaskSomeFlag) ^ PTAD_PTAD2){...} //THIS LINE DOES NOT WORK}
Note, when I compilied and tested this, it was strictly one of the other, I just combined them to illistrate.
Now, here is where I see the issue in the non working code:
lda PTAD
and 0x04 //Mask out PTA2
lsra
lsra //move it into position bit 0? This should be at bit 1 for the compare to work!
psha //Save on stack
lda FlagsRegister
and 0x02 //Mask out the correct bit from FlagsRegister
tsx
eor ,x //Do the compare with the wrong bit!
pulh
beq *+54
...
So, is it my code causing it to be out by one? or?
I am pretty sure my code is 'ok' as it works when each bit is tested seperately.