Code: Select all
#include <stdio.h>
#define CARTSTART 0xfa0000
#define CARTEND 0xfbffff
main()
{
unsigned char *addr = CARTSTART;
unsigned char *endaddr = CARTEND;
for (; addr < endaddr; addr++)
{
printf("0x%02x\t", *addr);
}
}
If you subtract addr from endaddr then you will get a value that's ffffffff.
If you change the start address to 0xfb0000 then it works. It looks like all tests and arithmetic, even on pointers, is 16 bit only, and unsigned arithmetic seems to be sort of signed. That's rather broken.