Why is Read-Modify-Write necessary for registers on embedded systems?

后端 未结 5 1845
伪装坚强ぢ
伪装坚强ぢ 2021-02-07 20:17

I was reading http://embeddedgurus.com/embedded-bridge/2010/03/different-bit-types-in-different-registers/, which said:

With read/write bits, firmware se

5条回答
  •  星月不相逢
    2021-02-07 21:09

    If you have to modify a subset of the bits in a word, and the architecture only supports word level read/write, you have to read the bits that must not change to know what to write back so that they are not modified.

    Some architectures support bit level memory access either globally or for specific regions of memory. But even then when modifying multiple bits, read-modify-write many result in fewer instructions. In multi-threaded systems care must be taken to ensure that two threads cannot perform this non-atomic action on the same word concurrently.

提交回复
热议问题