[Previous]
[Contents]
[Next]

FP_SEG()

obtain the segment portion of a far pointer

Synopsis:

#include <i86.h>
unsigned FP_SEG( void __far *far_ptr );

Description:

The FP_SEG() macro can be used to obtain the segment portion of the far pointer value given in far_ptr.

Returns:

The segment portion of the pointer value.

Examples:

#include <stdio.h>
#include <i86.h>

char ColourTable[256][3];

void main()
  {
    union REGPACK r;
    int i;

    /* read block of colour registers */
    r.h.ah = 0x10;
    r.h.al = 0x17;
#if defined(__386__)
    r.x.ebx = 0;
    r.x.ecx = 256;
    r.x.edx = FP_OFF( ColourTable );
    r.w.ds = r.w.fs = r.w.gs = FP_SEG( &r );
#else
    r.w.bx = 0;
    r.w.cx = 256;
    r.w.dx = FP_OFF( ColourTable );
#endif
    r.w.es = FP_SEG( ColourTable );
    intr( 0x10, &r );

    for( i = 0; i < 256; i++ ) {
      printf( "Colour index = %d "
          "{ Red=%d, Green=%d, Blue=%d }\n",
          i,
          ColourTable[i][0],
          ColourTable[i][1],
          ColourTable[i][2] );
    }
  }

Classification:

Intel

Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

Caveats:

FP_SEG() is a macro.

See also:

FP_OFF(), MK_FP(), segread()


[Previous]
[Contents]
[Next]