Objects in Program Space

Only const objects that have static storage duration are placed in program memory.

Enhanced Mid-range devices can directly read their program memory, although the compiler will still usually store data as retlw instructions. This way the compiler can either produce code that can call these instructions to obtain the program memory data as with the ordinary Mid-range devices, or directly read the operand to the instruction (the LSB of the retlw instruction). The most efficient access method can be selected by the compiler when the data needs to be read.

Data can be stored as individual bytes in the program memory of PIC18 devices. This can be read using table read instructions.

For other 8-bit PIC devices, the program space is not directly readable by the device. For these devices, the compiler stores data in the program memory by means of retlw instructions which can be called and will return a byte of data in the W register. The compiler will generate the code necessary to make it appear that program memory is being read directly.

Accessing data located in program memory is much slower than accessing objects in the data memory. The code associated with the access is also larger.