I have came across a question while working on assembly language. Here is the question:
Assume that bit P2.2 is used to control an outdoor light and bit P2.5 a light inside a building. Show how to turn on the outside light and turn off the inside one.
Solution given:
SETB C ; CY = 1
ORL C, P2.2 ; CY = P2.2 ORed w/ CY
MOV P2.2, C ; turn it on if not on
CLR C ; CY = 0
ANL C, P2.5 ; CY = P2.5 ANDed w/P2.5
MOV P2.5,C ; turn it off if not off
I just felt like it would do just the same job to code:
SETB P2.2
CLR P2.5
What's wrong with that?