Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
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 macro returns an unsigned integer value which is the segment portion
    of the pointer value.

Example:
    #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

Systems:
    MACRO

See Also:
    FP_OFF, MK_FP, segread

See Also: FP_OFF MK_FP

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson