home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / SYSUTL / TSRWRK32.ZIP / MARK.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-06-06  |  5.5 KB  |  165 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:
  54.     jmp    doit
  55.  
  56. ;put the following in the MAP file
  57. public idstr,VECTOR,EGASAV,INTCOM,EMSCNT,EMSMAP
  58.  
  59. idstr    db  'M3.1 PARAMETER BLOCK FOLLOWS' ;used to find this TSR
  60.  
  61. ;**** the following will be overwritten by the vector table image ******
  62. ;success message and version number
  63. didit    db  13,10,'MARK 3.1 - Marked current memory position',13,10,36
  64. ;file name for testing EMS presence
  65. emsnm    db  'EMMXXXX0',0
  66. ;ID string
  67. id    db  ' M3.1 TSR'
  68. IDLEN    equ $-id
  69.  
  70. ;***********************************************************************
  71. VECTOR  equ 0120H    ;offset in code seg where vector table is copied
  72. VECLEN  equ 0400H        ;1024 bytes for vectors
  73. EGASAV  equ VECTOR+VECLEN
  74. EGALEN  equ 8            ;8 bytes for EGA save area
  75. INTCOM  equ EGASAV+EGALEN
  76. INTLEN  equ 10H            ;16 bytes for interapps communication area
  77. PARENT  equ INTCOM+INTLEN
  78. PARLEN  equ 2            ;2 bytes for parent's PSP
  79. EMSCNT  equ PARENT+PARLEN
  80. EMSMAP  equ EMSCNT+2
  81. NEWLOC  equ EMSMAP+100H     ;location of relocated code
  82. ;***********************************************************************
  83.  
  84. doit    proc    near
  85.  
  86. ;put a standard ID string into the PSP for ShowTSRs to check
  87.     mov    si,offset id
  88.     mov    di,60h        ;unused area of PSP
  89.     mov    cx,IDLEN    ;characters in ID string
  90.     cld
  91.     rep    movsb        ;copied
  92.     mov    di,NEWLOC    ;relocate ourselves out of the way
  93.     push    di        ;will act as a return address
  94.     mov    si,offset pmess
  95.     mov    cx,lastcode-pmess
  96.     rep    movsb
  97.     ret            ;"return" to the relocated code
  98.  
  99. pmess:  mov    dx,offset didit ;print message
  100.     mov    ah,9
  101.     int    21H        ;write success message
  102.     mov    dx,offset emsnm ;determine whether EMS is present
  103.     mov    ax,3D00H
  104.     int    21H
  105.     jnc    emspres        ;ems driver installed
  106.      xor    bx,bx        ; or zero active handles
  107.      jmp    short stocnt
  108.  
  109. emspres:
  110.     mov    bx,ax        ;close the open handle
  111.     mov    ah,3EH
  112.     int    21H
  113.     mov    ah,4DH        ;store the EMS page map
  114.     mov    di,EMSMAP
  115.     xor    bx,bx        ;required by some versions of EMM
  116.     cld            ;required by some versions of EMM
  117.     int    67H
  118.  
  119. stocnt: mov    di,EMSCNT    ;store the number of active handles
  120.     mov    [di],bx        ;count of active handles
  121.  
  122. ;store the interrupt vector table (overwrites initial messages)
  123.     xor    ax,ax
  124.     mov    DS,ax        ;source address segment 0
  125.     ASSUME    DS:NOTHING
  126.     xor    si,si        ;offset 0
  127.     mov    di,VECTOR    ;destination offset, es=cs already
  128.     mov    cx,VECLEN shr 1    ;count of words to store
  129.     rep    movsw        ;copy vectors to our table
  130.     mov    ax,40H        ;store the EGA save area
  131.     mov    DS,ax        ;point to BIOS data area
  132.     mov    si,00A8H    ;EGA save area pointer
  133.     mov    di,EGASAV
  134.     mov    cx,EGALEN shr 1
  135.     rep    movsw
  136.     mov    si,00F0H    ;store the interapplications
  137.     mov    di,INTCOM    ;communication area
  138.     mov    cx,INTLEN shr 1
  139.     rep    movsw
  140.     mov    ax,CS        ;store the parent's
  141.     mov    DS,ax        ;PSP segment
  142.     mov    ax,DS:[16h]    ;get parent's PSP from our PSP
  143.     mov    DS:[PARENT],ax  ;store in data save area
  144.     mov    ES,ES:[2Ch]    ;release environment
  145.     mov    ah,49h        ;release for
  146.     int    21h        ;DOS reuse
  147.  
  148. ;terminate and stay resident
  149.     mov    dx,EMSMAP    ;start at base of ems map
  150.     mov    di,EMSCNT
  151.     mov    bx,CS:[di]    ;count of active handles
  152.     shl    bx,1
  153.     shl    bx,1        ;multiply EMS handle count by 4
  154.     add    dx,bx
  155.     add    dx,000FH    ;round up for paragraphs
  156.     mov    cl,4
  157.     shr    dx,cl        ;convert to paragraphs
  158.     mov    ax,3100H
  159.     int    21H        ;terminate but stay resident
  160. lastcode:
  161. doit    endp
  162.  
  163. CSEG    ends
  164.     end    ComEntry
  165.