Name
FP_OFF, FP_SEG - Get the offset and segment of an address.
Syntax
#include <dos.h>
unsigned FP_OFF(address)
unsigned FP_SEG(address)
void far *address;
Description
The FP_OFF and FP_SEG macros can be used to set or get the
offset and segment, respectively, of address. In small- and
medium-memory models, the FP_SEG and FP_OFF macros only work
if the far pointer argument lies in the default data
segment. If the far pointer is itself in a far data segment,
the macros will not work correctly.
Return Value
The FP_OFF macro returns an offset. The FP_SEG macro returns
a segment address.
Example
#include <malloc.h> #include <stdio.h>
void far *p; unsigned int seg_val; unsigned int off_val;
main()
{
/* Point pointer at something */
p = _fmalloc(100);
/* Get address pointed to */
seg_val = FP_SEG(p);
off_val = FP_OFF(p);
printf("Segment is %d; Offset is %d\n", seg_val,
off_val);
}
This program uses FP_SEG and FP_OFF to obtain the segment
and offset of the long pointer p.
(printed 6/18/89)