Is there a difference in assigning a whole byte to an SFR or applying an AND or OR to it’s value?
In other words, does it matter if I set some bits to same value as they were previously or this can trigger some hardware reaction?
For example I start from:
MOV UARTCON, 0x9b
Then with the same final value I can do
ORL UARTCON, 0x40
or
MOV UARTCON, 0xdb
or even
SETB UARTCON.6
Is there any difference?
I’m not talking particularly about UARTCON here, but about general mechanism of SFRs. Is the set of a bit matters or only the change of that bit?
UPD I can narrow the question: are bit addressable SFRs altered internally by bits or as a whole bytes even with instructions like CLR, SETB, ORL and AND?
There may be some bits that have different meaning when read and written, such as the port pins. When written they set the latch and the output, when read they return the input. To configure a pin for input, you write a 1 to it. Suppose you have set
P1.0to input and it is externally pulled low, that is it will be read as 0. Now if you want to setP1.1to input as well, you can doSETB P1.1and that will work fine. However if you read the value ofP1, modify the value, then write it back, then it won’t work:Note that
ORL P1, #2, while it logically does the same, works because the processor has special support and knows to read the port latch instead of the pin input.Another possibility you mentioned was the write triggering something. One such example is
SBUF. Even if you write the same value there, it will trigger a transmission. However this isn’t really relevant to your question, since it’s not bit-addressable. In the context of standard 8051 I can’t think of another SFR that exhibits similar behavior.