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

  1. ; Copyright (C) 1995,1996 CW Sandmann (sandmann@clio.rice.edu) 1206 Braelinn, Sugarland, TX 77479
  2. ;
  3. ; This file is distributed under the terms listed in the document
  4. ; "copying.cws", available from CW Sandmann at the address above.
  5. ; A copy of "copying.cws" should accompany this file; if not, a copy
  6. ; should be available from where this file was obtained.  This file
  7. ; may not be distributed without a verbatim copy of "copying.cws".
  8.  
  9. ; Enters DPMI protected mode and performs an "exit" with magic to unload TSR
  10.  
  11.     title    unload
  12.     include    segdefs.inc
  13.     start_data16
  14.  
  15. dpmi_protsw    dd    0
  16. no_dpmi        db    'CWSDPMI not removed', 13, 10, '$'
  17.  
  18.     end_data16
  19.  
  20.     start_code16
  21.  
  22.     public    _unload_tsr
  23. _unload_tsr:
  24.  
  25.     mov    ax,1687h
  26.     int    2fh                ;DPMI detection
  27.     or    ax,ax
  28.     jz    short dpmi_present
  29.     
  30. exit_error:
  31.     mov    dx,offset DGROUP:no_dpmi
  32.     mov    ah,9
  33.     int    21h
  34.  
  35.     mov    ax,4c01h
  36.     int    21h
  37.  
  38. dpmi_present:
  39.     mov    word ptr dpmi_protsw,di
  40.     mov    word ptr dpmi_protsw+2,es
  41.     mov    bx,si
  42.  
  43.     or    bx,bx                ;Allocate memory for DPMI
  44.     jz    short no_para
  45.     mov    ah,48h
  46.     int    21h
  47.     jc    short exit_error
  48.     mov    es,ax
  49.  
  50. no_para:
  51.     mov    ax,1
  52.     call    dpmi_protsw
  53.     jc    short exit_error
  54.  
  55. ; We are in protected mode
  56.  
  57.     mov    ebx,69151151h            ; Magic for unload
  58.     mov    ax,4c00h
  59.     int    21h
  60.  
  61.     end_code16
  62.     end
  63.