.TITLE CAT Simple Catchall Task ; ; This little program allows recursion in the catchall task. ; It immediately dequeues the MCR line and tries to spawn CA1. ; If that fails it tries to spawn CA2. If that fails it exits ; with an error message. ; ; The idea is that a command to the Catchall Task might result in a ; command that needs another pass. This way CA. passes the ; line to CA1 which passes it to MCR which passes it to CA2 and then ; it all goes back again. Note that as it is written only two ; levels are allowed - it would obviously be trivial to add more. ; .MCALL SPWN$,DIR$,GMCR$,QIOW$S,WTSE$S,EXIT$S,EXST$S,ALUN$S,MRKT$S EXSTAT: .BLKW 8. BUFF: .WORD ; For Prefix GMCR: GMCR$ SPWN: SPWN$ ...CA1,,,,,1,,EXSTAT,GMCR+G.MCRB MSG1: .ASCII /CA. - CCL Task not installed/<7> MSG1L=.-MSG1 MSG2: .ASCII /CA. - Recursion too deep/<7> MSG2L=.-MSG2 MSG3: .ASCII /CA. - CCL Spawning failed/<7> MSG3L=.-MSG3 .EVEN ; START: DIR$ #GMCR ; Get the command line MOV $DSW,SPWN+S.PWCL ; Stuff length in Spawn directive BNE 7$ ; If NE there was some - carry on ; 4$: JMP END ; Else exit at once ; 7$: DIR$ #SPWN ; Spawn to CA1 CMP $DSW,#IS.SUC ; OK? BEQ 4$ ; If EQ yes - exit CMP $DSW,#IE.INS ; No - was it not installed? BNE 10$ ; Not that - must be active MOV #MSG1,R0 ; Set up message MOV #MSG1L,R1 ; BR ERRXIT ; And exit with error ; 10$: CMP $DSW,#IE.ACT ; Was it active? BNE 20$ ; No - take error exit MOV #^RCA2,SPWN+S.PWTN+2 ; Change the name DIR$ #SPWN ; Try the other one CMP $DSW,#IS.SUC ; Success? BEQ END ; Yes - exit CMP $DSW,#IE.ACT ; Was it active? BNE 20$ ; If NE no - carry on MOV #"CA,BUFF ; Try going via MCR MOV #"1 ,BUFF+2 ; MOV #^RMCR,SPWN+S.PWTN ; MOV #^R...,SPWN+S.PWTN+2 ; MOV #BUFF,SPWN+S.PWCA ; Change the address ADD #4,SPWN+S.PWCL ; and size MOV #1,EXSTAT ; Initialise so we know what's happened DIR$ #SPWN ; Try it MRKT$S #1,#3,#2 ; Wait for three seconds as well WTSE$S #1 ; CMP EXSTAT,#1 ; Did it succeed? BEQ END ; If eq yes - exit MOV #"2 ,BUFF+2 ; No - change to CA2 MOV #1,EXSTAT ; Initialise so we know what's happened DIR$ #SPWN ; Try it MRKT$S #1,#3,#2 ; Wait for three seconds as well WTSE$S #1 ; CMP EXSTAT,#1 ; Did it succeed? BEQ END ; If eq yes - exit MOV #MSG2,R0 ; No - set up message MOV #MSG2L,R1 ; BR ERRXIT ; ; 20$: MOV #MSG3,R0 ; Set up default message MOV #MSG3L,R1 ; ; ERRXIT: ALUN$S #1,#"TI,#0 ; Assign LUN 1 QIOW$S #IO.WLB,#1,#1,,,, EXST$S #4 ; Fatal Error ; END: EXST$S #1 ; Success EXIT$S ; Just in case .END START