home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / PASCAL / TSRUTILS.ZIP / MARK.ASM < prev    next >
Assembly Source File  |  1989-05-04  |  7KB  |  179 lines

  1. ;==============================================================================
  2. ; MARK.ASM - mark a position in memory,
  3. ;            above which TSRs will later be cleared by RELEASE.COM
  4. ;            MARK can be called multiple times, each RELEASE will clear
  5. ;            above the last MARK called.
  6. ; If MARK is called with something on the command line, that text will
  7. ; be stored in the program segment prefix at offset 80H, where it is
  8. ; later accessible to RELEASE for a "named" release.
  9. ;==============================================================================
  10. ; written for MASM (version 4 or later) or TASM
  11. ; by Kim Kokkonen, TurboPower Software
  12. ; telephone: 408-438-8608, Compuserve 72457,2131
  13. ;==============================================================================
  14. ; VERSION 1.4  2/23/86
  15. ;   This version also stores the EMS page map so that RELEASE can release
  16. ;   READY! and any future resident programs using expanded memory
  17. ; VERSION 1.5  2/28/86
  18. ;   to keep consistent with MAPMEM and RELEASE
  19. ; VERSION 1.6  3/8/86
  20. ;   store all 256 interrupts, but only 32 EMS blocks
  21. ; VERSION 1.7  4/1/86
  22. ;   close the EMS handle opened to avoid using up a DOS handle
  23. ; VERSION 1.8  4/20/86
  24. ;   to keep consistent with MAPMEM and RELEASE
  25. ; VERSION 1.9  5/22/86
  26. ;   to keep consistent with MAPMEM and RELEASE
  27. ; VERSION 2.0  5/26/86
  28. ;   to keep consistent with MAPMEM and RELEASE
  29. ; VERSION 2.1  7/18/86
  30. ;   to keep consistent with RELEASE
  31. ; VERSION 2.2  3/4/87
  32. ;   add save area for BIOS data areas
  33. ;     40:A8 (8 bytes for EGA)
  34. ;     40:F0 (16 bytes for interapplications communications)
  35. ; VERSION 2.3  5/1/87
  36. ;   convert to use MASM
  37. ;   chop off unused portion of EMS page map when going resident
  38. ;   modify so that the data areas are not part of the COM file
  39. ; VERSION 2.4  5/17/87
  40. ;   for consistency with RELEASE
  41. ; VERSION 2.5  6/2/87
  42. ;   add version checking between MARK and RELEASE
  43. ; VERSION 2.6  1/15/89
  44. ;   fix problem occurring when command processor is an EXE file,
  45. ;     by storing parent's PSP segment as part of MARK save area
  46. ;     (thanks to Tom Rawson for this code)
  47. ; VERSION 2.7
  48. ;   skipped
  49. ; VERSION 2.8
  50. ;   for consistency with MARKNET/RELNET
  51. ; VERSION 2.9
  52. ;   for consistency with MARKNET/RELNET
  53. ;==============================================================================
  54.  
  55. Cseg      segment public para
  56.           assume  cs:Cseg, ds:Cseg, es:nothing
  57.  
  58.           org     100H
  59. comentry: jmp     doit
  60.  
  61. ;put the following in the MAP file
  62. public idstr,vector,egasav,intcom,emscnt,emsmap
  63.  
  64. idstr  db      'M2.9 PARAMETER BLOCK FOLLOWS' ;used to find this TSR
  65.  
  66. ;**** the following will be overwritten by the vector table image *************
  67. ;success message and version number
  68. didit  db      'MARK 2.9 - Marked current memory position',13,10,36
  69. ;file name for testing EMS presence
  70. emsnm  db      'EMMXXXX0',0
  71. ;******************************************************************************
  72.  
  73. vector equ     0120H           ;offset in code seg where vector table is copied
  74. veclen equ     0400H           ;1024 bytes for vectors
  75. egasav equ     vector+veclen
  76. egalen equ     8               ;8 bytes for EGA save area
  77. intcom equ     egasav+egalen
  78. intlen equ     10H             ;16 bytes for interapps communication area
  79. parent equ     intcom+intlen
  80. parlen equ     2               ;2 bytes for parent's PSP
  81. emscnt equ     parent+parlen
  82. emsmap equ     emscnt+2
  83.  
  84. newloc equ     emsmap+100H     ;location of relocated code
  85.  
  86. ;*****************************************************************************
  87.  
  88. doit   proc    near
  89.  
  90. ;relocate ourselves out of the way
  91.        mov     di,newloc
  92.        push    di                    ;will act as a return address
  93.        mov     si,offset pmess
  94.        mov     cx,lastcode-pmess
  95.        cld
  96.        rep     movsb
  97.        ret                          ;"return" to the relocated code
  98.  
  99. ;print message
  100. pmess:
  101.        mov     dx,offset didit
  102.        mov     ah,9
  103.        int     21H             ;write success message
  104.  
  105. ;determine whether EMS is present
  106.        mov     dx,offset emsnm
  107.        mov     ax,3D00H
  108.        int     21H
  109.        jnc     emspres           ;ems driver installed
  110.        xor     bx,bx
  111.        jmp     short stocnt
  112.  
  113. ;EMS present, close the open handle first
  114. emspres:
  115.        mov     bx,ax
  116.        mov     ah,3EH
  117.        int     21H
  118.  
  119. ;store the EMS page map
  120.        mov     ah,4DH
  121.        mov     di,emsmap
  122.        xor     bx,bx           ;required by some versions of EMM
  123.        cld                     ;required by some versions of EMM
  124.        int     67H
  125.  
  126. ;store the number of active handles
  127. stocnt:
  128.        mov     di,emscnt
  129.        mov     [di],bx          ;count of active handles
  130.  
  131. ;store the interrupt vector table (overwrites initial messages)
  132.        xor     ax,ax
  133.        mov     ds,ax            ;source address segment 0
  134.        assume  ds:nothing
  135.        xor     si,si            ;offset 0
  136.        mov     di,vector        ;destination offset, es=cs already
  137.        mov     cx,veclen shr 1  ;count of words to store
  138.        rep     movsw            ;copy vectors to our table
  139.  
  140. ;store the EGA save area
  141.        mov     ax,40H
  142.        mov     ds,ax            ;point to BIOS data area
  143.        mov     si,00A8H         ;EGA save area pointer
  144.        mov     di,egasav
  145.        mov     cx,egalen shr 1
  146.        rep     movsw            ;copy information to our save area
  147.  
  148. ;store the interapplications communication area
  149.        mov     si,00F0H         ;interapps communication area address
  150.        mov     di,intcom
  151.        mov     cx,intlen shr 1
  152.        rep     movsw            ;copy information to our save area
  153.  
  154. ;store the parent's PSP segment
  155.        mov     ax,cs           ;CS = PSP
  156.        mov     ds,ax           ;now DS = PSP
  157.        mov     ax,ds:[16h]     ;get parent's PSP from our PSP
  158.        mov     ds:[parent],ax  ;store in data save area
  159.  
  160. ;terminate and stay resident
  161. gores:
  162.        mov     dx,emsmap       ;start at base of ems map
  163.        mov     di,emscnt
  164.        mov     bx,cs:[di]      ;count of active handles
  165.        shl     bx,1
  166.        shl     bx,1            ;multiply EMS handle count by 4
  167.        add     dx,bx
  168.        add     dx,000FH        ;round up for paragraphs
  169.        mov     cl,4
  170.        shr     dx,cl           ;convert to paragraphs
  171.        mov     ax,3100H
  172.        int     21H             ;terminate but stay resident
  173.  
  174. lastcode:
  175. doit    endp
  176.  
  177. Cseg    ends
  178.         end     ComEntry
  179.