Hello,
I'm having trouble with the following pointer math. I get a different
result from the MSP430 GCC when I execute the same code compiled with
GCC for intel 386. Here is an example:
unsigned long *p1=(void*)0x1000, *p2=(void*)0x7000, *p3=(void*)0xf000;
unsigned long p2p1 = p2-p1;
unsigned long p3p1 = p3-p1;
static char buf[30];
snprintf (buf, sizeof(buf), "%8.8lx %8.8lx", p2p1, p3p1);
PrintLine (buf);
The "PrintLine" function squirts the string out my serial port that I
feed to my terminal emulator for display. The resulting string is given
below.
00001800 fffff800
I have created a similar test program to run on my Linux workstation,
built it with gcc and run it.
Here is the test progarm
main(){
unsigned long *p1=(void*)0x1000, *p2=(void*)0x7000, *p3=(void*)0xf000;
unsigned long p2p1 = p2-p1;
unsigned long p3p1 = p3-p1;
printf ("%8.8lx %8.8lx\n", p2p1, p3p1);
}
Here is the result
00001800 00003800
Help Please,
Walt Spicker
Salient Systems Inc.