home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / c / other / memory / movemem.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-11-01  |  1.6 KB  |  57 lines

  1. /* MOVEMEM.C illustrate direct memory access using functions:
  2.  *      movedata        FP_SEG          FP_OFF
  3.  *
  4.  * Also illustrated:
  5.  *      pack pragma
  6.  *
  7.  * See COPY2.C for another example of FP_SEG.
  8.  */
  9.  
  10. #include <memory.h>
  11. #include <stdio.h>
  12. #include <dos.h>
  13.  
  14. #pragma pack(1)     /* Use pragma to force packing on byte boundaries. */
  15.  
  16. struct LOWMEMVID
  17. {
  18.     char     vidmode;       /* 0x449 */
  19.     unsigned scrwid;        /* 0x44A */
  20.     unsigned scrlen;        /* 0x44C */
  21.     unsigned scroff;        /* 0x44E */
  22.     struct   LOCATE
  23.     {
  24.         unsigned char col;
  25.         unsigned char row;
  26.     } csrpos[8];            /* 0x450 */
  27.     struct   CURSIZE
  28.     {
  29.         unsigned char end;
  30.         unsigned char start;
  31.     } csrsize;              /* 0x460 */
  32.     char     page;          /* 0x462 */
  33. } vid;
  34. struct LOWMEMVID far *pvid = &vid;
  35.  
  36. main()
  37. {
  38.     int page;
  39.  
  40.     /* Move system information into uninitialized structure variable. */
  41.     movedata( 0, 0x449, FP_SEG( pvid ), FP_OFF( pvid ), sizeof( vid ) );
  42.  
  43.     printf( "Move data from low memory 0000:0449 to structure at %Fp\n\n",
  44.              (void far *)&vid );
  45.  
  46.     printf( "Mode:\t\t\t%u\n", vid.vidmode );
  47.     printf( "Page:\t\t\t%u\n", vid.page );
  48.     printf( "Screen width:\t\t%u\n", vid.scrwid );
  49.     printf( "Screen length:\t\t%u\n", vid.scrlen );
  50.     printf( "Cursor size:\t\tstart: %u\tend: %u\n",
  51.              vid.csrsize.start, vid.csrsize.end );
  52.     printf( "Cursor location:\t" );
  53.     for( page = 0; page < 8; page++ )
  54.         printf( "page:\t%u\tcolumn: %u\trow: %u\n\t\t\t",
  55.                 page, vid.csrpos[page].col, vid.csrpos[page].row );
  56. }
  57.