home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / microsft / xms20.arc / CLIB.ARC / XMM.ASM < prev    next >
Assembly Source File  |  1989-03-21  |  5KB  |  296 lines

  1.     TITLE   XMM_INTERFACE.ASM
  2.     NAME    XMM_INTERFACE
  3.  
  4. ;*******************************************************************************
  5. ;                                           ;
  6. ;    XMM C Interface Routines                           ;
  7. ;                                           ;
  8. ;    Copyright (c) 1988, Microsoft Corporation                   ;
  9. ;                                           ;
  10. ;*******************************************************************************
  11.  
  12. ?PLM=0
  13. ?WIN=0
  14.  
  15. include    cmacros.inc
  16.  
  17. sBegin    Data
  18. XMM_Initialised    dw    0
  19. XMM_Control    label    dword
  20.         dw    CodeOFFSET XMM_NotInitialised
  21.         dw    seg _TEXT
  22. sEnd    Data
  23.  
  24. sBegin    Code
  25. assumes    cs, Code
  26. assumes ds, DGROUP
  27.  
  28. ;
  29. ; Macro to convert from XMS success/fail to
  30. ; a form more acceptable for C.  IE.
  31. ;
  32. ; AX == 1 becomes DX:AX = 0
  33. ; AX != 1 becomes DX:AX = BL << 24 | (AX - 1)
  34. ;
  35. ; Since Error Codes returned in BL have the top bit
  36. ; set, C will interpret the return as negative.
  37. ;
  38. SuccessFail    macro
  39.     local    Success
  40.     xor    dx, dx
  41.     dec    ax
  42.     jz    Success
  43.     mov    dh, bl
  44. Success:
  45.     endm
  46.  
  47. ;
  48. ; Macro to convert from XMS return value in AX
  49. ; a form more acceptable for C.  IE.
  50. ;
  51. ; AX != 0 becomes DX:AX = AX
  52. ; AX == 0 becomes DX:AX = BL << 24 | AX
  53. ;
  54. ; Since Error Codes returned in BL have the top bit
  55. ; set, C will interpret the return as negative.
  56. ; XMS returns of this type return BL == 0 on success.
  57. ;
  58. SuccessFailAX    macro
  59.     local    Success
  60.     xor    dx, dx
  61.     or    ax, ax
  62.     jnz    Success
  63.     mov    dh, bl
  64. Success:
  65.     endm
  66.  
  67. ;
  68. ; Macro to convert from XMS return value in DX
  69. ; a form more acceptable for C.  IE.
  70. ;
  71. ; AX != 0 becomes DX:AX = DX
  72. ; AX == 0 becomes DX:AX = BL << 24 | DX
  73. ;
  74. ; Since Error Codes returned in BL have the top bit
  75. ; set, C will interpret the return as negative.
  76. ; XMS returns of this type return BL == 0 on success.
  77. ;
  78. SuccessFailDX    macro
  79.     local    Success
  80.     or    ax, ax
  81.     mov    ax, dx
  82.     mov    dx, 0                ; Preserves Flags
  83.     jnz    Success
  84.     mov    dh, bl
  85. Success:
  86.     endm
  87.  
  88.  
  89. cProc    XMM_NotInitialised, <FAR>
  90. cBegin
  91.     xor    ax, ax                ; Immediate failure
  92.     mov    bl, 80h                ; Not Implemented
  93. cEnd
  94.  
  95. cProc    XMM_Installed, <NEAR, PUBLIC>, <si, di>
  96. cBegin
  97.     cmp    [XMM_Initialised], 0
  98.     jne    Already_Initialised
  99.     mov    ax, 4300h            ; Test for XMM
  100.     int    2fh
  101.     cmp    al, 80h
  102.     jne    NoDriver
  103.  
  104.     mov    ax, 4310h            ; Get Control Function
  105.     int    2fh
  106.     mov    word ptr [XMM_Control], bx
  107.     mov    word ptr [XMM_Control+2], es
  108.     inc    [XMM_Initialised]
  109. NoDriver:
  110. Already_Initialised:
  111.     mov    ax, [XMM_Initialised]
  112. cEnd
  113.  
  114.  
  115. cProc    XMM_Version, <NEAR, PUBLIC>, <si, di>
  116. cBegin
  117.     xor    ah, ah                ; Function 0
  118.     call    [XMM_Control]
  119.     mov    dx, bx                ; Return a long
  120. cEnd
  121.  
  122.  
  123. ;
  124. ;    long    XMM_RequestHMA(Space_Needed: unsigned short);
  125. ;
  126. cProc    XMM_RequestHMA, <NEAR, PUBLIC>, <si, di>
  127. parmW    Space_Needed
  128. cBegin
  129.     mov    ah, 1
  130.     mov    dx, Space_Needed
  131.     call    [XMM_Control]
  132.     SuccessFail
  133. cEnd
  134.  
  135. cProc    XMM_ReleaseHMA, <NEAR, PUBLIC>, <si, di>
  136. cBegin
  137.     mov    ah, 2
  138.     call    [XMM_Control]
  139.     SuccessFail
  140. cEnd
  141.  
  142. cProc    XMM_GlobalEnableA20, <NEAR, PUBLIC>, <si, di>
  143. cBegin
  144.     mov    ah, 3
  145.     call    [XMM_Control]
  146.     SuccessFail
  147. cEnd
  148.  
  149. cProc    XMM_GlobalDisableA20, <NEAR, PUBLIC>, <si, di>
  150. cBegin
  151.     mov    ah, 4
  152.     call    [XMM_Control]
  153.     SuccessFail
  154. cEnd
  155.  
  156. cProc    XMM_EnableA20, <NEAR, PUBLIC>, <si, di>
  157. cBegin
  158.     mov    ah, 5
  159.     call    [XMM_Control]
  160.     SuccessFail
  161. cEnd
  162.  
  163. cProc    XMM_DisableA20, <NEAR, PUBLIC>, <si, di>
  164. cBegin
  165.     mov    ah, 6
  166.     call    [XMM_Control]
  167.     SuccessFail
  168. cEnd
  169.  
  170. cProc    XMM_QueryA20, <NEAR, PUBLIC>, <si, di>
  171. cBegin
  172.     mov    ah, 7
  173.     call    [XMM_Control]
  174.     SuccessFailAX
  175. cEnd
  176.  
  177. cProc    XMM_QueryLargestFree, <NEAR, PUBLIC>, <si, di>
  178. cBegin
  179.     mov    ah, 8
  180.     call    [XMM_Control]
  181.     SuccessFailAX
  182. cEnd
  183.  
  184. cProc    XMM_QueryTotalFree, <NEAR, PUBLIC>, <si, di>
  185. cBegin
  186.     mov    ah, 8
  187.     call    [XMM_Control]
  188.     SuccessFailDX
  189. cEnd
  190.  
  191. cProc    XMM_AllocateExtended, <NEAR, PUBLIC>, <si, di>
  192. parmW    SizeK
  193. cBegin
  194.     mov    ah, 9
  195.     mov    dx, SizeK
  196.     call    [XMM_Control]
  197.     SuccessFailDX
  198. cEnd
  199.  
  200. cProc    XMM_FreeExtended, <NEAR, PUBLIC>, <si, di>
  201. parmW    Handle
  202. cBegin
  203.     mov    ah, 0Ah
  204.     mov    dx, Handle
  205.     call    [XMM_Control]
  206.     SuccessFail
  207. cEnd
  208.  
  209. cProc    XMM_MoveExtended, <NEAR, PUBLIC>, <si, di>
  210. parmW    pInfo
  211. cBegin
  212.     mov    ah, 0Bh
  213.     mov    si, pInfo            ; DS:SI => Description 
  214.     call    [XMM_Control]
  215.     SuccessFail
  216. cEnd
  217.  
  218. cProc    XMM_LockExtended, <NEAR, PUBLIC>, <si, di>
  219. parmW    Handle
  220. cBegin
  221.     mov    ah, 0Ch
  222.     mov    dx, Handle
  223.     call    [XMM_Control]
  224.     xchg    ax, bx
  225.     dec    bx
  226.     jz    XMML_Success
  227.     mov    dh, al
  228. XMML_Success:
  229. cEnd
  230.  
  231. cProc    XMM_UnLockExtended, <NEAR, PUBLIC>, <si, di>
  232. parmW    Handle
  233. cBegin
  234.     mov    ah, 0Dh
  235.     mov    dx, Handle
  236.     call    [XMM_Control]
  237.     SuccessFail
  238. cEnd
  239.  
  240. cProc    XMM_GetHandleLength, <NEAR, PUBLIC>, <si, di>
  241. parmW    Handle
  242. cBegin
  243.     mov    ah, 0Eh
  244.     mov    dx, Handle
  245.     call    [XMM_Control]
  246.     SuccessFailDX
  247. cEnd
  248.  
  249. cProc    XMM_GetHandleInfo, <NEAR, PUBLIC>, <si, di>
  250. parmW    Handle
  251. cBegin
  252.     mov    ah, 0Eh
  253.     mov    dx, Handle
  254.     call    [XMM_Control]
  255.     mov    dx, bx
  256.     SuccessFailDX
  257. cEnd
  258.  
  259. cProc    XMM_ReallocateExtended, <NEAR, PUBLIC>, <si, di>
  260. parmW    Handle
  261. parmW    NewSize
  262. cBegin
  263.     mov    ah, 0Fh
  264.     mov    dx, Handle
  265.     mov    bx, NewSize
  266.     call    [XMM_Control]
  267.     SuccessFail
  268. cEnd
  269.  
  270. cProc    XMM_RequestUMB, <NEAR, PUBLIC>, <si, di>
  271. parmW    UMBSize
  272. cBegin
  273.     mov    ah, 10h
  274.     mov    dx, UMBSize
  275.     call    [XMM_Control]
  276.     xchg    bx, ax            ; Segment in AX, Size in DX
  277.     dec    bx
  278.     jz    RUMB_Success
  279.     xchg    ax, dx            ; Largest available size in AX
  280.     mov    dh, dl            ; Error code now in DH
  281. RUMB_Success:
  282. cEnd
  283.  
  284. cProc    XMM_ReleaseUMB, <NEAR, PUBLIC>, <si, di>
  285. parmW    UMBSegment
  286. cBegin
  287.     mov    ah, 11h
  288.     mov    dx, UMBSegment
  289.     call    [XMM_Control]
  290.     SuccessFail
  291. cEnd
  292.  
  293. sEnd    Code
  294.  
  295. END
  296.