using all space for lookuptables can only be done with ASM for PICs, i only can code in C.
For the 16F, I do something like the following (if needed), I never used a dspic so maybe does not apply but usually there is a way to make the c compiler do what you want. In this case it works good for 14bit data or less.
void ascii_lookup_14seg(){
//make known this 'function' used with 'global'
//prepend '_' to asm name
asm("global _ascii_lookup_14seg");
//as much data as needed (14bit or less)
asm("dw 0,6,544,4814,4845,3108,9053,1024");
//return added here, is ok
}
uint16_t rom_read(uint16_t waddr)
{
PMADR = waddr; //set address
CFGS = 0; //flash space
RD = 1; //start read
NOP(); //next 2 instructions ignored
NOP();
return PMDAT;
}
uint8_t n = 3;
uint16_t val = rom_read( (uint16_t)ascii_lookup_14seg + n );
A normal 'const' would place the data in flash as retlw instructions (14bits flash = 8bits data), where this is 14bits flash = 14bits data. If one is trying to squeeze some more code in available space, this could help. I was using just less than half of a 4Kword pic, and decided I wanted a bootloader so I could upload a newer 'app' to page1 (but page0 code cannot change and always runs on reset). I had a couple 'const' tables that were 14bit data, so I used the code above to save about 300words which enabled me to fit everything in page0. I also wrote the reset/irq jump code needed also in C (with 'asm' keyword), so you can do most things without leaving 'c' if wanted. In the end, I gave up the bootloader idea as its really not worth the trouble and am now back to using 35% of a 4Kword part, using normal 'const', although I also have plenty of extra ram so don't even need to use 'const'.
Although I have previously used gcc with other micros (avr, arm) and have been familiar enough with the many gcc/gas options so can usually find/get what I want done, my only guide was the xc8 user manual. It had all the info I needed to move the page0 app up to make room for the reset/irq jump code, and to build an app that resided in page1.
The free version of xc8 is fine for most users and the few extra instructions will not make any difference. If you feel you can't make it without the last bit of optimizations, I believe you can spend $30 on a one month subscription to xc8 pro.
There are always different parts for different applications, but in defense of 8bitters- find me a 32bit part that can source/sink 20ma per pin with 250-350ma total, find me a 32bit part that can sleep with 100na or less, find me a 32bit part that can run from 1.8v-5.5v, find me a 32bit part that can be had in dip/soic/ssop/qfn, find me a 32bit part that comes in 6pins when I only need a few pins to do something simple, find me a 32bit part... I'll quit while I think I'm ahead