My program is as follows:
void main(void) { char far *ptr; ptr = 0x200000; printf("ptr = %p\r\n", ptr); while(1); }
ptr = 0x200000 #1 After executing "ptr = 0x210000;" Off-chip xdata memory: 0x200000(start), 0x10000(length) The 8051 does not have a linear address space, and the values of a far pointer are unfortunately not simply the offset into xdata. The far pointer format is an extension of the "generic" 3-byte pointer format, in which one of the bytes is a tag byte identifying the memory space. For far memory, that tag byte identifies a 64Kbyte segment of far xdata memory. For what I assume are historical reasons, though, xdata starts with a tag value of 1, not 0. That is, the pointer values are "off by 0x10000". At any rate, you should use the FVAR, FARRAY, FCVAR, FCARRAY macros in absacc.h to construct a pointer from an offset rather than using integer values. The macros contain the proper offsets to make the tag byte come out with the correct value. Also, check the Debug / Memory Map menu option to be sure you have the memory ranges and access permissions set up appropriately.
The 8051 does not have a linear address space Correction: Most derivatives of the 8051 do not have a linear address space. The Mx, 669 and some Dallas derivatives (and more?) do. Erik