XC8 - constant ROM allocation for PIC12F1501
stringtext psect must be linked within the first half of each program memory page


This restriction only applies to 'baseline' PICs such as the 12C509, which can only call subroutines in the first half of each 256 byte page. Why does this matter? In older PICs there are no instructions for reading data from ROM, so a method was developed called Table Read, in which data arrays are stored as a sequence of RETLW instructions (return from subroutine with literal in working register).            

The 12F1501 is one of the new generation of enhanced mid range PICs which can use their index register to read the ROM directly, so it has no restrictions on placement of data in the ROM. However the XC8 compiler still insists on trying to align stringtext on page boundaries, and refuses to put it in page zero even when only a few bytes of initialization code are 'in the way'! This may result in running out of space even though you have a significant amount of 'free' ROM.

The easiest way around this problem is to simply force your arrays into a code section - then the compiler should align them on word boundaries with no gaps (like normal code). Just add a section specifier to each array definition, like this:-   

const __section("mystringtext") unsigned char patterns[12] = {
    0, 0, 0, 0,
    0, 0, 0, 0,
    0, 0, 0, 0,
};