home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2MISC / CSDPMI3S.ZIP / SRC / CWSDPMI / XMS.ASM < prev    next >
Encoding:
Assembly Source File  |  1996-06-15  |  2.0 KB  |  115 lines

  1. ; Copyright (C) 1995,1996 CW Sandmann (sandmann@clio.rice.edu) 1206 Braelinn, Sugarland, TX 77479
  2.     title    xms
  3.     include    segdefs.inc
  4.  
  5.     start_bss
  6.  
  7. xms_entry    label    dword
  8.     dd    ?
  9.  
  10.     end_bss
  11.  
  12. ;------------------------------------------------------------------------
  13.  
  14.     start_code16
  15.  
  16. ; int xms_installed(void);
  17.     public    _xms_installed
  18. _xms_installed    proc    near
  19.     mov    ax,04300h
  20.     int    02fH
  21.     cmp    al,080h
  22.     je    short present
  23.     xor    ax,ax
  24.     ret
  25. present:
  26.     mov    ax,04310h
  27.     int    02fh
  28.     mov    word ptr xms_entry,bx
  29.     mov    word ptr (xms_entry+2),es
  30.     mov    ax,1
  31.     ret
  32. _xms_installed    endp
  33.  
  34. ; int xms_query_extended_memory(void) - return largest free block
  35.     public    _xms_query_extended_memory
  36. _xms_query_extended_memory    proc    near
  37.     mov    ah,08H
  38.     jmp    short no_arg_common
  39. _xms_query_extended_memory    endp
  40.  
  41. ; int xms_local_enable_a20(void)
  42.     public    _xms_local_enable_a20
  43. _xms_local_enable_a20    proc    near
  44.     mov    ah,05H
  45.     jmp    short no_arg_common
  46. _xms_local_enable_a20    endp
  47.  
  48. ; int xms_local_disable_a20(void)
  49.     public    _xms_local_disable_a20
  50. _xms_local_disable_a20    proc    near
  51.     mov    ah,06H
  52.     jmp    short no_arg_common
  53. _xms_local_disable_a20    endp
  54.  
  55. ; int xms_emb_free(short handle);
  56.     public    _xms_emb_free
  57. _xms_emb_free    proc    near
  58.     mov    ah,00aH
  59. handle_common:
  60.     push    bp
  61.     mov    bp,sp
  62.     mov    dx,[bp+4]
  63.     pop    bp
  64. no_arg_common:
  65.     call    [xms_entry]
  66.     ret
  67. _xms_emb_free    endp
  68.  
  69. ; int xms_unlock_emb(short handle);
  70.     public    _xms_lock_emb
  71. _xms_unlock_emb    proc    near
  72.     mov    ah,00dH
  73.     jmp    short handle_common
  74. _xms_unlock_emb    endp
  75.  
  76. ; ulong xms_lock_emb(short handle);
  77.     public    _xms_unlock_emb
  78. _xms_lock_emb    proc    near
  79.     push    bp
  80.     mov    bp,sp
  81.     mov    ah,00cH
  82.     mov    dx,[bp+4]
  83.      pop    bp
  84.     call    [xms_entry]
  85.     or    ax,ax
  86.     je    short lock_failed
  87.     mov    ax,bx
  88.     ret
  89. lock_failed:
  90.     mov    dx,ax
  91.      ret
  92. _xms_lock_emb    endp
  93.  
  94. ; int xms_emb_allocate(ushort size);
  95.     public    _xms_emb_allocate
  96. _xms_emb_allocate    proc    near
  97.     push    bp
  98.     mov    bp,sp
  99.     mov    ah,09H
  100.     mov    dx,[bp+4]
  101.     pop    bp
  102.     call    [xms_entry]
  103.     or    ax,ax
  104.     je    short alloc_failed
  105.     xchg    ax,dx
  106.     ret
  107. alloc_failed:
  108.     mov    ax,-1
  109.     ret
  110. _xms_emb_allocate    endp
  111.  
  112.     end_code16
  113.  
  114.     end
  115.