//KM 2018 03 23: getting lots of form spam; screen out dates before 2000 (book publication date) MPC - Constant ROM Arrays | Byte Craft Limited

MPC - Constant ROM Arrays


Arrays declared in ROM are often useful. They are typically used for lookup tables or messages shown on a display. MPC distinguishes ROM arrays from normal data memory arrays by the const data type modifier.

The compiler implements ROM arrays with an ADDWF PC instruction followed by a series of RETLW instructions. To read an array element, the compiler places the index in the W register and generates a CALL to the start of the array. The compiler then adds the W register to the program counter and a RETLW returns the value in the W register. 17Cxx parts use TBLRD and TLRD instructions.

 const char s[]="Byte Craft Limited!";
 void main(){    char ch;
   unsigned int i;
   for (i=0; i<19;i++)       PORTB=s[i];