                                       CP/M   V2.2
                              Application Note 08, 2/20/82
                                   Nested SUBMIT Files

                           Copyright  1982 by Digital Research
                   CP/M is a registered trademark of Digital Research.
                         DDT is a trademark of Digital Research.
                                 Compiled November 1982

          Applicable products and version numbers:  CP/M   V2.1 and V2.2

          Program:  SUBMIT.COM

               The CP/M SUBMIT program  allows  you  to  embed  another  SUBMIT
          command  within  a  submit file.  However, control does not return to
          the original SUBMIT file after executing the nested  SUBMIT  command.
          To  return  control  to the original SUBMIT command, use any standard
          editor  to  type  the  following  procedure   into   a   file   named
          SUBPATCH.ASM:

             ;
             ;
             subfcb: equ     5bbh
             bdos:   equ     5
             open:   equ     211h
             ;
                     org     22dh             ;submit erase subroutine
             ;
             opsl:   lda     subfcb+15        ;file open ok if ext not full
                     ral
                     rnc
                     lxi     h,subfcb+12      ;try next extent
                     inr     m
             ops:    lxi     d,subfcb         ;open extent
                     jmp     create
             ;
                     org     25dh             ;submit create subroutine
             create: call    open
                     inr     a
                     jnz     opsl             ;loop if open ok
                     lxi     d,subfcb
                     mvi     c,22
                     call    bdos
                     adi     1
                     ret
             ;
             ;       the following code calls the above routines
             ;
                     org     4feh
             ;
                     call    ops              ;open the $$$.sub file
                     jc      517h             ;jump if not opened ok
                     lda     subfcb+15        ;set current record to end
                     sta     subfcb+32
                     jmp     51dh             ;jump if open ok
             ;
                     org     subfcb
                     db      1                ;force $$$.sub file to A:
             ;
                     end


               Assemble SUBPATCH ASM to create the file SUBPATCH.HEX.  Then use
          DDT  to  insert  SUBPATCH.HEX  into  the SUBMIT.COM program, as shown
          below.

                    A>ddt submit.com
                    DDT VERS 2.2
                    NEXT  PC
                    0600 0100
                    -isubpatch.hex
                    -r
                    -g0
                    A>save 5 submit1.com


               In the new program SUBMIT1.COM, control returns to the  original
          SUBMIT file after the system executes embedded SUBMIT commands.

               Licensed  users  are  granted  the  right   to   include   these
          modifications in CP/M V2.1 and V2.2 software.
