Please describe the read-modify-write instruction in detail. [2009/08/05]
The read-modify-write instruction performs the following operations.
- Read data from a specified address.
- Process the bits specified in the read-out data.
- Write the data to the original address.
Data is written and read in byte units. When processing a bit or performing a logic operation, the data in the bits which are not specified in the data read out (in byte units) are not processed but are simply written to the original address.
[Example] SEB 2, RAM
|Bit processing||CLB, SEB|
|Shift||ASL, LSR, ROL, ROR, RRF|
|Arithmetic operation||DEC, INC|
In addition, add and subtract/logical operation instructions (ADC, SBC, AND, EOR, and ORA) when T flag = 1 operate in the way as the read-modify-write instruction.