home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 024 / psi110g.zip / XMS.ASM < prev    next >
Assembly Source File  |  1993-09-16  |  3KB  |  158 lines

  1. ; XMS routines to get available UMB's and HMA,
  2. ; and allocate extended memory.
  3. ; Written from the XMS 3.0 specification.
  4. ; (C) 1993 Johan. K. Reinalda, WG7J
  5.  
  6. include asmglobal.h
  7.  
  8. .data
  9. XMS_Entry  dd   1
  10.  
  11. .code
  12. public Installed_XMS
  13. public Request_UMB,Release_UMB
  14. public Request_HMA,Release_HMA
  15. public Query_XMS,Total_XMS
  16. public Alloc_XMS,Free_XMS
  17. public Move_XMS
  18.  
  19. Installed_XMS proc
  20.     mov     ax,4300h
  21.     int     2Fh
  22.     cmp     al,80h
  23.     jne     NoXMSDriver
  24. ; Get the address of the driver's control function
  25.     mov     ax,4310h
  26.     int     2Fh
  27.     mov     word ptr [XMS_Entry],bx      ;XMS_Entry is function entry point
  28.     mov     word ptr [XMS_Entry+2],es
  29.     mov     ax, 1
  30.     ret
  31. NoXMSDriver:
  32.     xor     ax, ax
  33.     ret
  34. Installed_XMS endp
  35.  
  36.  
  37. Request_UMB proc
  38.     arg sz:word
  39.  
  40.     mov ah, 10h
  41.     mov dx, sz
  42.     call [XMS_Entry]
  43.     cmp ax, 1
  44.     jne request_failed
  45.     mov ax, bx      ; UMB segment in dx
  46.     jmp request_done
  47. request_failed:
  48.     mov ax, dx      ; set actual size
  49.     mov dh, bl      ; return error code
  50. request_done:
  51.     ret
  52. Request_UMB endp
  53.  
  54. Release_UMB proc
  55.     arg block:word
  56.  
  57.     mov dx, block
  58.     mov ah, 11h
  59.     call [XMS_Entry]
  60.     cmp ax, 1
  61.     jne release_failed
  62.     xor ax, ax
  63.     xor dx, dx
  64.     jmp release_done
  65. release_failed:
  66.     mov dh, bl          ; return error in high byte
  67. release_done:
  68.     ret
  69. Release_UMB endp
  70.  
  71. Request_HMA proc
  72.     mov ah, 01h
  73.     mov dx, 0ffffh      ; we're an application
  74.     call [XMS_Entry]
  75.     ret
  76. Request_HMA endp
  77.  
  78. Release_HMA proc
  79.     mov ah, 02h
  80.     call    [XMS_Entry]
  81.     ret
  82. Release_HMA endp
  83.  
  84. Query_XMS proc
  85.     mov ah, 8
  86.     call    [XMS_Entry]
  87.     xor    dx, dx
  88.     or  ax, ax
  89.     jnz  QLSuccess
  90.     mov    dh, bl
  91. QLSuccess:
  92.     ret
  93. Query_XMS endp
  94.  
  95. Total_XMS proc
  96.     mov    ah, 8
  97.     call    [XMS_Entry]
  98.     xor ax, ax
  99.     mov ax, dx
  100.     mov dx, 0
  101.     jnz QTSuccess
  102.     mov    dh, bl
  103. QTSuccess:
  104.     ret
  105. Total_XMS endp
  106.  
  107. Alloc_XMS proc
  108.     arg sz:word
  109.  
  110.     mov    ah, 9
  111.     mov dx, sz
  112.     call    [XMS_Entry]
  113.     xor ax, ax
  114.     mov ax, dx
  115.     mov dx, 0
  116.     jnz AESuccess
  117.     mov    dh, bl
  118. AESuccess:
  119.     ret
  120. Alloc_XMS endp
  121.  
  122. Free_XMS proc
  123.     arg handle:word
  124.  
  125.     mov ah, 0Ah
  126.     mov dx, handle
  127.     call    [XMS_Entry]
  128.     xor    dx, dx
  129.     dec    ax
  130.     jz  FSuccess
  131.     mov dl, bl
  132. FSuccess:
  133.     ret
  134. Free_XMS endp
  135.  
  136. Move_XMS proc
  137.     arg buf:dword
  138.  
  139.     push ds
  140.     push si
  141.  
  142. ; DS:SI = pointer to XMS move stucture
  143.     lds si, buf
  144.     mov ah, 0bh
  145.     call    [XMS_Entry]
  146.     xor dx, dx
  147.     dec    ax
  148.     jz  MSuccess
  149.     mov    dh, bl
  150. MSuccess:
  151.     pop si
  152.     pop ds
  153.     ret
  154. Move_XMS endp
  155.  
  156. END
  157.  
  158.