home *** CD-ROM | disk | FTP | other *** search
/ Internet MPEG Audio Archive / IMAA.mdf / util / dos / l3v100n / rsx / source / dpmi10.asm < prev    next >
Assembly Source File  |  1994-01-19  |  8KB  |  456 lines

  1. ;
  2. ; DPMI10.ASM (c) Rainer Schnitker  '93
  3. ;
  4.  
  5. ;
  6. ; 16bit library for DPMI 0.9 calls
  7. ;
  8. ; define 'HAVE386' to use 32bit DPMI mode
  9. ;
  10.  
  11.     .286
  12.         .model SMALL, C
  13.  
  14. ; macro to call dpmi in ax
  15. ;
  16. DPMI MACRO function
  17.         mov ax,function
  18.         int 31h
  19.         ENDM
  20.  
  21. getdword MACRO high,low,address
  22.         mov low,word ptr address
  23.         mov high,word ptr address.2
  24.     ENDM
  25.  
  26. setdword MACRO address,high,low
  27.         mov word ptr address,low
  28.         mov word ptr address.2,high
  29.     ENDM
  30.  
  31.  
  32.         .data
  33.  
  34.         .code
  35.  
  36.    ;    
  37.    ;    int GetMultipleDescriptors(WORD anzahl,WORD *buffer)
  38.    ;    
  39.     public    C GetMultipleDescriptors
  40. GetMultipleDescriptors PROC C \
  41.         anzahl  :WORD, \
  42.     buffer    :PTR
  43.  
  44.         mov     cx, anzahl
  45.     push    ds
  46.     pop    es
  47. ifdef HAVE386
  48.     .386
  49.     movzx    edi, word ptr buffer
  50.         .286
  51. else
  52.     mov    di, word ptr buffer
  53. endif
  54.     DPMI 000Eh
  55.     jc    short @@end
  56.     xor    ax,ax
  57. @@end:
  58.     ret    
  59. GetMultipleDescriptors endp
  60.  
  61.    ;    
  62.    ;    int SetMultipleDescriptors(WORD anzahl,WORD *buffer)
  63.    ;    
  64.     public    C SetMultipleDescriptors
  65. SetMultipleDescriptors PROC C \
  66.         anzahl  :WORD, \
  67.     buffer    :PTR
  68.  
  69.         mov     cx, anzahl
  70.     push    ds
  71.     pop    es
  72. ifdef HAVE386
  73.     .386
  74.     movzx    edi, word ptr buffer
  75.         .286
  76. else
  77.     mov    di, word ptr buffer
  78. endif
  79.     DPMI 000Fh
  80.     jc    short @@end
  81.     xor    ax,ax
  82. @@end:
  83.     ret    
  84. SetMultipleDescriptors endp
  85.  
  86.    ;
  87.    ;    int GetProtModeExceptionVector32(BYTE no,WORD *sel,DWORD *off)
  88.    ;    
  89.     public    C GetProtModeExceptionVector32
  90. GetProtModeExceptionVector32 PROC C \
  91.         no      :BYTE , \
  92.         segm    :PTR , \
  93.         offs    :PTR
  94.  
  95.     mov    bl,no
  96.         DPMI 0211h
  97.     jc    short @@end
  98.  
  99.     mov    bx,segm
  100.     mov    word ptr [bx],cx
  101.     mov    bx,offs
  102.     mov    word ptr [bx],dx
  103.     .386
  104.         shr     edx,16
  105.     .286
  106.     mov    word ptr [bx].2,dx
  107.  
  108.     xor    ax,ax
  109. @@end:
  110.     ret    
  111. GetProtModeExceptionVector32   endp
  112.  
  113.    ;
  114.    ;    int GetRealModeExceptionVector32(BYTE no,WORD *sel,DWORD *off)
  115.    ;    
  116.     public    C GetRealModeExceptionVector32
  117. GetRealModeExceptionVector32 PROC C \
  118.         no      :BYTE , \
  119.         segm    :PTR , \
  120.         offs    :PTR
  121.  
  122.     mov    bl,no
  123.         DPMI 0212h
  124.     jc    short @@end
  125.  
  126.     mov    bx,segm
  127.     mov    word ptr [bx],cx
  128.     mov    bx,offs
  129.     mov    word ptr [bx],dx
  130.     .386
  131.         shr     edx,16
  132.     .286
  133.     mov    word ptr [bx].2,dx
  134.         xor     ax,ax
  135. @@end:
  136.     ret    
  137. GetRealModeExceptionVector32   endp
  138.  
  139.    ;
  140.    ;    int SetProtModeExceptionVector32(BYTE b,WORD sel,DWORD off)
  141.    ;    
  142.     public    C SetProtModeExceptionVector32
  143. SetProtModeExceptionVector32 PROC C \
  144.         b       :BYTE , \
  145.         segm    :WORD , \
  146.     offs    :DWORD
  147.  
  148.     mov    bl,b
  149.     mov    cx,segm
  150.     .386
  151.     mov    edx,offs
  152.     .286
  153.         DPMI 0213h
  154.     jc    short @@end
  155.  
  156.     xor    ax,ax
  157. @@end:
  158.     .386
  159.     xor    edx,edx
  160.     .286
  161.     ret    
  162. SetProtModeExceptionVector32   endp
  163.  
  164.    ;
  165.    ;    int SetRealModeExceptionVector32(BYTE b,WORD sel,DWORD off)
  166.    ;    
  167.     public    C SetRealModeExceptionVector32
  168. SetRealModeExceptionVector32 PROC C \
  169.         b       :BYTE , \
  170.         segm    :WORD , \
  171.     offs    :DWORD
  172.  
  173.     mov    bl,b
  174.     mov    cx,segm
  175.     .386
  176.     mov    edx,offs
  177.     .286
  178.         DPMI 0213h
  179.     jc    short @@end
  180.  
  181.     xor    ax,ax
  182. @@end:
  183.     .386
  184.     xor    edx,edx
  185.     .286
  186.     ret    
  187. SetRealModeExceptionVector32   endp
  188.  
  189.  
  190.    ;
  191.    ;    void GetDPMICapabilities(DPMICAP *v,BYTE *buffer)
  192.    ;    
  193.         public  C GetDPMICapabilities
  194. GetDPMICapabilities PROC C USES SI, \
  195.         cap     :PTR, \
  196.         buffer  :PTR
  197.  
  198.     push    ds
  199.     pop    es
  200. ifdef HAVE386
  201.     .386
  202.     movzx    edi, word ptr buffer
  203.         .286
  204. else
  205.     mov    di, word ptr buffer
  206. endif
  207.         DPMI 0401h
  208.     jc    short @@end
  209.     mov    bx, word ptr cap
  210.         mov     word ptr [bx  ],ax
  211.         mov     word ptr [bx+2],cx
  212.     mov    word ptr [bx+4],dx
  213.     xor    ax,ax
  214. @@end:
  215.         ret
  216. GetDPMICapabilities endp
  217.  
  218.  
  219. ifdef HAVE386
  220.    ;    
  221.    ;    int AllocLinearMemory(DWORD bytes,DWORD linaddress,DWORD flags,
  222.    ;                          DWORD *handle,DWORD *memaddress)
  223.    ;    
  224.         public  C AllocLinearMemory
  225. AllocLinearMemory PROC C \
  226.         nbytes  :DWORD , \
  227.         linaddr :DWORD , \
  228.         flags   :DWORD , \
  229.     handle    :PTR , \
  230.     memadr    :PTR
  231.  
  232.     .386
  233.     push    esi
  234.     push    ebx
  235.     mov    ecx, nbytes
  236.         mov     ebx, linaddr
  237.         mov     edx, flags
  238.     DPMI 0504h
  239.     jc    short @@end
  240.  
  241.         movzx   edx, word ptr handle
  242.     mov    dword ptr [edx], esi
  243.         movzx   edx, word ptr memadr
  244.     mov    dword ptr [edx], ebx
  245.     xor    ax, ax
  246. @@end:
  247.         xor     ecx, ecx
  248.     xor    edx, edx
  249.     pop    ebx
  250.     pop    esi
  251.         .286
  252.  
  253.         ret
  254. AllocLinearMemory  endp
  255.  
  256.    ;
  257.    ;    int ResizeLinearMemory(DWORD bytes,DWORD handle,DWORD flags
  258.    ;                  DWORD *newhandle,DWORD *newmemaddress)
  259.    ;    
  260.     public    C ResizeLinearMemory
  261. ResizeLinearMemory PROC C \
  262.         nbytes  :DWORD , \
  263.     handle    :DWORD , \
  264.         flags   :DWORD , \
  265.     new_handle:PTR , \
  266.     new_memadr:PTR
  267.  
  268.     .386
  269.     push    esi
  270.     push    ebx
  271.         mov     esi, handle
  272.     mov    ecx, nbytes
  273.     DPMI 0505h
  274.     jc    short @@end
  275.  
  276.     movzx    edx, word ptr new_handle
  277.     mov    dword ptr [edx], esi
  278.     movzx    edx, word ptr new_memadr
  279.     mov    dword ptr [edx], ebx
  280.     xor    ax, ax
  281. @@end:
  282.         xor     ecx, ecx
  283.     pop    ebx
  284.     pop    esi
  285.         .286
  286.  
  287.         ret
  288. ResizeLinearMemory  endp
  289.  
  290.    ;
  291.    ;    int GetPageAttibutes(DWORD handle,DWORD offs,DWORD bytes,WORD **attr)
  292.    ;    
  293.     public    C GetPageAttibutes
  294. GetPageAttibutes PROC C \
  295.     handle    :DWORD , \
  296.     offs    :DWORD , \
  297.     nbytes    :DWORD , \
  298.     attr    :PTR
  299.  
  300.     .386
  301.     push    esi
  302.     push    ebx
  303.     push    ds
  304.     pop    es
  305.         mov     esi, handle
  306.     mov    ebx, offs
  307.     mov    ecx, nbytes
  308.     movzx    edx, attr
  309.     DPMI 0506h
  310.     jc    short @@end
  311.  
  312.     xor    ax, ax
  313. @@end:
  314.         xor     ecx, ecx
  315.     xor    edx, edx
  316.     pop    ebx
  317.     pop    esi
  318.         .286
  319.  
  320.         ret
  321. GetPageAttibutes  endp
  322.  
  323.    ;
  324.    ;    int ModifyPageAttibutes(DWORD handle,DWORD offs,DWORD bytes,WORD **attr)
  325.    ;
  326.     public    C ModifyPageAttibutes
  327. ModifyPageAttibutes PROC C \
  328.     handle    :DWORD , \
  329.     offs    :DWORD , \
  330.     npages    :DWORD , \
  331.     attr    :PTR
  332.  
  333.     .386
  334.     push    esi
  335.     push    ebx
  336.     push    ds
  337.     pop    es
  338.         mov     esi, handle
  339.     mov    ebx, offs
  340.     mov    ecx, npages
  341.     movzx    edx, word ptr attr
  342.     DPMI 0507h
  343.     jc    short @@end
  344.  
  345.     xor    ax, ax
  346. @@end:
  347.         xor     ecx, ecx
  348.     xor    edx, edx
  349.     pop    ebx
  350.     pop    esi
  351.         .286
  352.  
  353.         ret
  354. ModifyPageAttibutes  endp
  355.  
  356.    ;
  357.    ;    int MapDeviceInMemoryBlock(DWORD handle,DWORD offs,
  358.    ;                   DWORD bytes,DWORD device)
  359.    ;
  360.     public    C MapDeviceInMemoryBlock
  361. MapDeviceInMemoryBlock PROC C \
  362.     handle    :DWORD , \
  363.     offs    :DWORD , \
  364.     nbytes    :DWORD , \
  365.     device    :PTR
  366.  
  367.     .386
  368.     push    esi
  369.     push    ebx
  370.         mov     esi, handle
  371.     mov    ebx, offs
  372.     mov    ecx, nbytes
  373.     movzx    edx, device
  374.     DPMI 0507h
  375.     jc    short @@end
  376.  
  377.     xor    ax, ax
  378. @@end:
  379.         xor     ecx, ecx
  380.     xor    edx, edx
  381.     pop    ebx
  382.     pop    esi
  383.         .286
  384.  
  385.         ret
  386. MapDeviceInMemoryBlock    endp
  387.  
  388. endif   ;HAVE386
  389.  
  390.    ;
  391.    ;    int GetMemoryBlockData(DWORD handle,DWORD *addr,DWORD *bytes)
  392.    ;
  393.     public    C GetMemoryBlockData
  394. GetMemoryBlockData PROC C USES DI SI, \
  395.     handle    :DWORD , \
  396.     addr    :PTR , \
  397.     bytes    :PTR
  398.  
  399.     getdword si,di,handle
  400.     DPMI 050Ah
  401.     jc    short @@end
  402.     mov    bx, addr
  403.     setdword [bx],bx,dx
  404.     mov    bx, bytes
  405.     setdword [bx],si,di
  406.     xor    ax, ax
  407. @@end:
  408.  
  409.         ret
  410. GetMemoryBlockData  endp
  411.  
  412.    ;
  413.    ;    int GetMemoryInfo(INFO *info)
  414.    ;
  415.     public    C GetMemoryInfo
  416. GetMemoryInfo PROC C USES DI SI, \
  417.     info    :PTR
  418.  
  419.     push    ds
  420.     pop    es
  421. ifdef HAVE386
  422.     .386
  423.     movzx    edi, info
  424.     .386
  425. else
  426.     mov    di, info
  427. endif
  428.     DPMI 050Bh
  429.     jc    short @@end
  430.  
  431.     xor    ax, ax
  432. @@end:
  433.  
  434.         ret
  435. GetMemoryInfo  endp
  436.  
  437.    ;
  438.    ;    int FreePhysicalMapping(DWORD address)
  439.    ;
  440.     public    C FreePhysicalMapping
  441. FreePhysicalMapping PROC C USES DI SI, \
  442.     address :DWORD
  443.  
  444.     getdword bx,cx,address
  445.     DPMI 0801h
  446.     jc    short @@end
  447.  
  448.     xor    ax, ax
  449. @@end:
  450.  
  451.         ret
  452. FreePhysicalMapping  endp
  453.  
  454.  
  455.     end
  456.