In the SDCC 2.5.x branch I could declare a variable like
const unsigned char at 0x2100 var=0x1c;
...and it would put that variable into nonvolatile data memory.
Now, with sdcc 3.0.1 built from CVS, it does something strange: It treats it like an array in CODE MEMORY, adding 'retlw' instructions in this inappropriate place.
Complete sample code:
const unsigned char __at 0x2100 eedata=0x1c;
void main(void)
{ while(1); }
Compiled with:
sdcc --use-non-free -mpic14 -p16f628a eepromwtf.c
sdcc --version
SDCC : mcs51/gbz80/z80/ds390/pic16/pic14/TININative/ds400/hc08 3.0.1 #6113 (Jan 15 2011) (Linux)
Unexpected result in ASM:
;--------------------------------------------------------
; initialized data
;--------------------------------------------------------
ID_0039_eepromwtf_0 code 0x2100
_eedata
retlw 0x1c
Error messages: None, though the malformed ASM produces a warning, to wit:
eepromwtf.asm:72:Warning [220] Address exceeds maximum range for this processor.
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
Update: It generates code correctly when the variable has the __data keyword. I somehow thrashed for hours trying to adapt existing code without discovering that, I suppose the code I was fixing was too complicated.
All the same this is a behavior change. Getting EEPROM data into C code properly is something I'd worked out through trial and error, and I never did find proper documentation describing the process -- I was convinced the PIC14 port didn't even look at __data specifiers and the like, let alone implement them. Just a little note somewhere about a proper way to do this that's expected to stay proper would be great.