home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / p / patch-go.lbr / P&G10.AZM / P&G10.ASM
Encoding:
Assembly Source File  |  1993-10-25  |  15.0 KB  |  653 lines

  1. ;      -=[ PATCH&GO - Load Program, Patch It, and Execute ]=-
  2. ;
  3. ; USAGE:  PATCH&GO c:comfile d:patfile
  4. ;
  5. ; where:  c:comfile =     name of program to be loaded, patched, and
  6. ;            executed (c: specifies the drive where the
  7. ;            program will be found when it is loaded and
  8. ;            defaults to the drive currently selected at
  9. ;
  10. ;      d:patfile =    name of program that will load, patch, and
  11. ;            execute "comfile" (d: specifies the drive
  12. ;            where the "patfile" is saved and defaults
  13. ;            to the currently selected drive)
  14. ;
  15. ; Both filenames are required and can not contain wildcards.  The
  16. ; COM file type is implied on both files.
  17. ;
  18. ; IMPLEMENTATION NOTES:
  19. ;
  20. ; Equate DEFDRV controls whether or not the "comfile" will be loaded
  21. ; from drive A: if it is not found on the currently selected drive
  22. ; and the drive was not specified explicitly.
  23. ;
  24. ; REVISION HISTORY:
  25. ;
  26. ; v1.0    Original version coded entirely in 8080 mnemonics for CP/M
  27. ;    2.2 systems.  (J.D. Osnes, 7/17/86)
  28. ;
  29. ; COPYRIGHT:
  30. ;
  31. ;    PATCH&GO may be copied and distributed freely at no cost for
  32. ;    the benefit and enjoyment of all registered CP/M users.  It
  33. ;    may not be sold or included in a package for sale without
  34. ;    prior written permission of the copyright owner:
  35. ;
  36. ;        Copyright (c) 1986 by    John D. Osnes
  37. ;                    1084 6th Street #41
  38. ;                    Albany, CA   94710
  39. ;
  40. ;    The author specifically disclaims any warranties, implied or
  41. ;    otherwise, as to the performance and suitability of PATCH&GO.
  42.  
  43. FALSE    EQU    0
  44. TRUE    EQU    NOT FALSE
  45.  
  46. DEFDRV    EQU    TRUE        ; If true, load program to be patched
  47.                 ; from drive A: if it is not found on
  48.                 ; the currently selected drive and its
  49.                 ; drive was not specified explicitly
  50.                 ; when the patching program was created
  51.  
  52. BDOS    EQU    0005H        ; Addr of jump to BDOS
  53. FCB1    EQU    005CH        ; Addr of FCB for 1st file
  54. FCB2    EQU    006CH        ; Addr of FCB for 2nd file
  55. TPA    EQU    0100H        ; Addr of Transient Program Area
  56.  
  57. CONOUT    EQU    02H        ; BDOS "Console Output" function
  58. DCONIO    EQU    06H        ; BDOS "Direct Console I/O" function
  59. PRINTS    EQU    09H        ; BDOS "Print String" function
  60. OPENF    EQU    0FH        ; BDOS "Open File" function
  61. CLOSEF    EQU    10H        ; BDOS "Close File" function
  62. DLETEF    EQU    13H        ; BDOS "Delete File" function
  63. READS    EQU    14H        ; BDOS "Read Sequential" function
  64. WRITES    EQU    15H        ; BDOS "Write Sequential" function
  65. MAKEF    EQU    16H        ; BDOS "Make File" function
  66. SETDMA    EQU    1AH        ; BDOS "Set DMA Address" function
  67.  
  68. CNTLC    EQU    03H        ; Control-C (abort)
  69. BELL    EQU    07H        ; Bell
  70. BS    EQU    08H        ; Backspace
  71. LF    EQU    0AH        ; Linefeed
  72. CR    EQU    0DH        ; Carriage return
  73. CNTLX    EQU    18H        ; Control-X (delete entry)
  74.  
  75.     ORG    TPA
  76.     JMP    GETPAT
  77.  
  78. VERS:    DB    CR,LF
  79.     DB    'PATCH&GO v1.0 (07/17/86)'
  80.     DB    CR,LF,'$'
  81.  
  82.     DB    'Copyright (c) 1986 by John D. Osnes'
  83.  
  84. GETPAT:    MVI    C,PRINTS    ; Display signon msg
  85.     LXI    D,VERS
  86.     CALL    BDOS
  87.  
  88.     LXI    H,FCB1+1    ; Name of program specified?
  89.     MOV    A,M
  90.     CPI    ' '
  91.     JNZ    GETP02        ; YES
  92.  
  93. GETP01:    MVI    C,PRINTS    ; NO, display help
  94.     LXI    D,HELP
  95.     JMP    BDOS        ; Return to CCP via BDOS
  96.  
  97. GETP02:    LXI    B,9        ; Store name of program
  98.     LXI    D,COMFCB
  99.     DCX    H
  100.     CALL    MOVE
  101.     CALL    AMBIG        ; Check for ambiguous filename
  102.  
  103.     LXI    H,FCB2+1    ; Name of patching program
  104.     MOV    A,M        ; specified?
  105.     CPI    ' '
  106.     JZ    GETP01        ; NO, display help and exit
  107.  
  108.     LXI    B,9        ; Move name of patching program
  109.     LXI    D,FCB1        ; to default FCB
  110.     DCX    H
  111.     CALL    MOVE
  112.     LXI    B,3        ; Append COM extension
  113.     LXI    H,COMEXT
  114.     CALL    MOVE
  115.     CALL    AMBIG        ; Check for ambiguous filename
  116.  
  117.     MVI    C,PRINTS    ; Display command msg
  118.     LXI    D,COMMSG
  119.     CALL    BDOS
  120.  
  121. ; Loop for entry of patches
  122.  
  123. GETP04:    LXI    D,ADRMSG    ; Prompt for addr
  124. GETP05:    MVI    C,PRINTS
  125.     CALL    BDOS
  126.     MVI    C,4        ; Get addr (4 digits max)
  127.     LXI    D,ADDR
  128.     CALL    HEXIN
  129.     JNZ    GETP05        ; If zero set, restart entry
  130.     JC    SAVPAT        ; If carry set, end of patches
  131.     DCR    B        ; Empty entry?
  132.     JNZ    GETP06        ; NO, convert addr to binary
  133.  
  134.     LHLD    PATADR        ; YES, get last addr and increment it
  135.     DCX    H
  136.     DCX    H
  137.     MOV    D,M
  138.     DCX    H
  139.     MOV    E,M
  140.     INX    D
  141.     MOV    A,D        ; Display addr
  142.     CALL    BINHEX
  143.     MOV    A,E
  144.     CALL    BINHEX
  145.     LXI    H,VALMSG
  146.     JMP    GETP07
  147.  
  148. GETP06:    LXI    D,ADDR        ; Convert addr to binary
  149.     CALL    HEXBIN
  150.     XCHG
  151. GETP07:    PUSH    H
  152.     LHLD    PATADR        ; Store addr at location for
  153.     MOV    M,E        ; next patch
  154.     INX    H
  155.     MOV    M,D
  156.     POP    D
  157.  
  158.     MVI    C,PRINTS    ; Prompt for value
  159.     CALL    BDOS
  160.     XRA    A        ; Disable period terminator
  161.     STA    PTERM
  162.     MVI    C,2        ; Get value (2 digits max)
  163.     LXI    D,VALUE
  164.     CALL    HEXIN
  165.     MVI    A,RZ        ; Enable period terminator
  166.     STA    PTERM
  167.     JNZ    GETP05        ; If zero set, restart entry
  168.  
  169.     DCR    B        ; Empty entry?
  170.     JNZ    GETP08        ; NO, convert value to binary
  171.  
  172.     LHLD    PATADR        ; YES, get last value and repeat it
  173.     DCX    H
  174.     MOV    E,M
  175.     MOV    A,E        ; Display value
  176.     CALL    BINHEX
  177.     JMP    GETP09
  178.  
  179. GETP08:    LXI    D,VALUE        ; Convert addr to binary
  180.     CALL    HEXBIN
  181.     XCHG
  182. GETP09:    LHLD    PATADR        ; Store value at location for
  183.     INX    H        ; next patch
  184.     INX    H
  185.     MOV    M,E
  186.     INX    H        ; Store location for next patch
  187.     SHLD    PATADR
  188.     LHLD    PATCNT        ; Increment number of patches
  189.     INX    H
  190.     SHLD    PATCNT
  191.     JMP    GETP04        ; Get next patch
  192.  
  193. ; Save patching program
  194.  
  195. SAVPAT:    MVI    C,PRINTS    ; Display informative msg
  196.     LXI    D,ENDPAT
  197.     CALL    BDOS
  198.  
  199.     LHLD    PATCNT        ; Any patches entered?
  200.     MOV    A,H
  201.     ORA    L
  202.     JNZ    SAVP02        ; YES
  203.  
  204.     MVI    C,PRINTS    ; NO, don't save patching program
  205.     LXI    D,NOPATS
  206.     JMP    BDOS        ; Return to CCP via BDOS
  207. NOPATS:    DB    LF
  208.     DB    '++ No Patches - Patching Program Not Saved ++'
  209.     DB    BELL,CR,LF,'$'
  210.  
  211. SAVP02:    LXI    H,PATMOV    ; Patch addr in MOVE routine of
  212.     SHLD    JMPMOV        ; patching program
  213.     LHLD    PATADR
  214.     LXI    B,RELOC
  215.     CALL    SBCHL        ; Patch length of relocatable
  216.     SHLD    RELEN        ; module in patching program
  217.  
  218.     MVI    C,DLETEF    ; Delete patching file if it
  219.     LXI    D,FCB1        ; already exists
  220.     CALL    BDOS
  221.  
  222.     MVI    C,MAKEF        ; Create patching file
  223.     LXI    D,FCB1
  224.     CALL    BDOS
  225.     INR    A
  226.     JNZ    SAVP04        ; Successfully created
  227.  
  228.     MVI    C,PRINTS    ; Directory full
  229.     LXI    D,DIRFUL
  230.     JMP    BDOS        ; Return to CCP via BDOS
  231. DIRFUL:    DB    LF,'++ Directory Full ++',BELL,CR,LF,'$'
  232.  
  233. SAVP04:    LXI    D,PATPRO    ; Save patching program, beginning
  234. SAVP05:    MVI    C,SETDMA    ; at addr PATPRO
  235.     PUSH    D
  236.     CALL    BDOS
  237.     MVI    C,WRITES
  238.     LXI    D,FCB1
  239.     CALL    BDOS
  240.     POP    D
  241.     ORA    A
  242.     JNZ    DSKFUL        ; Disk full
  243.     LXI    H,128
  244.     DAD    D
  245.     XCHG            ; DE = next record of patching program
  246.     LHLD    PATADR        ; HL = end of patching program
  247.     MOV    A,D
  248.     CMP    H
  249.     JC    SAVP05        ; Save next record if H > D
  250.     JNZ    SAVP06        ; Done if H < D
  251.     MOV    A,E        ; H = D, compare L and E
  252.     CMP    L
  253.     JC    SAVP05        ; Save next record if L > E
  254.  
  255. SAVP06:    MVI    C,CLOSEF    ; Close patching file
  256.     LXI    D,FCB1
  257.     CALL    BDOS
  258.  
  259.     MVI    C,PRINTS    ; Done
  260.     LXI    D,DUNMSG
  261.     JMP    BDOS        ; Return to CCP via BDOS
  262. DUNMSG:    DB    LF,'Done ...',CR,LF,'$'
  263.  
  264. DSKFUL:    MVI    C,DLETEF    ; Disk full, so delete partial file
  265.     LXI    D,FCB1
  266.     CALL    BDOS
  267.  
  268.     MVI    C,PRINTS    ; Display error msg
  269.     LXI    D,DSKMSG
  270.     JMP    BDOS        ; Return to CCP via BDOS
  271. DSKMSG:    DB    LF,'++ Disk Full ++',BELL,CR,LF,'$'
  272.  
  273. ; Check for ambiguous filename in default FCB (abort if name is
  274. ; ambiguous)
  275.  
  276. AMBIG:    MVI    A,'?'
  277.     MVI    C,8
  278.     LXI    H,FCB1+1
  279. AMBIG2:    CMP    M
  280.     JZ    AMBIG4
  281.     INX    H
  282.     DCR    C
  283.     JNZ    AMBIG2
  284.     RET
  285.  
  286. AMBIG4:    POP    H        ; Restore stack
  287.     MVI    C,PRINTS    ; Display error msg
  288.     LXI    D,AMBMSG
  289.     JMP    BDOS        ; Return to CCP via BDOS
  290. AMBMSG:    DB    '++ Wildcards Not Allowed in Filenames ++'
  291.     DB    BELL,CR,LF,'$'
  292.  
  293. ; Get hexadecimal input (C digits max, store in buffer at DE; on
  294. ; return, B = number of digits entered + 1; zero set and carry
  295. ; clear if terminated by carriage return; zero and carry set if
  296. ; terminated by period; zero clear if terminated by ^X)
  297.  
  298. HEXIN:    MVI    B,0        ; Erase last entry from buffer
  299.     PUSH    B
  300.     PUSH    D
  301.     LXI    H,ERASEN
  302.     CALL    MOVE
  303.     POP    D
  304.     POP    B
  305.     INR    B        ; B = char counter
  306.     INR    C        ; C = buffer counter
  307.  
  308. HEXIN2:    PUSH    B        ; Loop for each digit
  309.     PUSH    D
  310. HEXIN4:    MVI    C,DCONIO    ; Get char using Direct Console I/O
  311.     MVI    E,0FFH
  312.     CALL    BDOS
  313.     ORA    A
  314.     JZ    HEXIN4        ; Loop til a char is entered
  315.     ANI    7FH        ; Strip parity bit
  316.     CPI    'a'        ; Convert lowercase to uppercase
  317.     JC    HEXIN6
  318.     CPI    'z'+1
  319.     JNC    HEXIN6
  320.     ANI    5FH
  321. HEXIN6:    POP    D
  322.     POP    B
  323.     CPI    '0'        ; Is char a hex digit?
  324.     JC    CNTLIN        ; NO, but may be control char
  325.     CPI    'F'+1
  326.     JNC    BADCH2        ; NO, error
  327.     CPI    '9'+1
  328.     JC    HEXIN8        ; YES, store it
  329.     CPI    'A'
  330.     JC    BADCH2        ; NO, error
  331. HEXIN8:    DCR    C        ; Max digits already entered?
  332.     JZ    MAXDIG        ; YES, error
  333.     INR    B        ; NO, increment digit counter
  334.     STAX    D        ; Store digit in buffer
  335.     INX    D        ; Increment buffer pointer
  336.  
  337. HEXCHO:    CALL    PCHAR        ; Echo digit
  338.     JMP    HEXIN2        ; Get next digit
  339.  
  340. MAXDIG:    INR    C        ; Max digits entered, so restore
  341.     JMP    BADCH2        ; buffer counter and ring bell
  342.  
  343. CNTLIN:    CPI    CR        ; Check control chars
  344.     RZ            ; Carriage return terminates entry
  345.     CPI    CNTLX
  346.     JZ    RENTER        ; ^X restarts entry
  347.     CPI    CNTLC
  348.     JZ    ABORT        ; ^C aborts
  349.     DCR    B
  350.     JNZ    BACKSP        ; Not 1st char, so may be backspace
  351.     CPI    '.'        ; 1st char, so may be period
  352.     STC
  353. PTERM:    RZ            ; Lone period terminates patches
  354.  
  355. BADCHR:    INR    B        ; Restore char counter
  356. BADCH2:    MVI    A,BELL        ; Ring bell on error
  357.     JMP    HEXCHO
  358.  
  359. BACKSP:    CPI    BS        ; Backspace routine
  360.     JNZ    BADCHR        ; Not backspace, so bad char
  361.     CALL    PCHAR
  362.     INR    C
  363.     DCX    D
  364.     MVI    A,' '
  365.     STAX    D
  366.     CALL    PCHAR
  367.     MVI    A,BS
  368.     JMP    HEXCHO
  369.  
  370. RENTER:    MVI    C,PRINTS    ; ^X entered, so restart entry
  371.     LXI    D,ERASE        ; Erase line
  372.     CALL    BDOS
  373.     LXI    D,ADRMS2
  374.     XRA    A
  375.     INR    A        ; Clear zero flag
  376.     RET
  377.  
  378. ABORT:    POP    H        ; ^C entered, so restore stack
  379.     MVI    C,PRINTS    ; Display appropriate msg
  380.     LXI    D,ABMSG
  381.     JMP    BDOS        ; Return to CCP via BDOS
  382. ABMSG:    DB    '^C  .. Abort ..',BELL,CR,LF,'$'
  383.  
  384. ; Convert ASCII hexadecimal digits beginning at DE to binary and
  385. ; return value in HL (digits terminated by space and DE = addr of
  386. ; space on return)
  387.  
  388. HEXBIN:    LXI    H,0        ; Zero accummulator
  389. HEXB02:    LDAX    D        ; Get next hex digit (or terminator)
  390.     SUI    '0'
  391.     RC            ; Terminator (space)
  392.     CPI    10
  393.     JC    HEXB04
  394.     SUI    'A'-'9'-1
  395. HEXB04:    DAD    H
  396.     DAD    H
  397.     DAD    H
  398.     DAD    H
  399.     ORA    L
  400.     MOV    L,A
  401.     INX    D
  402.     JMP    HEXB02
  403.  
  404. ; Display byte in A in hexadecimal notation (2 ASCII chars)
  405.  
  406. BINHEX:    PUSH    PSW
  407.     RLC
  408.     RLC
  409.     RLC
  410.     RLC
  411.     CALL    BINH02
  412.     POP    PSW
  413. BINH02:    ANI    0FH
  414.     ADI    '0'
  415.     CPI    '9'+1
  416.     JC    PCHAR
  417.     ADI    'A'-('9'+1)    ; Fall thru PCHAR
  418.  
  419. ; Display char in A (BC and DE preserved)
  420.  
  421. PCHAR:    PUSH    B
  422.     PUSH    D
  423.     MVI    C,CONOUT
  424.     MOV    E,A
  425.     CALL    BDOS
  426.     POP    D
  427.     POP    B
  428.     RET
  429.  
  430. ; Data area for PATCH&GO
  431.  
  432. PATADR:    DW    PATCHS        ; Addr to store next patch
  433.  
  434. ADRMSG:    DB    CR,LF        ; Address prompt
  435. ADRMS2:    DB    'Addr: $'
  436. ADDR:    DB    '    '        ; Storage for address (in ASCII)
  437. VALMSG:    DB    '   Value: $'    ; Value prompt
  438. VALUE:    DB    '   '        ; Storage for value (in ASCII)
  439.  
  440. ERASE:    DB    CR        ; Erases line of current entry
  441. ERASEN:    DB    '                       ',CR,'$'
  442.  
  443. ENDPAT:    DB    '.. End of Patches ..',CR,LF,'$'
  444.  
  445. ; Patching program and its data area begins here
  446.  
  447. PATPRO:    LXI    D,PATFCB
  448. OFFSET    EQU    PATPRO-TPA    ; (offset between addr in PATCH&GO
  449. PATOPN    EQU    $-OFFSET    ; and addr in patching program)
  450.     MVI    C,OPENF        ; Attempt to open file to load and
  451.     CALL    BDOS        ; patch
  452.     INR    A        ; Program found?
  453.     JNZ    PATP02        ; YES
  454.  
  455.      IF    DEFDRV
  456.     LXI    D,PATFCB    ; NO
  457.     LDAX    D        ; Was drive specified explicitly?
  458.     ORA    A
  459.     JNZ    NOFILE        ; YES, abort
  460.     INR    A        ; NO, try drive A:
  461.     STAX    D
  462.     JMP    PATOPN
  463. NOFILE    EQU    $-OFFSET
  464.      ENDIF
  465.  
  466.     MVI    C,PRINTS    ; Program not found, so display
  467.     LXI    D,NOFMSG    ; error msg
  468.     JMP    BDOS        ; Return to CCP via BDOS
  469. NOFMSG    EQU    $-OFFSET
  470.     DB    '++ COM File Not Found ++',BELL,CR,LF,'$'
  471.  
  472. PATP02    EQU    $-OFFSET
  473.     LDA    BDOS+2
  474.     SUI    8
  475.     MOV    H,A
  476.     MVI    L,0        ; HL = top-of-TPA
  477. RELEN    EQU    $+1
  478.     LXI    B,0        ; BC = length of relocatable module
  479.     CALL    PATSBC
  480.     SHLD    RELADR        ; Store relocation addr
  481.     PUSH    B
  482.     LXI    B,PATREL
  483.     CALL    PATSBC
  484.     XCHG            ; DE = offset between addr in patching
  485.                 ; program and addr in relocated module
  486.     LHLD    CH1        ; Add offset to addresses in relocatable
  487.     DAD    D        ; module
  488.     SHLD    CH1
  489.     LHLD    CH2
  490.     DAD    D
  491.     SHLD    CH2
  492.     LHLD    CH3
  493.     DAD    D
  494.     SHLD    CH3
  495.     LHLD    CH4
  496.     DAD    D
  497.     SHLD    CH4
  498.     LHLD    CH5
  499.     DAD    D
  500.     SHLD    CH5
  501.     LHLD    CH6
  502.     DAD    D
  503.     SHLD    CH6
  504.     LHLD    CH7
  505.     DAD    D
  506.     SHLD    CH7
  507.     LHLD    CH8
  508.     DAD    D
  509.     SHLD    CH8
  510.  
  511.     POP    B        ; BC = length of relocatable module
  512.     LHLD    RELADR
  513.     XCHG            ; DE = relocation addr
  514.     PUSH    D        ; Push relocation addr on stack
  515.     LXI    H,PATREL    ; Relocate module (fall thru MOVE
  516.                 ; and "return" to relocated module)
  517.  
  518. PATMOV    EQU    $-OFFSET
  519. MOVE:    MOV    A,B        ; Move BC bytes from HL to DE
  520.     ORA    C
  521.     RZ
  522.     MOV    A,M
  523.     STAX    D
  524.     INX    H
  525.     INX    D
  526.     DCX    B
  527. JMPMOV    EQU    $+1
  528.     JMP    MOVE
  529.  
  530. PATSBC    EQU    $-OFFSET
  531. SBCHL:    MOV    A,L        ; HL = HL - BC
  532.     SUB    C
  533.     MOV    L,A
  534.     MOV    A,H
  535.     SBB    B
  536.     MOV    H,A
  537.     RET
  538.  
  539. PATREL    EQU    $-OFFSET
  540. RELOC    EQU    $        ; Addr of rel mod in PATCH&GO
  541.  
  542.     LXI    D,TPA        ; Read program to be patched into TPA
  543. PATLOD    EQU    $-OFFSET
  544.     LXI    H,128
  545.     DAD    D
  546. RELADR    EQU    $+1-OFFSET
  547.     LXI    B,0
  548.     MOV    A,B
  549.     CMP    H
  550. CH1    EQU    $+1-OFFSET
  551.     JC    MEMERR        ; Will overwrite rel mod if H > B
  552. CH2    EQU    $+1-OFFSET
  553.     JNZ    PATRDR        ; Load next record if H < B
  554.     MOV    A,C        ; H = L, compare L and C
  555.     CMP    L
  556. CH3    EQU    $+1-OFFSET
  557.     JC    MEMERR        ; Will overwrite rel mod if L > C
  558. PATRDR    EQU    $-OFFSET
  559.     MVI    C,SETDMA    ; Read a record into TPA
  560.     PUSH    H
  561.     CALL    BDOS
  562.     MVI    C,READS
  563. CH4    EQU    $+1-OFFSET
  564.     LXI    D,PATFCB
  565.     CALL    BDOS
  566.     POP    D
  567.     ORA    A        ; End-of-file?
  568. CH5    EQU    $+1-OFFSET
  569.     JZ    PATLOD        ; NO, read next record
  570.  
  571. PATCNT    EQU    $+1
  572.     LXI    B,0        ; BC = number of bytes to patch
  573. CH6    EQU    $+1-OFFSET
  574.     LXI    H,PATPAT    ; HL = addr of patches
  575. PATLOP    EQU    $-OFFSET    ; Loop for installing patches
  576.     MOV    A,B        ; When BC = 0, jump to base of TPA
  577.     ORA    C        ; to execute patched program
  578.     JZ    TPA
  579.     DCX    B
  580.     MOV    E,M
  581.     INX    H
  582.     MOV    D,M
  583.     INX    H
  584.     MOV    A,M
  585.     INX    H
  586.     STAX    D
  587. CH7    EQU    $+1-OFFSET
  588.     JMP    PATLOP
  589.  
  590. MEMERR    EQU    $-OFFSET    ; Attempt to overwrite relocation
  591.     MVI    C,PRINTS    ; module, so can't load program
  592. CH8    EQU    $+1-OFFSET
  593.     LXI    D,MEMSG        ; Display error msg
  594.     JMP    BDOS        ; Return to CCP via BDOS
  595. MEMSG    EQU    $-OFFSET
  596.     DB    '++ Out of Memory ++',BELL,CR,LF,'$'
  597.  
  598. PATFCB    EQU    $-OFFSET
  599. COMFCB:    DB    0,'        '    ; FCB for program
  600. COMEXT:    DB    'COM',0,0,0,0,0,0
  601.     DB    0,0,0,0,0,0,0,0,0
  602.     DB    0,0,0,0,0,0
  603.     DW    0-1
  604.     DB    0
  605.  
  606. PATPAT    EQU    $-OFFSET
  607. PATCHS    EQU    $        ; Patches (overwrites msgs)
  608.  
  609. COMMSG:    DB    LF        ; Command msg
  610.     DB    'All Entries in Hexadecimal, Terminated '
  611.     DB    'by RETURN',CR,LF
  612.     DB    '  (Empty Entry = Next Address or Repeat '
  613.     DB    'Value)',CR,LF,LF
  614.     DB    '   ^H = Backspace, ^X = Restart Current '
  615.     DB    'Entry',CR,LF
  616.     DB    '       PERIOD = End of Patches, ^C = '
  617.     DB    'Abort',CR,LF
  618.     DB    '$'
  619.  
  620. HELP:    DB    LF        ; Help msg
  621.     DB    'Creates a program which loads, patches, and '
  622.     DB    'executes another program.',CR,LF,LF
  623.     DB    'USAGE:  PATCH&GO c:comfile d:patfile',CR,LF,LF
  624.     DB    'where:  c:comfile = name of the program to '
  625.     DB    'be loaded, patched, and',CR,LF
  626.     DB    '                    executed (c: specifies '
  627.     DB    'the drive where the pro-',CR,LF
  628.     DB    '                    gram will be found when '
  629.     DB    'it is loaded and defaults',CR,LF
  630.     DB    '                    to the drive currently '
  631.     DB    'selected at the time',CR,LF
  632.     DB    '                    "comfile" is loaded'
  633.      IF    DEFDRV
  634.     DB    ' or to drive A: if "comfile"',CR,LF
  635.     DB    '                    is not found on the '
  636.     DB    'currently selected drive'
  637.      ENDIF
  638.     DB    ')',CR,LF,LF
  639.     DB    '        d:patfile = name of the program '
  640.     DB    'that will load, patch, and',CR,LF
  641.     DB    '                    execute "comfile" '
  642.     DB    '(d: specifies the drive where',CR,LF
  643.     DB    '                    the "patfile" is '
  644.     DB    'saved and defaults to the',CR,LF
  645.     DB    '                    currently selected '
  646.     DB    'drive)',CR,LF,LF
  647.     DB    'Both filenames are required and can not '
  648.     DB    'contain wildcards.  The COM',CR,LF
  649.     DB    'file type is implied on both files.',CR,LF
  650.     DB    '$'
  651.  
  652.     END
  653.