home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / msj / msjv3_1 / lim4 / move_exc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-02  |  1.9 KB  |  61 lines

  1. /*
  2.  
  3. Figure 6
  4. ========
  5.  
  6. */
  7.  
  8. /******************************************************************/
  9. /* This function implements MOVE or EXCHANGE MEMORY REGION        */
  10. /* function to move or exchange conventional memory with expanded */
  11. /* memory pages                                                   */
  12. /******************************************************************/
  13.  
  14. int move_exchg_to_expanded(function_number, conv_buffer,  handle, 
  15.                            page, length)
  16. unsigned int function_number ; /* Move or Exchange*/
  17. char far *conv_buffer ;        /* conventional memory with */
  18. int handle;                    /* EMM memory associated with 
  19.                                   this handle */
  20. int page ;                     /* at this physical page */
  21. unsigned long int length;      /* and this many bytes */
  22.  
  23. {
  24. struct move_exchg 
  25.  {
  26.    unsigned long int region_length;
  27.    char source_type ;
  28.    unsigned int source_handle ;
  29.    unsigned int source_offset ;
  30.    unsigned int source_seg_page;
  31.    char dest_type;
  32.    unsigned int dest_handle;
  33.    unsigned int dest_offset;
  34.    unsigned int dest_seg_page;
  35.   } move_exchg_struct;
  36. struct move_exchg *move_exchg_ptr;  
  37.  
  38.   /* START OF FUNCTION CODE */
  39.  
  40.   move_exchg_struct.region_length  = length ;
  41.   move_exchg_struct.source_type    = 0;
  42.   move_exchg_struct.source_handle  = 0;
  43.   move_exchg_struct.source_offset   = FP_OFF(conv_buffer);
  44.   move_exchg_struct.source_seg_page = FP_SEG(conv_buffer);
  45.   move_exchg_struct.dest_type      = 1;
  46.   move_exchg_struct.dest_handle    = handle;
  47.   move_exchg_struct.dest_offset    = 0 ;
  48.   move_exchg_struct.dest_seg_page  = page;
  49.  
  50.   /* Setup structure to make int86x call */
  51.  
  52.   inregs.x.ax = function_number;
  53.   move_exchg_ptr = &move_exchg_struct;
  54.   inregs.x.si = FP_OFF(move_exchg_ptr);
  55.   segregs.ds  = FP_SEG(move_exchg_ptr);
  56.   int86x(EMM_INT, &inregs, &outregs, &segregs);
  57.   if (outregs.h.ah != 0) exit(1);
  58.  
  59.   return(outregs.x.ax) ;
  60.          
  61. }