home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 14 / CDACTUAL.iso / cdactual / demobin / share / program / c / XMSLIB12.ZIP / XMSLIB.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-03-08  |  24.9 KB  |  546 lines

  1. %title "XMSLIB.ASM - Interface to the XMS driver for TurboC 2.0 and TC++ 1.0"
  2. %subttl "Copyright 1990, 1991 by Michael Graff"
  3.  
  4. ; This package allows TurboC programs to use a XMS driver to store data
  5.  
  6. ; Version 1.2, 08-Mar-91
  7.  
  8.         ideal
  9.         model   large                   ; use LARGE model for this.  However,
  10.                                         ; other TC models (other than possibly
  11.                                         ; HUGE) should work as well.
  12.  
  13. TRUE    equ     1
  14. FALSE   equ     0
  15.  
  16. XGetVersion     equ     00h             ; commands to the XMS driver
  17. XRequestHMA     equ     01h
  18. XReleaseHMA     equ     02h
  19. XGlobalE20      equ     03h
  20. XGlobalD20      equ     04h
  21. XLocalE20       equ     05h
  22. XLocalD20       equ     06h
  23. XQuery20        equ     07h
  24. XGetMemSize     equ     08h
  25. XAllocEMB       equ     09h
  26. XFreeEMB        equ     0ah
  27. XMoveEMB        equ     0bh
  28. XLockEMB        equ     0ch
  29. XUnlockEMB      equ     0dh
  30. XGetHandleInfo  equ     0eh
  31. XReallocEMB     equ     0fh
  32. XRequestUMB     equ     10h
  33. XReleaseUMB     equ     11h
  34.  
  35. ENone           equ     00h             ; "no error" error code
  36. ENotInitd       equ     01h             ; XMSSetup was never called before other XMS funcs
  37.  
  38. struc   ExtMemMoveStruct
  39.         Length          dd      ?       ; 32-bit number of bytes to transfer
  40.         SourceHandle    dw      ?       ; Handle of source block
  41.         SourceOffset    dd      ?       ; 32-bit offset into source block
  42.         DestHandle      dw      ?       ; Handle of dest block
  43.         DestOffset      dd      ?       ; 32-bit offset into dest block
  44. ends    ExtMemMoveStruct
  45.  
  46.         codeseg
  47. _XMSDriver      dd      ?
  48. _XMSInitd       dw      FALSE
  49.  
  50. public  _XMS_Setup,_XMS_Version,_XMS_RequestHMA,_XMS_ReleaseHMA,_XMS_FreeMem
  51. public  _XMS_GlobalEnableA20,_XMS_GlobalDisableA20,_XMS_LocalEnableA20
  52. public  _XMS_LocalDisableA20,_XMS_QueryA20,_XMS_AllocEMB,_XMS_FreeEMB
  53. public  _XMS_MoveEMB,_XMS_LockEMB,_XMS_UnlockEMB,_XMS_GetEMBHandleInfo
  54. public  _XMS_ReallocEMB,_XMS_RequestUMB,_XMS_ReleaseUMB
  55.  
  56. ;--------------------------------------------------------------------------
  57. ; extern unsigned int far XMS_Setup(void);
  58. ;--------------------------------------------------------------------------
  59.  
  60. proc    _XMS_Setup       far
  61.         push    bp                      ; save TurboC's bp
  62.         mov     bp,sp                   ; use bp to address parameters
  63.         mov     [_XMSInitd],0           ; Routine has not init'd yet
  64.         mov     ax,4300h                ; XMS Driver installation check
  65.         int     2fh
  66.         cmp     al,80h                  ; returns 80h if installed
  67.         jmp short @@xmsfound
  68.         mov     ax,FALSE                ; XMS Driver not present
  69.         jmp     @@exit
  70. @@xmsfound:
  71.         mov     ax,4310h                ; get address of XMS driver
  72.         int     2fh
  73.         mov     [word _XMSDriver],bx    ; store offset
  74.         mov     [word _XMSDriver+2],es  ; store segment
  75.         inc     [_XMSInitd]             ; we have init'd our code
  76.         mov     ax,TRUE
  77. @@exit:
  78.         pop     bp                      ; restore TurboC's bp
  79.         ret                             ; we outa here
  80. endp    _XMS_Setup
  81.  
  82. ;-------------------------------------------------------------------------------
  83. ; extern unsigned char far XMS_Version(
  84. ;       unsigned int far *version, unsigned int far *internal,
  85. ;       unsigned int far *HMA);
  86. ;-------------------------------------------------------------------------------
  87.  
  88. proc    _XMS_Version     far
  89.         arg version:dword,internal:dword,HMA:dword
  90.  
  91.         push    bp                      ; save TurboC's bp
  92.         mov     bp,sp                   ; use bp to address parameters
  93.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  94.         jne     @@hasinitd              ; yes, continue
  95.         mov     al,ENotInitd            ; nope, return error code
  96.         jmp     short @@exit
  97. @@hasinitd:
  98.         mov     ah,XGetVersion          ; function to get version of HMA driver
  99.         call    [dword _XMSDriver]      ; call the XMS driver
  100.         les     di,[version]            ; point es:di to variable
  101.         mov     [word ptr es:di],ax
  102.         les     di,[internal]
  103.         mov     [word ptr es:di],bx
  104.         les     di,[HMA]
  105.         mov     [word ptr es:di],dx
  106.         mov     al,ENone                ; no error can occur here (?)
  107. @@exit:
  108.         pop     bp                      ; restore TurboC's bp
  109.         ret                             ; we outa here
  110. endp    _XMS_Version
  111.  
  112. ;-------------------------------------------------------------------------------
  113. ; extern unsigned char far XMS_RequestHMA(unsigned int size);
  114. ;-------------------------------------------------------------------------------
  115.  
  116. proc    _XMS_RequestHMA  far
  117.         arg size:word
  118.  
  119.         push    bp                      ; save TurboC's bp
  120.         mov     bp,sp                   ; use bp to address parameters
  121.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  122.         jne     @@hasinitd              ; yes, continue
  123.         mov     al,ENotInitd            ; nope, return error code
  124.         jmp     short @@exit
  125. @@hasinitd:
  126.         mov     dx,[size]               ; ammount of HMA wanted
  127.         mov     ah,XRequestHMA          ; function to allocate HMA
  128.         call    [dword _XMSDriver]      ; call the XMS driver
  129.         mov     al,bl                   ; return any error codes generated
  130. @@exit:
  131.         pop     bp                      ; restore TurboC's bp
  132.         ret                             ; we outa here
  133. endp    _XMS_RequestHMA
  134.  
  135. ;-------------------------------------------------------------------------------
  136. ; extern unsigned char far XMS_ReleaseHMA(void);
  137. ;-------------------------------------------------------------------------------
  138.  
  139. proc    _XMS_ReleaseHMA far
  140.  
  141.         push    bp                      ; save TurboC's bp
  142.         mov     bp,sp                   ; use bp to address parameters
  143.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  144.         jne     @@hasinitd              ; yes, continue
  145.         mov     al,ENotInitd            ; nope, return error code
  146.         jmp     short @@exit
  147. @@hasinitd:
  148.         mov     dx,[size]               ; ammount of HMA wanted
  149.         mov     ah,XReleaseHMA          ; function to release HMA
  150.         call    [dword _XMSDriver]      ; call the XMS driver
  151.         mov     al,bl                   ; return any error codes generated
  152. @@exit:
  153.         pop     bp                      ; restore TurboC's bp
  154.         ret                             ; we outa here
  155. endp    _XMS_ReleaseHMA
  156.  
  157. ;-------------------------------------------------------------------------------
  158. ; extern unsigned char far XMS_GlobalEnableA20(void);
  159. ;-------------------------------------------------------------------------------
  160.  
  161. proc    _XMS_GlobalEnableA20    far
  162.  
  163.         push    bp                      ; save TurboC's bp
  164.         mov     bp,sp                   ; use bp to address parameters
  165.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  166.         jne     @@hasinitd              ; yes, continue
  167.         mov     al,ENotInitd            ; nope, return error code
  168.         jmp     short @@exit
  169. @@hasinitd:
  170.         mov     dx,[size]               ; ammount of HMA wanted
  171.         mov     ah,XGlobalE20           ; function code
  172.         call    [dword _XMSDriver]      ; call the XMS driver
  173.         mov     al,bl                   ; return any error codes generated
  174. @@exit:
  175.         pop     bp                      ; restore TurboC's bp
  176.         ret                             ; we outa here
  177. endp    _XMS_GlobalEnableA20
  178.  
  179. ;-------------------------------------------------------------------------------
  180. ; extern unsigned char far XMS_GlobalDisableA20(void);
  181. ;-------------------------------------------------------------------------------
  182.  
  183. proc    _XMS_GlobalDisableA20   far
  184.  
  185.         push    bp                      ; save TurboC's bp
  186.         mov     bp,sp                   ; use bp to address parameters
  187.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  188.         jne     @@hasinitd              ; yes, continue
  189.         mov     al,ENotInitd            ; nope, return error code
  190.         jmp     short @@exit
  191. @@hasinitd:
  192.         mov     dx,[size]               ; ammount of HMA wanted
  193.         mov     ah,XGlobalD20           ; function code
  194.         call    [dword _XMSDriver]      ; call the XMS driver
  195.         mov     al,bl                   ; return any error codes generated
  196. @@exit:
  197.         pop     bp                      ; restore TurboC's bp
  198.         ret                             ; we outa here
  199. endp    _XMS_GlobalDisableA20
  200.  
  201. ;-------------------------------------------------------------------------------
  202. ; extern unsigned char far XMS_LocalEnableA20(void);
  203. ;-------------------------------------------------------------------------------
  204.  
  205. proc    _XMS_LocalEnableA20     far
  206.  
  207.         push    bp                      ; save TurboC's bp
  208.         mov     bp,sp                   ; use bp to address parameters
  209.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  210.         jne     @@hasinitd              ; yes, continue
  211.         mov     al,ENotInitd            ; nope, return error code
  212.         jmp     short @@exit
  213. @@hasinitd:
  214.         mov     dx,[size]               ; ammount of HMA wanted
  215.         mov     ah,XLocalE20            ; function code
  216.         call    [dword _XMSDriver]      ; call the XMS driver
  217.         mov     al,bl                   ; return any error codes generated
  218. @@exit:
  219.         pop     bp                      ; restore TurboC's bp
  220.         ret                             ; we outa here
  221. endp    _XMS_LocalEnableA20
  222.  
  223. ;-------------------------------------------------------------------------------
  224. ; extern unsigned char far XMS_LocalDisableA20(void);
  225. ;-------------------------------------------------------------------------------
  226.  
  227. proc    _XMS_LocalDisableA20    far
  228.  
  229.         push    bp                      ; save TurboC's bp
  230.         mov     bp,sp                   ; use bp to address parameters
  231.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  232.         jne     @@hasinitd              ; yes, continue
  233.         mov     al,ENotInitd            ; nope, return error code
  234.         jmp     short @@exit
  235. @@hasinitd:
  236.         mov     dx,[size]               ; ammount of HMA wanted
  237.         mov     ah,XLocalD20            ; function code
  238.         call    [dword _XMSDriver]      ; call the XMS driver
  239.         mov     al,bl                   ; return any error codes generated
  240. @@exit:
  241.         pop     bp                      ; restore TurboC's bp
  242.         ret                             ; we outa here
  243. endp    _XMS_LocalDisableA20
  244.  
  245. ;-------------------------------------------------------------------------------
  246. ; extern unsigned char far XMS_QueryA20(unsigned int far *state);
  247. ;-------------------------------------------------------------------------------
  248.  
  249. proc    _XMS_QueryA20   far
  250.         arg     state:dword
  251.         push    bp                      ; save TurboC's bp
  252.         mov     bp,sp                   ; use bp to address parameters
  253.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  254.         jne     @@hasinitd              ; yes, continue
  255.         mov     al,ENotInitd            ; nope, return error code
  256.         jmp     short @@exit
  257. @@hasinitd:
  258.         mov     dx,[size]               ; ammount of HMA wanted
  259.         mov     ah,XQuery20             ; function code
  260.         call    [dword _XMSDriver]      ; call the XMS driver
  261.         les     di,[state]              ; point to return value
  262.         mov     [word ptr es:di],ax     ; return A20 state
  263.         mov     al,bl                   ; return any error codes generated
  264. @@exit:
  265.         pop     bp                      ; restore TurboC's bp
  266.         ret                             ; we outa here
  267. endp    _XMS_QueryA20
  268.  
  269. ;-------------------------------------------------------------------------------
  270. ; extern unsigned char far XMS_FreeMem(
  271. ;       unsigned int far *freemem, unsigned int far *totmem);
  272. ;-------------------------------------------------------------------------------
  273.  
  274. proc    _XMS_FreeMem     far
  275.         arg freemem:dword,totmem:dword
  276.  
  277.         push    bp                      ; save TurboC's bp
  278.         mov     bp,sp                   ; use bp to address parameters
  279.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  280.         jne     @@hasinitd              ; yes, continue
  281.         mov     al,ENotInitd            ; nope, return error code
  282.         jmp     short @@exit
  283. @@hasinitd:
  284.         mov     ah,XGetMemSize          ; function to get free/total memory
  285.         call    [dword _XMSDriver]      ; call the XMS driver
  286.         les     di,[freemem]            ; point es:di to freemem
  287.         mov     [word ptr es:di],ax
  288.         les     di,[totmem]
  289.         mov     [word ptr es:di],dx
  290.         mov     al,bl                   ; transfer XMS error code to al
  291. @@exit:
  292.         pop     bp                      ; restore TurboC's bp
  293.         ret                             ; we outa here
  294. endp    _XMS_FreeMem
  295.  
  296. ;-------------------------------------------------------------------------------
  297. ; extern unsigned char far XMS_AllocEMB(
  298. ;       unsigned int size, unsigned int far *handle);
  299. ;-------------------------------------------------------------------------------
  300.  
  301. proc    _XMS_AllocEMB   far
  302.         arg size:word,handle:dword
  303.  
  304.         push    bp                      ; save TurboC's bp
  305.         mov     bp,sp                   ; use bp to address parameters
  306.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  307.         jne     @@hasinitd              ; yes, continue
  308.         mov     al,ENotInitd            ; nope, return error code
  309.         jmp     short @@exit
  310. @@hasinitd:
  311.         mov     ah,XAllocEMB            ; function code
  312.         mov     dx,[size]               ; number of K to allocate
  313.         call    [dword _XMSDriver]      ; call the XMS driver
  314.         les     di,[handle]
  315.         mov     [word ptr es:di],dx     ; save handle number
  316.         mov     al,bl                   ; transfer XMS error code to al
  317. @@exit:
  318.         pop     bp                      ; restore TurboC's bp
  319.         ret                             ; we outa here
  320. endp    _XMS_AllocEMB
  321.  
  322. ;-------------------------------------------------------------------------------
  323. ; extern unsigned char far XMS_FreeEMB(unsigned int handle);
  324. ;-------------------------------------------------------------------------------
  325.  
  326. proc    _XMS_FreeEMB    far
  327.         arg     handle:word
  328.  
  329.         push    bp                      ; save TurboC's bp
  330.         mov     bp,sp                   ; use bp to address parameters
  331.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  332.         jne     @@hasinitd              ; yes, continue
  333.         mov     al,ENotInitd            ; nope, return error code
  334.         jmp     short @@exit
  335. @@hasinitd:
  336.         mov     ah,XFreeEMB             ; function code
  337.         mov     dx,[handle]             ; handle number to free
  338.         call    [dword _XMSDriver]      ; call the XMS driver
  339.         mov     al,bl                   ; transfer XMS error code to al
  340. @@exit:
  341.         pop     bp                      ; restore TurboC's bp
  342.         ret                             ; we outa here
  343. endp    _XMS_FreeEMB
  344.  
  345. ;-------------------------------------------------------------------------------
  346. ; extern unsigned char far XMS_MoveEMB(struct EMMMoveStruct far *MoveRec);
  347. ;-------------------------------------------------------------------------------
  348.  
  349. proc    _XMS_MoveEMB    far
  350.         arg     MoveRec:dword
  351.  
  352.         push    bp                      ; save TurboC's bp
  353.         mov     bp,sp                   ; use bp to address parameters
  354.         xor     bl,bl                   ; reset error code to 0
  355.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  356.         jne     @@hasinitd              ; yes, continue
  357.         mov     al,ENotInitd            ; nope, return error code
  358.         jmp     short @@exit
  359. @@hasinitd:
  360.         push    ds                      ; save Turbo's data segment
  361.         mov     ah,XMoveEMB             ; function code
  362.         lds     si,[MoveRec]            ; Point ds:si to MoveRec
  363.         call    [dword cs:_XMSDriver]   ; call the XMS driver
  364.         mov     al,bl                   ; transfer XMS error code to al
  365.         pop     ds                      ; restore Turbo's data segment
  366. @@exit:
  367.         pop     bp                      ; restore TurboC's bp
  368.         ret                             ; we outa here
  369. endp    _XMS_MoveEMB
  370.  
  371. ;-------------------------------------------------------------------------------
  372. ; extern unsigned char far XMS_LockEMB(unsigned int handle, void far *address);
  373. ;-------------------------------------------------------------------------------
  374.  
  375. proc    _XMS_LockEMB    far
  376.         arg     handle:word,address:dword
  377.  
  378.         push    bp                      ; save TurboC's bp
  379.         mov     bp,sp                   ; use bp to address parameters
  380.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  381.         jne     @@hasinitd              ; yes, continue
  382.         mov     al,ENotInitd            ; nope, return error code
  383.         jmp     short @@exit
  384. @@hasinitd:
  385.         mov     ah,XLockEMB             ; function code
  386.         mov     dx,[handle]             ; handle number to Lock
  387.         call    [dword _XMSDriver]      ; call the XMS driver
  388.         cmp     ax,1                    ; was the call successful?
  389.         je      @@success               ; yep, so jump!
  390.         mov     al,bl                   ; transfer XMS error code to al
  391.         jmp     short @@exit            ; get out
  392. @@success:
  393.         mov     al,0                    ; return no error code
  394.         les     di,[address]            ; point to address
  395.         mov     [word ptr es:di],bx     ; store the offset
  396.         mov     [word ptr es:di+2],dx   ; store the segment
  397. @@exit:
  398.         pop     bp                      ; restore TurboC's bp
  399.         ret                             ; we outa here
  400. endp    _XMS_LockEMB
  401.  
  402. ;-------------------------------------------------------------------------------
  403. ; extern unsigned char far XMS_UnlockEMB(unsigned int handle);
  404. ;-------------------------------------------------------------------------------
  405.  
  406. proc    _XMS_UnlockEMB  far
  407.         arg     handle:word
  408.  
  409.         push    bp                      ; save TurboC's bp
  410.         mov     bp,sp                   ; use bp to address parameters
  411.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  412.         jne     @@hasinitd              ; yes, continue
  413.         mov     al,ENotInitd            ; nope, return error code
  414.         jmp     short @@exit
  415. @@hasinitd:
  416.         mov     ah,XUnlockEMB           ; function code
  417.         mov     dx,[handle]             ; handle number to Unlock
  418.         call    [dword _XMSDriver]      ; call the XMS driver
  419.         mov     al,bl                   ; transfer XMS error code to al
  420. @@exit:
  421.         pop     bp                      ; restore TurboC's bp
  422.         ret                             ; we outa here
  423. endp    _XMS_UnlockEMB
  424.  
  425. ;-------------------------------------------------------------------------------
  426. ; extern unsigned char far XMS_GetEMBHandleInfoEMB(
  427. ;       unsigned int handle, unsigned char far *LockCount,
  428. ;       unsigned char far *EMBHandlesFree, unsigned int far *length);
  429. ;-------------------------------------------------------------------------------
  430.  
  431. proc    _XMS_GetEMBHandleInfo   far
  432.         arg     handle:word,LockCount:dword,EMBHandlesFree:dword,length:dword
  433.  
  434.         push    bp                      ; save TurboC's bp
  435.         mov     bp,sp                   ; use bp to address parameters
  436.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  437.         jne     @@hasinitd              ; yes, continue
  438.         mov     al,ENotInitd            ; nope, return error code
  439.         jmp     short @@exit
  440. @@hasinitd:
  441.         mov     ah,XGetHandleInfo       ; function code
  442.         mov     dx,[handle]             ; handle number to GetEMBHandleInfo
  443.         call    [dword _XMSDriver]      ; call the XMS driver
  444.         cmp     ax,1                    ; was the call successful?
  445.         je      @@success               ; yep, so jump!
  446.         mov     al,bl                   ; transfer XMS error code to al
  447.         jmp     short @@exit            ; get out
  448. @@success:
  449.         mov     al,0                    ; return no error code
  450.         les     di,[LockCount]          ; set up es:di as a pointer
  451.         mov     [byte ptr es:di],bh     ; save lock count
  452.         les     di,[EMBHandlesFree]
  453.         mov     [byte ptr es:di],bl     ; save # of free handles in system
  454.         les     di,[length]
  455.         mov     [word ptr es:di],dx     ; save block length
  456. @@exit:
  457.         pop     bp                      ; restore TurboC's bp
  458.         ret                             ; we outa here
  459. endp    _XMS_GetEMBHandleInfo
  460.  
  461. ;-------------------------------------------------------------------------------
  462. ; extern unsigned char far XMS_ReallocEMB(
  463. ;       unsigned int handle, unsigned int newsize);
  464. ;-------------------------------------------------------------------------------
  465.  
  466. proc    _XMS_ReallocEMB  far
  467.         arg     handle:word,newsize:word
  468.  
  469.         push    bp                      ; save TurboC's bp
  470.         mov     bp,sp                   ; use bp to address parameters
  471.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  472.         jne     @@hasinitd              ; yes, continue
  473.         mov     al,ENotInitd            ; nope, return error code
  474.         jmp     short @@exit
  475. @@hasinitd:
  476.         mov     ah,XReallocEMB          ; function code
  477.         mov     dx,[handle]             ; handle number to reallocate
  478.         mov     bx,[newsize]            ; new size wanted
  479.         call    [dword _XMSDriver]      ; call the XMS driver
  480.         mov     al,bl                   ; transfer XMS error code to al
  481. @@exit:
  482.         pop     bp                      ; restore TurboC's bp
  483.         ret                             ; we outa here
  484. endp    _XMS_ReallocEMB
  485.  
  486. ;-------------------------------------------------------------------------------
  487. ; extern unsigned char far XMS_RequestUMB(
  488. ;       unsigned int SizeWanded,
  489. ;       unsigned int far *segaddr,
  490. ;       unsigned int far *SizeUgot);
  491. ;-------------------------------------------------------------------------------
  492.  
  493. proc    _XMS_RequestUMB far
  494.         arg     sizewanted:word,segaddr:dword,SizeUgot:dword
  495.  
  496.         push    bp                      ; save TurboC's bp
  497.         mov     bp,sp                   ; use bp to address parameters
  498.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  499.         jne     @@hasinitd              ; yes, continue
  500.         mov     al,ENotInitd            ; nope, return error code
  501.         jmp     short @@exit
  502. @@hasinitd:
  503.         mov     ah,XRequestUMB          ; function code
  504.         mov     dx,[sizewanted]         ; nuumber of paragraphs we want
  505.         call    [dword _XMSDriver]      ; call the XMS driver
  506.         les     di,[SizeUgot]           ; we store a value here all the time
  507.         mov     [word ptr es:di],dx     ; either size requested or max free
  508.         cmp     ax,1                    ; was the call successful?
  509.         je      @@success               ; yep, so jump!
  510.         mov     al,bl                   ; transfer XMS error code to al
  511.         jmp     short @@exit            ; get out
  512. @@success:
  513.         mov     al,0                    ; return no error code
  514.         les     di,[segaddr]            ; point to address
  515.         mov     [word ptr es:di],bx     ; store the segment
  516. @@exit:
  517.         pop     bp                      ; restore TurboC's bp
  518.         ret                             ; we outa here
  519. endp    _XMS_RequestUMB
  520.  
  521. ;-------------------------------------------------------------------------------
  522. ; extern unsigned char far XMS_ReleaseUMB(unsigned int segaddr);
  523. ;-------------------------------------------------------------------------------
  524.  
  525. proc    _XMS_ReleaseUMB  far
  526.         arg     segaddr:word
  527.  
  528.         push    bp                      ; save TurboC's bp
  529.         mov     bp,sp                   ; use bp to address parameters
  530.         cmp     [_XMSInitd],0           ; has XMSSetup been called?
  531.         jne     @@hasinitd              ; yes, continue
  532.         mov     al,ENotInitd            ; nope, return error code
  533.         jmp     short @@exit
  534. @@hasinitd:
  535.         mov     ah,XReleaseUMB          ; function code
  536.         mov     dx,[segaddr]            ; handle number to Release
  537.         call    [dword _XMSDriver]      ; call the XMS driver
  538.         mov     al,bl                   ; transfer XMS error code to al
  539. @@exit:
  540.         pop     bp                      ; restore TurboC's bp
  541.         ret                             ; we outa here
  542. endp    _XMS_ReleaseUMB
  543.  
  544. ;------------- End of file! ---------------------------------------------------
  545.         end
  546.