While executing the following code:
char far * buf; buf=FARRAY(char, 0x8FFF0); printf("%p\r\n",buf); buf+=0x100; printf("%p\r\n",buf);
x:08fff0 x:0800f0
Hello! 0x100UL does the trick and now MSB of buf pointer is updated to 0x09. But consider more complicated example: typedef struct a{ char x[0x100]; char y[0x100];} struct_a; .......................... struct_a far * buf; buf=FARRAY(struct_a, 0x8FFF0); printf("%p\r\n",buf); printf("%p\r\n",buf->y); I get it again: x:08fff0 x:0800f0 What can you advice in such a case when structure is crossing 64K boundary? By the way I've already found the note in the "C51 User's guide": The absolute addressed object cannot cross a 64KB segment boundary. For example, you cannot access a long array that has 10 elements and starts at address 0xFFF8. Is that note still valid for the Dallas chips with true 24-bit DPTR's? I suspect yes... :(
typedef struct a{ char x[0x100]; char y[0x100];} struct_a; .......................... struct_a far * buf; buf=FARRAY(struct_a, 0x8FFF0); printf("%p\r\n",buf); printf("%p\r\n",buf->y);
Oh, finally I've found it: http://www.keil.com/support/man/docs/c51/c51_le_far.htm Bottom line: yes, this is not a bug, this is a feature. It is my responsibility to not place objects over the 64K boundaries. Dot.