home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / BEEHIVE / ZCAT / MACPATCH.ASM < prev    next >
Assembly Source File  |  2000-06-30  |  3KB  |  87 lines

  1. ; This patch turns the MAC assembler into a partial ZCPR3 utility.  When it
  2. ; runs, it automatically sets the program error flag in the message buffer
  3. ; to show whether or not MAC encountered any errors in assembly.  The flow
  4. ; control command IF ERROR can then be used to control command flow.
  5. ;
  6. ; (NOTE: int the original distribution of SYSFCP.ASM there is an error that
  7. ; reverses the sensing of the program error flag.  You must either correct
  8. ; that error or use the reverse test IF ~ERROR.  The com file IF12.COM has
  9. ; the correct sensing.)
  10. ;
  11. ; Jay Sage, sysop, Newton Centre (Massachusetts) Z-Node
  12. ; July 8, 1985
  13.  
  14. patch        equ    2b70h        ;place to intercept MAC
  15. conout        equ    2ac9h        ;address called at patch originally
  16. newcode        equ    2e70h        ;place to put new flag setting code
  17. macstart    equ    0128h        ;where MAC code really begins
  18. signon        equ    2cd3h        ;loacation of signon message
  19.  
  20. cr        equ    0dh
  21. lf        equ    0ah
  22.  
  23. ;-----------------------------------------------------------------------------
  24.  
  25. ; First we patch the beginning of the program to make it look like a ZCPR3
  26. ; utility program.  It can then be installed using Z3INS to know the address
  27. ; of the environment descriptor.  From that it can find the program error
  28. ; flag in the message buffer and patch it into the flag-setting code at
  29. ; at newcode.  The code patched in at 100h overwrites the copyright message.
  30.  
  31.         org    100h
  32.  
  33.         jmp    start
  34.  
  35.         db    'Z3ENV'
  36.         db    1        ;external environment
  37. z3env:        dw    0de00h        ;this address set by Z3INS
  38.  
  39. start:        lhld    z3env        ;get env address into hl
  40.         lxi    d,22h        ;offset to message buffer address
  41.         dad    d        ;hl points to address of message buf
  42.         mov    a,m        ;read address out
  43.         inx    h
  44.         mov    h,m
  45.         mov    l,a        ;hl now points to start of message buf
  46.         lxi    d,6        ;offset to program error flag
  47.         dad    d        ;now hl points to program error flag
  48.         mvi    m,0        ;set it to no error status
  49.         shld    store+1        ;patch flag-setting code below
  50.         jmp    macstart    ;continue with original code
  51.  
  52. ;-----------------------------------------------------------------------------
  53.  
  54. ; We intercept MAC execution at address PATCH.  The original instruction here
  55. ; was CALL CONOUT.  We replace it with a call to our new code, which in turn
  56. ; will jump to conout.
  57.  
  58.         org    patch
  59.  
  60.         call    newcode
  61.  
  62. ;-----------------------------------------------------------------------------
  63.  
  64. ; At NEWCODE, which appears to be some extra space at the end of MAC, we
  65. ; place the code to set the error flag.
  66.  
  67.         org    newcode
  68.  
  69.         push    psw        ;make sure we don't mess anything up
  70.         mvi    a,0ffh        ;value to set the flag
  71. store:        sta    0        ;address will be filled in by code
  72.         pop    psw        ;restore registers
  73.         jmp    conout        ;go to where MAC went originally
  74.  
  75. ;-----------------------------------------------------------------------------
  76.  
  77. ; Just for the hell of it, patch the signon message to show it is a ZCPR3
  78. ; version.  Twenty characters max, not including final mandatory carriage
  79. ; return.
  80.  
  81.         org    signon
  82.  
  83.         db    lf
  84.         db    'Z3 MACRO ASSEMBLER',cr
  85.  
  86.         end
  87.