The “based on pointer” variant of based addressing enables specification of a pointer as a base-expression. The based pointer, then, is an offset into the segment starting at the beginning of the pointer on which it is based.
One use for pointers based on pointers is for persistent objects that contain pointers. A linked list of pointers based on pointers can be saved to disk and reloaded to another place in memory, and the pointers will still be valid. The following example declares such a linked list:
void *vpBuffer;
struct llist_t
{
void __based( vpBuffer ) *vpData;
llist_t __based( vpBuffer ) *llNext;
};
The pointer, vpBuffer
, is assigned the address of memory allocated at some later point in the program; the linked list is then relocated relative to the value of vpBuffer
.
Pointers based on pointer addresses are the only forms of __based valid in 32-bit compilations. In such compilations, they are 32-bit displacements from a 32-bit base.