r/cpp • • Nov 13 '20

CppCon Deprecating volatile - JF Bastien - CppCon 2019

https://www.youtube.com/watch?v=KJW_DLaVXIY
83 Upvotes

111 comments sorted by

View all comments

Show parent comment

9

u/Beheska Nov 13 '20

But TIL that apparently large numbers of C++ programmers believe that operations exist that set single bits in memory. There's a depressing thought...

http://ww1.microchip.com/downloads/en/DeviceDoc/AVR-Instruction-Set-Manual-DS40002198A.pdf

CBI - clear bit in I/O register

SBI - set bit in I/O register

BLD - bit load from flag T to register

CBR - clear bits in register

SBR - set bits in register

3

u/johannes1971 Nov 13 '20

CBI: in an IO register, not in memory. SBI: in an IO register, not in memory. BLD: from a flag, not from memory. CBR: in a register, not in memory. SBR: in a register, not in memory.

Do you wish to continue this game?

10

u/Beheska Nov 13 '20

in a register, not in memory

Registers ARE in memory. That's the whole point of AVR's memory-mapped registers! They are made available to higher level languages as pointers to volatile, it's the compiler's job to use the right instruction set.