Content deleted Content added
mNo edit summary |
|||
Line 129:
const volatile int & hardwareRegister = *reinterpret_cast<int*>(0x8000);
hardwareRegister = 5; // Error! Cannot write to a const ___location▼
int currentValue = hardwareRegister; // Read the memory ___location
int newValue = hardwareRegister; // Read it again
▲ hardwareRegister = 5; // Error! Cannot write to a const ___location
Because <code>hardwareRegister</code> is volatile, there is no guarantee that it will hold the same value on two successive reads even though the programmer cannot modify it. The semantics here indicate that the register's value is read-only but not necessarily unchanging.
Line 139:
// Set up a pointer to a read-only memory-mapped register that
// contains a memory address for us to
const int * volatile const tableLookup = reinterpret_cast<int*>(0x8004);
int currentTableValue = *tableLookup; //
int newTableValue = *tableLookup; //
tableLookup = ¤tTableValue; // Error! Cannot modify a const pointer
|