.TITLE SPAWN .IDENT /14JAN82/ .ENABL LC ; Formerly SPWNMCR 1.4XA : ; ; MODULE TO TAKE OUTPUT FROM CCL.MAC AS ADDR OF FIRST CHAR, ; LENGTH IN CHARACTERS, AND TO OUTPUT AN MCR COMMAND LINE ; USE THE SPAWN DIRECTIVE TO SEND MESSAGES TO MCR ; ; J. DOWNWARD 16-FEB-79 ; ; 18-MAY-79 EXIT WITH CORRECT STATUS ; WAIT FOR SPAWNED COMMAND TO COMPLETE ; UNLESS COMMAND TERMINATED WITH A %$% ; ; 15-JUN-79 CHANGE ...MCR TO MCR... FOR V3.2 ; ; P. Sorenson 01-mar-81 Update for CCL V7.0 ; Mich. State Univ. ; ; Notes on SPAWN vs. SPWNMCR: modified call sequence and entry points ; for version 7.0A of CCL. Call with: R0 = start address of command, ; R1 = length of command, and R2 = 0 if want SPAWN to wait for spawned ; task to exit (R2 >< 0 will return immediately after successful spawn). ; Entry points are: PUTMCR to spawn command to MCR...; PUTCA2 to spawn ; command to ...CA2, 2nd "catchall" task. ; ; An optional enhancement may be included at SYSGEN time to ; allow the SPAWN directive (see [12,10] DRSPW.MAC) to relink the ; OCB (offspring control block) of CCL's offspring to CCL's parent, ; thereby allowing CCL to silently exit without losing a path back to ; the task that invoked CCL. This enhancement is courtesy of D. ; Steinberg, and was published in the Feb. '81 Multi-tasker. This ; special spawn directive is invoked by issuing the SPAWN with event ; flag = -1, and is enabled here by definition of the symbol $DSSPW ; in a conditional assembly file (typically PRECCL.MAC). ; ; J. Downward 27-Aug-81 For RSX11M V4.0 added RPOI support. If the ; JGD80 %$ is seen or if the CCL command line is ; the only command line (ie it starts with a *), ; the code attempts to use RPOI$ first. If ; however, %R is present, RPOI will not be used. ; If RPOI$ is legal, the OCB will be relinked ; and CCL will immediately exit. RPOI$ relinks ; OCB's for V4.0 the same way the above ; discussed patch does for V3.2. ; ; 16-Nov-81 Use also as CLI ; JGD81 If Must use RPOI. Can't wait to ring bell. ; ; P. Sorenson 18-Jun-82 Make "CA2NM" global so CCL can modify its ; PRS03 catchall based on current task name ; ; PRS04 Restore registers on return ; ; PRS05 Change entry point for catchall to "PUTCA"; ; task name to spawn must be defined @$CANAM. ; For CLI's, the name @$CANAM will be the ; default defined here, or altered by GBLPAT, ; ZAP, etc. ; For catchall's, the name @$CANAM will be setup ; at run time prior to calling PUTCA. ; Also, stop MCR prompts when CA. spawns CA0 etc .MCALL SPWN$,DIR$,STSE$S,EXST$S .MCALL RPOI$ ; JGD80 EFN1=1 ; EVENT FLAG FOR STOP ESC=33 RP.ONX=2 ;****** temporary definition ;JGD80 .PSECT $IDATA,RW,D,CON,LCL,REL ;PRS05 MCRNM: .RAD50 /MCR.../ ; Spawned task name for PUTMCR entry point $CANAM:: CA2NM: .RAD50 /MCR.../ ; Spawned task name for PUTCA entry ;PRS05 SPNDPB: SPWN$ MCR...,,,,,EFN1,,,, CHAIN: RPOI$ MCR...,,,,,,,,,,,, ; JGD80 .PSECT $CODE1,RO,I,CON,LCL,REL ;PRS05 PUTCA:: ; External entry point--spawn a catchall ;PRS05 MOV R1,-(SP) ; Save command length ;PRS05 MOV #$CANAM,R1 ; Fetch pointer to catchall's name ;PRS05 MOVB #RP.OAL!RP.OEX,CHAIN+R.POSC; Pass all OCB connections ;PRS05 BR MERGE ; and branch PUTMCR:: ; External entry point MOV R1,-(SP) ; Save command length ;PRS05 MOV #MCRNM,R1 ; Fetch pointer to MCR... name MOVB #RP.ONX!RP.OEX,CHAIN+R.POSC; Must pass only 1 OCB ;PRS05 MERGE: CMP #79.,(SP) ; NOW WE CAN'T HAVE A BUFFER >79 CHAR. BLT 34$ ; OR ELSE ERROR MOV #EFN1,SPNDPB+S.PWEF ; Set up event flag TSTB CLIFLG ; Are we a CLI ;JGD81 BNE 2$ ; If NE, yes, Must use RPOI ;PRS05 TSTB RING ; Should terminal bell ring on exit ;JGD80 BNE 8$ ; If NE, yes, can't use RPOI$ ;JGD81 TST R2 ; Requested exit right after spawn? BNE 3$ ; In NE, Yes, try RPOI$ first ;JGD80 CMPB SAVTYP,#'* ; Is this the last action line? ;JGD80 BNE 8$ ; If NE no, Must use SPWN/STOP ;PRS04 2$: MOVB #RP.ONX,CHAIN+R.POSC ; CLI's pass 1 OCB, don't exit ;PRS05 3$: MOV (R1),CHAIN+R.POTK ; Yes, use chain directive ;JGD80 MOV 2(R1),CHAIN+R.POTK+2 ; so first set taskname ;JGD80 MOV (SP),CHAIN+R.POBL ; Then length of command ;PRS05 MOV R0,CHAIN+R.POBF ; And command buffer address ;JGD80 ADD (SP),R0 ; Offset ;PRS05 MOVB ESC,(R0) ; Stop MCR ">" prompt ;JGD80 MOV CHAIN+R.POBF,R0 ; Restore pointer ;PRS05 MOV #EX$SUC,EXSTAT ; Assume CCL exit status OK ;JGD80 4$: DIR$ #CHAIN ; Chain command to MCR ;JGD80 BCC 35$ ; Return to caller on success ;PRS04 TSTB CLIFLG ; Are we a CLI ;JGD81 BNE 35$ ; If yes, Return for more ;PRS04 5$: ; Ref lable ;JGD81 ; CHAIN failed, try SPAWN .IFDF $DSSPW ; Conditional assembly for special ; spawn to relink OCB's NEG SPNDPB+S.PWEF ; Signal special spawn (set EFN=-1) .ENDC ;$DSSPW 8$: ; Reference label ;JGD81 MOV (R1),SPNDPB+S.PWTN ; Set up task name MOV 2(R1),SPNDPB+S.PWTN+2 ; MOV (SP),SPNDPB+S.PWCL ; Set up command length MOV R0,SPNDPB+S.PWCA ; Set up command start address MOV #EXSTAT,SPNDPB+S.PWES ; Insert exit status block address MOV #EX$SUC,EXSTAT ; assume success ;PRS05 10$: DIR$ #SPNDPB ; Spawn command BCS 32$ ; Check error status TST R2 ; Check value in R2 BNE 35$ ; If non-zero, don't wait for spawned ; task exit, return with carry bit clear STSE$S #EFN1 ; Stop until command done ; TST EXSTAT ; Check exit status; If 0, have success ; BNE 30$ ; If non-zero, use status returned by offspring ; MOV #EX$SUC,EXSTAT ; Show success 30$: CLC ; Return success in carry bit BR 35$ ; and return 32$: .IFDF $DSSPW ; Conditional assembly for special spawns CMP $DSW,#IE.ITS ; Spawn failed; was it a special spawn (EFN=-1) ; to MCR w/ multiple parent's ? BNE 34$ ; Branch if no, regular spawn error NEG SPNDPB+S.PWEF ; If yes, retry a normal spawn and CLR R2 ; wait for offspring to exit BR 10$ ; .ENDC ;$DSSPW 34$: SEC ; Show spawn failure, set carry and 35$: MOV (SP)+,R1 ; Restore command length ;PRS04 RETURN ; Exit .END