home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / beehive / zcat / rmacptch.asm < prev    next >
Assembly Source File  |  1994-07-13  |  4KB  |  97 lines

  1. ; RMACPTCH.ASM - 7/20/85
  2. ; Adapted by Bruce Morgen from Jay Sage's ingenious MACPATCH.ASM, this
  3. ; patch turns the RMAC assembler into a partial ZCPR3 utility.  When it
  4. ; runs, it automatically sets the program error flag in the message buffer
  5. ; to show whether or not RMAC encountered any errors in assembly.  The flow
  6. ; control command IF ERROR can then be used to control command flow.
  7. ;
  8. ; (NOTE: in the original distribution of SYSFCP.ASM there is an error that
  9. ; reverses the sensing of the program error flag.  You must either correct
  10. ; that error or use the reverse test IF ~ERROR.  The com file IF12.COM has
  11. ; the correct sensing {as does Jay's SYSFCP11.LBR package - b/m}.)
  12. ;
  13. ; BIG NOTE: The patched RMAC.COM must be installed by Z3INS.COM using a
  14. ; valid *.ENV file as a reference - neglect this and the patch will NOT
  15. ; work unless you are very lucky (your ENV load address would have to be
  16. ; DE00h).  The patch may be installed with MLOAD (version 2.1 or later)
  17. ; or a debugger like DDT, ZDM or SID.  I used MAC to assemble it, ASM
  18. ; would probably do in a pinch - b/m.
  19. ;
  20. ; Idea and all running code from MACPATCH.ASM by Jay Sage,
  21. ; sysop, Newton Centre (Massachusetts) Z-Node.
  22.  
  23. patch        equ    3024h        ;place to intercept RMAC
  24. conout        equ    2f78h        ;address called at patch originally
  25. newcode        equ    0150h        ;place to put new flag setting code
  26. rmcstart    equ    01a8h        ;where RMAC code really begins
  27. signon        equ    319ch        ;location of signon message
  28.  
  29. cr        equ    0dh
  30. lf        equ    0ah
  31.  
  32. ;-----------------------------------------------------------------------------
  33.  
  34. ; First we patch the beginning of the program to make it look like a ZCPR3
  35. ; utility program.  It can then be installed using Z3INS to know the address
  36. ; of the environment descriptor.  From that it can find the program error
  37. ; flag in the message buffer and patch it into the flag-setting code at
  38. ; at newcode.  The code patched in at 100h overwrites the copyright message.
  39.  
  40.         org    100h
  41.  
  42.         jmp    start
  43.  
  44.         db    'Z3ENV'
  45.         db    1        ;external environment
  46. z3env:        dw    0de00h        ;this address set by Z3INS
  47.  
  48. start:        lhld    z3env        ;get env address into hl
  49.         lxi    d,22h        ;offset to message buffer address
  50.         dad    d        ;hl points to address of message buf
  51.         mov    a,m        ;read address out
  52.         inx    h
  53.         mov    h,m
  54.         mov    l,a        ;hl now points to start of message buf
  55.         lxi    d,6        ;offset to program error flag
  56.         dad    d        ;now hl points to program error flag
  57.         mvi    m,0        ;set it to no error status
  58.         shld    store+1        ;patch flag-setting code below
  59.         jmp    rmcstart    ;continue with original code
  60.  
  61. ;-----------------------------------------------------------------------------
  62.  
  63. ; We intercept RMAC execution at address PATCH.  The original instruction here
  64. ; was CALL CONOUT.  We replace it with a call to our new code, which in turn
  65. ; will jump to conout.
  66.  
  67.         org    patch
  68.  
  69.         call    newcode
  70.  
  71. ;-----------------------------------------------------------------------------
  72.  
  73. ; At NEWCODE, which is within a PIP-style patching area near the start
  74. ; of RMAC, we place the code to set the error flag.  This address is
  75. ; compatible with the George Blat and Sigi Kluger RMAC patches.
  76.  
  77.         org    newcode
  78.  
  79.         push    psw        ;make sure we don't mess anything up
  80.         mvi    a,0ffh        ;value to set the flag
  81. store:        sta    0        ;address will be filled in by code
  82.         pop    psw        ;restore registers
  83.         jmp    conout        ;go to where RMAC went originally
  84.  
  85. ;-----------------------------------------------------------------------------
  86.  
  87. ; Just for the hell of it, patch the signon message to show it is a ZCPR3
  88. ; version.  Eighteen characters max, not including final mandatory carriage
  89. ; return.
  90.  
  91.         org    signon
  92.  
  93.         db    lf
  94.         db    'Z3 REL/MACRO ASSEM',cr
  95.  
  96.         end
  97. ters max, not includi