.TITLE SPAWN .IDENT /V1.0A/ .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 ; ; 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). ; ; Paul Sorenson -- 3/81 ; Mich. State Univ. ; .MCALL SPWN$,DIR$,STSE$S,EXST$S EFN1=1 ; EVENT FLAG FOR STOP ESC=33 .PSECT $VARS,RW,D,CON,LCL MCRNM: .RAD50 /MCR.../ ; Spawned task name for PUTMCR entry point CA2NM: .RAD50 /...CA2/ ; Spawned task name for PUTCA2 entry point LEN: .WORD 0 ; Length of command to MCR EXSTAT: .WORD EX$SUC ; Exit status block (8. words long) .BLKW 7 SPNDPB: SPWN$ MCR...,,,,,EFN1,,,, .PSECT $CODE1,RW,I,CON,LCL PUTCA2:: ; External entry point--spawn ...CA2 MOV R1,LEN ; Save command length MOV #CA2NM,R1 ; Fetch pointer to ...CA2 name BR MERGE ; and branch PUTMCR:: ; External entry point MOV R1,LEN ; Save command length MOV #MCRNM,R1 ; Fetch pointer to MCR... name MERGE: CMP #79.,LEN ; NOW WE CAN'T HAVE A BUFFER >79 CHAR. BLT 34$ ; OR ELSE ERROR MOV #EFN1,SPNDPB+S.PWEF ; Set up event flag .IFDF $DSSPW ; Conditional assembly for special spawn ; to relink OCB's TST R2 ; Requested exit right after spawn? BEQ 5$ ; Branch if no NEG SPNDPB+S.PWEF ; Signal special spawn by setting EFN=-1 MOVB ESC,LEN(R0) ; Stop MCR ">" prompt 5$: ; Reference label .ENDC ;$DSSPW MOV (R1),SPNDPB+S.PWTN ; Set up task name MOV 2(R1),SPNDPB+S.PWTN+2 ; MOV LEN,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 10$: DIR$ #SPNDPB ; Spawn command BCS 32$ ; Check error status 20$: MOV #EX$SUC,EXSTAT ; Spawn OK, assume success TST R2 ; Check value in R2 BNE 30$ ; If non-zero, don't wait for spawned task exit 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$: MOV EXSTAT,R0 ; Save exit status for anyone who wants it 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$: RETURN ; Exit .END