I've just begun to use the latest win32 binary distribution of SDCC. I can't seem to make printf or printf_small behave correctly on either the s51 simulator or an AT89C51AC2.
void main(void)
    int i;
    AN2 = 0; 
    AN3 = 1;  

        for(i = 0; i < 256; i++)
            printf_small("Sample %d is %d \n\r", i, (int)read_adc_highres(0));
In this case read_adc_highres() returns an unsigned long, but the problem will occur just as readily if I have it return an int.
It seems that printf_small() will pre-pend minus signs to certain ranges of numbers in both the loop counter and sampling routine return.
ie Sample -245 is 179
   Sample 23 is -159
I gave up on printf as I couldn't make it work at all!
I compile with the --stack-after-data option. 
If I were to do 3 printf_small statements in a row, the middle one might work okay and the others not!
Can anyone see immediately where I might be going wrong, or possibly have some printf\ printf_small experience or usage examples to share?