The loop below never ends. I see in the assembler
listing that the loop's end condition is transformed
to '(0xFFFF-i) creates borrow', i.e. ((0xFFFF-i)<0),
which never happens when i is unsigned int
-----------------------------------
bit TestXMem()
{
xdata unsigned char * data addr;
unsigned int i;
bit b;
b = 0;
for(i=0x0000; i<=0xFFFF; i++) {
addr = (xdata unsigned char *)i;
*addr = 0x55; if (*addr!=0x55) {b=1; break;}
*addr = 0xAA; if (*addr!=0xAA) {b=1; break;}
*addr = 0;
}
return b;
}
// -----
void main()
{
TestXMem();
}
-----------------------------------
H:\>sdcc -v
SDCC :
mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/d
s400/hc08 2.5.6 #
(May 18 2006) (MINGW32)
Logged In: NO
SDCC's integer type is 16 bit. So the condition i<=0xFFFF is
always true.
SDCC should eventually evaluate this at compile time instead
of letting the 8051 find out, but it's correct behaviour.