home *** CD-ROM | disk | FTP | other *** search
/ Software Collection (I) / TOOLS.iso / b05 / 6.img / PSCRIPT / ADRSCVT.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-03-11  |  4.9 KB  |  189 lines

  1.  
  2. ;  This file was taken from LP7000 direct wife driver and modefied.
  3.  
  4. ;/*********************************************************************
  5. ;* Module Name: adrscvt.asm
  6. ;*
  7. ;* address conversion to handle huge bitmaps
  8. ;*
  9. ;* Created: Dec.1,1990
  10. ;* Author: Akirak
  11. ;*
  12. ;* Copyright (c) 1990  Microsoft Corporation
  13. ;*
  14. ;*   ( This module was created by MSKK )
  15. ;*
  16. ;*********************************************************************/
  17.  
  18.                 title   adrscvt.asm
  19.  
  20. .xlist
  21. include cmacros.inc
  22. .list
  23.  
  24. createSeg   _ADRSCVT,ADRSCVT,byte,public,CODE
  25.  
  26. sBegin  DATA
  27.  
  28. sEnd    DATA
  29.  
  30. sBegin  ADRSCVT
  31.  
  32. assumes CS,ADRSCVT
  33. assumes DS,DATA
  34.  
  35. externA         __WinFlags
  36.  
  37.  
  38. WINP    equ     00037001b               ;protected mode
  39.  
  40. DPMI_ALLOC_LDT  equ     0000h
  41. DPMI_FREE_LDT   equ     0001h
  42. DPMI_GET_BASE_ADDR      equ     0006h
  43. DPMI_SET_BASE_ADDR      equ     0007h
  44. DPMI_SET_LIMIT          equ     0008h
  45. DPMI_GET_DESCRIPTER     equ     000bh
  46. DPMI_SET_DESCRIPTER     equ     000ch
  47.  
  48. DPMI    macro   func
  49.         mov     ax,func
  50.         int     31h
  51.         endm
  52.  
  53. cProc CreateDirectAlias,<PUBLIC,FAR>,<si,di,ds>
  54.                 ParmD   src
  55.                 ParmD   offsett
  56.                 ParmD   LimitSize
  57.                 localW  AllocedSelector
  58.                 localV  Descripter,8
  59. cBegin
  60.                 mov     ax,__WinFlags
  61.                 and     ax,WINP
  62.                 jz      REAL_MODE
  63.  
  64. PROTECT_MODE:
  65.  
  66.                 ;allocate one selector
  67.                 mov     cx,1            ;allocate one selector
  68.                 DPMI    DPMI_ALLOC_LDT
  69.                 jc      errexit
  70.                 mov     AllocedSelector,ax
  71.  
  72.                 ;get descripter from original selector
  73.                 mov     bx,word ptr src.2
  74.                 lea     di,Descripter
  75.                 push    ss
  76.                 pop     es
  77.                 DPMI    DPMI_GET_DESCRIPTER
  78.                 jc      free_and_errexit
  79.  
  80.                 ;set decripter to allocated selector
  81.                 mov     bx,AllocedSelector
  82.                 DPMI    DPMI_SET_DESCRIPTER
  83.                 jc      free_and_errexit
  84.  
  85.                 ;get base address of src, returned in CX:DX
  86.                 mov     bx,word ptr src.2
  87.                 DPMI    DPMI_GET_BASE_ADDR
  88.                 jc      free_and_errexit
  89.  
  90.                 ;to get actual address point, add offsets
  91.                 add     dx,word ptr src.0
  92.                 adc     cx,0
  93.                 add     dx,word ptr offsett.0
  94.                 adc     cx,word ptr offsett.2
  95.  
  96.                 ;set base address of dest
  97.                 mov     bx,AllocedSelector
  98.                 DPMI    DPMI_SET_BASE_ADDR
  99.                 jc      free_and_errexit
  100.  
  101.                 ;set limit size
  102.                 mov     bx,AllocedSelector
  103.                 mov     cx,word ptr LimitSize.2
  104.                 mov     dx,word ptr LimitSize.0
  105.  
  106. ;ifdef ?
  107.                 ;IS IT REQUIRED?
  108.                 ;I CAN'T RECOGNIZE 8.8 SEC. OF DPMI SPECIFICATION 0.9
  109.                 ;                                     Dec.1,1990 AkiraK
  110.                 or      dx,0000111111111111b
  111. ;endif
  112.  
  113.                 DPMI    DPMI_SET_LIMIT
  114.                 jc      free_and_errexit
  115.  
  116.                 mov     dx,AllocedSelector
  117.                 xor     ax,ax
  118.  
  119.                 jmp     exit_create
  120.  
  121. free_and_errexit:
  122.                 ;free allocated selector
  123.                 mov     bx,AllocedSelector
  124.                 DPMI    DPMI_FREE_LDT
  125.  
  126. errexit:
  127.                 xor     ax,ax
  128.                 mov     dx,ax
  129.                 jmp     exit_create
  130.  
  131. REAL_MODE:
  132.                 ;get liner address
  133.                 mov     ax,word ptr src.2
  134.                 mov     dx,ax
  135.                 mov     cl,4
  136.                 shl     ax,cl
  137.                 mov     cl,12
  138.                 shr     dx,cl
  139.                 add     ax,word ptr src.0
  140.                 adc     dx,0
  141.  
  142.                 ;add offset
  143.                 add     ax,word ptr offsett.0
  144.                 adc     dx,word ptr offsett.2
  145.  
  146.                 ;convert into segment:offset address
  147.                 ;NORMALIZED VALUE
  148.  
  149.                 mov     cl,12
  150.                 shl     dx,cl
  151.  
  152.                 mov     bx,ax
  153.                 mov     cl,4
  154.                 shr     bx,cl
  155.                 add     dx,bx
  156.  
  157.                 and     ax,0003700003701111b
  158.  
  159.                 ;jmp    exit_create
  160.  
  161. exit_create:
  162.  
  163. cEnd
  164.  
  165.  
  166. cProc DeleteDirectAlias,<PUBLIC,FAR>,<si,di,ds>
  167.                 ParmD   free_ptr
  168. cBegin
  169.                 mov     ax,__WinFlags
  170.                 and     ax,WINP
  171.                 jz      exit_delete
  172.  
  173.                 ;if protect mode, free selector and return
  174.  
  175.                 ;free allocated selector
  176.                 mov     bx,word ptr free_ptr.2
  177.                 DPMI    DPMI_FREE_LDT
  178.                 ;no check return value
  179.  
  180. exit_delete:
  181.                 xor     ax,ax
  182.  
  183. cEnd
  184.  
  185.  
  186. sEnd    ADRSCVT
  187.  
  188. end
  189.