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.0
to input and it is externally pulled low, that is it will be read as 0. Now if you want to set P1.1
to input as well, you can do SETB P1.1
and that will work fine. However if you read the value of P1
, modify the value, then write it back, then it won't work:
MOV P1, #1 ; set P1.0 to input
MOV A, P1 ; reads 0
ORL A, #2
MOV P1, A ; P1.0 no longer input
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.