This is embarrassing... I consider myself an expert in the 8051 architecture, but I've never had to perform a single bit xor operation before.
What I want to do is fairly simple, I want C = XOR(DOWN_FLAG, UP_FLAG). I've performed plenty of byte-to-byte XRL operations before, but I've never had the need to perform a bit-to-bit xor, until now.
This is how the code would look like if the XRL C, bit instruction existed (which it doesn't ... numbers in parenthesis are the clock cycles performed by each instruction in an AT89LP4052):
But since the stupid bit-to-bit XRL instruction doesn't exist, I've been forced to translate them into bytes and performing XRL there.
This bothers me because it seems like an awful waste of cycles and instructions for such a simple task. And I know that a standard gate XOR instruction (which can easily be translated to code) looks like this.
But it still looks like an awful number of steps. Is there an easier way?
What I want to do is fairly simple, I want C = XOR(DOWN_FLAG, UP_FLAG). I've performed plenty of byte-to-byte XRL operations before, but I've never had the need to perform a bit-to-bit xor, until now.
This is how the code would look like if the XRL C, bit instruction existed (which it doesn't ... numbers in parenthesis are the clock cycles performed by each instruction in an AT89LP4052):
Code:
MOV DOWN_FLAG, C ;(2)
XRL C, UP_FLAG ;(?)
JC CHECK_UP_DOWN_INPUTS_EXIT ;(3)
Code:
MOV DOWN_FLAG, C ;(2)
CLR A ;(1)
MOV A.0, C ;(2)
MOV C, UP_FLAG ;(2)
MOV B, #00H ;(3)
MOV B.0, C ;(2)
XRL A, B ;(2)
JNZ CHECK_UP_DOWN_INPUTS_EXIT ;(3)
But it still looks like an awful number of steps. Is there an easier way?