64K boundaries on DS80C400

While executing the following code:

 char far * buf;
 buf=FARRAY(char, 0x8FFF0);
 printf("%p\r\n",buf);
 buf+=0x100;
 printf("%p\r\n",buf);
I get the following result printed:
x:08fff0
x:0800f0
Obviously, the MSB of the pointer is not updated. Why? Is this a known bug in C51?
Settings: device DS80C400, C51 v7.50, Memory Model Large (variables in XDATA), contiguous mode 16M, 'far' memory type support - checked.

Parents
  • By default, pointer operations use 16-bit math. So, the rollover you see is expected.

    What happens if you change the buf += 0x100; to...

     buf+=0x100UL;
    

    In the CX51 Compiler, using long math operations on far pointers forces 24-bit operations and avoids the 16-bit math issues.

    Jon

Reply
  • By default, pointer operations use 16-bit math. So, the rollover you see is expected.

    What happens if you change the buf += 0x100; to...

     buf+=0x100UL;
    

    In the CX51 Compiler, using long math operations on far pointers forces 24-bit operations and avoids the 16-bit math issues.

    Jon

Children
More questions in this forum