             Page   60, 130
              EXTRN  Pascal B$ShellSetup:Far
              EXTRN  Pascal B$ShellRecover:Far
     .MODEL   MEDIUM,BASIC
              .CODE

     Qexec    Proc    Far Uses DS ES SI DI, Arg1:Ptr
              Jmp     Start

     HoldRC   DW      0

     Pars     DW      0                      ;Environment segment
     CmdLine  DW      0                      ;Command line for child - length
     CmdLineS DW      0                      ;  Command line text
              DW      5CH                    ;Default FCB 1 offset
     Fcb1     DW      0                      ;FCB 1 segment address
              DW      6CH                    ;Default FCB 2 offset
     Fcb2     DW      0                      ;FCB 2 segment address

     PgmTxt   DB      65 Dup(?)              ;Work area to build pgm string

     CmdBuf   DB      ?                      ;This will hold the length
              DB      ' '                    ;Must allow one space
     CmdTxt   DB      80 Dup(?)              ;The command line text

     Start:   Mov     CS:HoldRC,-1           ;Set RC to -1
              Mov     BX,Arg1                ;Get Program name length
              Mov     CX,[BX]                ;  in CX
              Jcxz    GetOut                 ;Error - Get out
              Mov     SI,[BX+2]              ;Address of Program string
              Mov     DI,Offset PgmTxt       ;Program text buffer
              Push    ES                     ;Save ES register
              Mov     AX,CS                  ;Make the ES register
              Mov     ES,AX                  ;   the same as the CS register

     Pline:   Lodsb                          ;Get a character
              Cmp     AL,' '                 ;Is it a space?
              Je      Pline1                 ;Yes - go to next routine
              Stosb                          ;Move to buffer
              Loop    Pline                  ;Do it again

     Pline1:  Xor     AX,AX                  ;Zero out AX register
              Stosb                          ;Make PgmTxt an ASCIIZ string
              Jcxz    Pline2                 ;No more - continue
              Dec     CX                     ;Adjust for space

     Pline2:  Mov     CS:CmdBuf,CL           ;Save command tail length
              Mov     DI,Offset CmdTxt       ;Command tail buffer
              Jcxz    Tline                  ;No more - continue
              Rep     Movsb                  ;Move command tail to buffer
     Tline:   Inc     CS:CmdBuf              ;Add one to tail length
              Mov     AL,13                  ;CR value in AL
              Stosb                          ;Move to buffer
              Pop     ES                     ;Restore ES register
              Mov     DI,Offset CmdBuf       ;New command tail
              Mov     CS:CmdLine,DI          ;Move address to parameter block
              Mov     DI,CS                  ;Get CS register address
              Mov     CS:CmdLineS,DI         ;Move address to parameter block
              Mov     AH,62H                 ;Get current PSP segment
              Int     21H                    ;DOS interrupt
              Mov     CS:Fcb1,BX             ;Move PSP address to param block
              Mov     CS:Fcb2,BX             ;Move PSP address to param block
              Call    B$ShellSetup           ;QB routine to compress memory
              Mov     DX,Offset PgmTxt       ;DX points to program name string
              Mov     BX,Offset Pars         ;BX points to child environment
              Push    DS                     ;Save DS register
              Mov     AX,CS                  ;Put CS register address
              Mov     ES,AX                  ;   into the ES register
              Mov     DS,AX                  ;   into the DS register
              Mov     AH,4BH                 ;Function 4B - EXEC function
              Mov     AL,00H                 ;Sub Function 0 - load & exec pgm
              Int     21H                    ;DOS interrupt
              Pop     DS                     ;Restore DS register
              Jnc     Cont                   ;No Error - Continue
              Mov     AH,-1                  ;Set AH = FFh
              Jmp     Cont1                  ;Error - Get out
     Cont:    Mov     AH,4DH                 ;Function 4D - Get child errorlevel
              Int     21H                    ;DOS interrupt
              Xor     AH,AH                  ;Zero out AH register
     Cont1:   Mov     CS:HoldRC,AX           ;Set RC to -1
              Call    B$ShellRecover         ;QB routine to uncompress memory

     GetOut:  Mov     AX,CS:HoldRC           ;Set the return code
              Ret                            ;Go back to caller

     Qexec    Endp
              End
