|
|||||||||||
Technical Support Support Resources
Product Information |
C51: READ-MODIFY-WRITE RegistersInformation in this article applies to:
QUESTIONI keep hearing about READ-MODIFY-WRITE registers and I don't understand what this means? ANSWERREAD-MODIFY-WRITE refers to the technique used to implement an assembly instruction and is typically used by the bitwise operations (AND, OR, XOR). For example, the following instruction:
reads the value of the P1 latch (not the input pins), modifys the value read--it performs a bitwise OR (with 0x01)--, and writes the new value back into the P1 latch. There are usually no side-effects of READ-MODIFY-WRITE instructions when accessing registers that have the same values when read or when written (because they act like RAM). However, READ-MODIFY-WRITE instructions can cause problems when the register being accessed is write-only or reads a different value than what was written. A characteristic of the I/O ports of the 8051 is that the value you write may not be the value you read (since reading the port returns the state of the port pins). However, these registers are specially treated for READ-MODIFY-WRITE instructions and instructions like ORL P1,#01 read the port latch (the previously written P1 value) instead of the port pins. You should carefully check the registers of a specific device to be certain how they behave with respect to the READ-MODIFY-WRITE instructions. MORE INFORMATION
Last Reviewed: Thursday, February 25, 2021 | ||||||||||
|
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.