C volatile

The compiler will freely issue indexed addressing modes wherever appropriate. Due to a processor bug, these addressing modes can cause NMOS 6502 to issue a spurious read to a memory location one page lower than the one intended. These reads are not considered to constitute an access to a volatile object, even if they overlap with one in memory.

To avoid accidentally triggering I/O, pointer arithmetic should be avoided for addresses one page above read-sensitive I/O locations. To be safe, such routines can be written in assembly.

The read/modify/write (RMW) instructions (e.g., INC) also issue a spurious read or write to the location, depending on the 6502 version. If the underlying object is volatile, these accesses would be considered to be volatile accesses; accordingly, the compiler avoids generating RMW instructions for such addresses. Instead, the compiler will manually issue the load, manipulate the value, and store it back. [[Category:C]]