home *** CD-ROM | disk | FTP | other *** search
/ TopWare Tools / TOOLS.iso / tools / top1190 / mark.asm < prev    next >
Encoding:
Assembly Source File  |  1989-05-31  |  6.5 KB  |  162 lines

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