home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / doc / ems / disk2 / emm15_d.asm < prev    next >
Assembly Source File  |  1989-11-29  |  6KB  |  105 lines

  1. ;-----------------------------------------------------------------------------;
  2. ;      MODULE NAME:   EMM15_D.ASM                                             ;
  3. ;                                                                             ;
  4. ;    FUNCTION NAME:   get_context_size                                        ;
  5. ;                                                                             ;
  6. ;      DESCRIPTION:   This function returns the storage requirements for the  ;
  7. ;                     structure passed by the get_context, set_context, and   ;
  8. ;                     get_set_context functions.  Use this function when you  ;
  9. ;                     want to dynamically allocate this space.  This function ;
  10. ;                     doesn't require an EMM handle.                          ;
  11. ;                                                                             ;
  12. ;           PASSED:   &context_size:                                          ;
  13. ;                        is a far pointer to the size of the mapping context  ;
  14. ;                        structure.                                           ;
  15. ;                                                                             ;
  16. ;         RETURNED:   status:                                                 ;
  17. ;                        is the status EMM returns from the call.  All other  ;
  18. ;                        returned results are valid only if the status        ;
  19. ;                        returned is zero.  Otherwise they are undefined.     ;
  20. ;                                                                             ;
  21. ;                     context_size:                                           ;
  22. ;                        is the size of the mapping context structure.        ;
  23. ;                        Normally, you just supply a CONTEXT_STRUCT structure ;
  24. ;                        which contains an array of the largest space         ;
  25. ;                        possible (currently 255 bytes).  However, if you     ;
  26. ;                        want to dynamically allocate the exact amount of     ;
  27. ;                        space required to save a context, use this function  ;
  28. ;                        to get the size needed.  (See example below.)  The   ;
  29. ;                        size depends on how the expanded memory system is    ;
  30. ;                        configured and how the expanded memory manager is    ;
  31. ;                        implemented.                                         ;
  32. ;                                                                             ;
  33. ; C USE CONVENTION:   unsigned int status;                                    ;
  34. ;                     unsigned int context_size;                              ;
  35. ;                     void         *context;                                  ;
  36. ;                                                                             ;
  37. ;                     status = get_context_size (&context_size);              ;
  38. ;                     if (status == PASSED)                                   ;
  39. ;                     {                                                       ;
  40. ;                        context = malloc (context_size);                     ;
  41. ;                        if (context == NULL)                                 ;
  42. ;                           /* error condition (no memory to allocate) */     ;
  43. ;                        else                                                 ; 
  44. ;                        {                                                    ;
  45. ;                           status = get_context ((CONTEXT_STRUCT *) context);;
  46. ;                           if (status == PASSED)                             ;
  47. ;                              printf ("context saved\n");                    ;
  48. ;                           else                                              ;
  49. ;                              /* error condition */                          ;
  50. ;                        }                                                    ;
  51. ;                     }                                                       ;
  52. ;                     else                                                    ;
  53. ;                        /* error condition */                                ;
  54. ;-----------------------------------------------------------------------------;
  55. .XLIST
  56. PAGE    60,132
  57.  
  58. IFDEF SMALL
  59.    .MODEL SMALL, C
  60. ENDIF
  61. IFDEF MEDIUM
  62.    .MODEL MEDIUM, C
  63. ENDIF
  64. IFDEF LARGE
  65.    .MODEL LARGE, C
  66. ENDIF
  67. IFDEF COMPACT
  68.    .MODEL COMPACT, C
  69. ENDIF
  70. IFDEF HUGE
  71.    .MODEL HUGE, C
  72. ENDIF
  73.  
  74. INCLUDE emmlib.equ
  75. INCLUDE emmlib.str
  76. INCLUDE emmlib.mac
  77. .LIST
  78. .CODE
  79.  
  80. get_context_size    PROC                                                  \
  81.             ptr_context_size:FAR PTR WORD
  82.  
  83.     ;---------------------------------------------------------------------;
  84.     ;   do;                                                               ;
  85.     ;   .   get the MAXIMUM memory mapping context size from EMM;         ;
  86.     ;---------------------------------------------------------------------;
  87.     MOVE        AX, get_size_page_map_array_fcn
  88.     INT         EMM_int
  89.  
  90.     ;---------------------------------------------------------------------;
  91.     ;   .   pass the MAX size back to the caller;                         ;
  92.     ;---------------------------------------------------------------------;
  93.     MOVE        ES:BX, ptr_context_size
  94.     MOVE        ES:[BX], AX
  95.  
  96.     ;---------------------------------------------------------------------;
  97.     ;   .   return (EMM status);                                          ;
  98.     ;   end;                                                              ;
  99.     ;---------------------------------------------------------------------;
  100.     RET_EMM_STAT    AH
  101.  
  102. get_context_size    ENDP
  103.  
  104. END
  105.