This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

font[i].count & font[i-16].count in 390

The target options:contiguous mode:512KB program,off-chip code memory(0x0000:0xfc00),off-chip xdata memory(0x20000:0x10000).

extern code struct font_t font[];
void main(void)
{
    unsigned char count;
    unsigned int i = 67;

    count = font[i].count;
    count = font[i-16].count;
}
In the above test program,I cann't get my second count accessing because the compiler generate the following code
......
mov R7,#43;    i value
mov B,#0x42;   sizeof(struct font_t) = 0x42
mov A,R7
mov DPTR,#0x10787;  ???
ACALL    C?OFFXADD(C:000702);get DPTR
clr A
movc A,@A+DPTR; count
......
the error lies in mov DPTR,#0x10787 that should be mov DPTR,#0x0787 because the font is located c:0x0BA7.
Resolution?

  • Yes, this is a compiler problem (but only in Dallas 390 contigious mode).

    Avoid for the moment negative indexing in arrays, by using the following work-around:

    void main(void) {
        unsigned char count;
        unsigned int i = 67, h;
    
        count = font[i].count;
        h = i-16;
        count = font[h].count;
    }
    

  • Yes, this is a compiler problem (but only in Dallas 390 contigious mode).

    Avoid for the moment negative indexing in arrays, by using the following work-around:

    void main(void) {
        unsigned char count;
        unsigned int i = 67, h;
    
        count = font[i].count;
        h = i-16;
        count = font[h].count;
    }
    

    The problem will get solved in next C51. If you need a pre-release, please send email to: support.intl@keil.com.