The following code should print 0, but instead it prints 4096.
uint8 buffer ; buffer = 0; printf("%u\r\n", strlen(buffer));
If, instead, I declare the buffer to be in XDATA space (
uint8 XDATA buffer ), then it does the right thing.
I tracked the problem down and it seems to be a bug in
_gptrget, which is called by
strlen. It looks like it’s not doing the right thing with pointers to PDATA (seems to overwriting the DPH register with 0?)
I’ve attached the relevant source files.