	.title comand
	.ident	/v2/
;
; A version of the trivial command decoder program for a stand-alone
; RSX11M or M-Plus system.
;
; This program is taskbuilt /-SE & installed as MCR... for the benefit
; of ...INS which may otherwise attempt to start MCR and crash the system
;
; Start the program with the VMR RUN command
; It runs programs with names XXX when given commands such as XXX command
; REF: Multitasker, Vol 14, No. 6, Pg. 155-6
;	Richard J. D. Kirkman,  ATMOS Oxford.   April 1981.
;
	.mcall	dir$,qiow$,alun$,spwn$,wtse$s
	.enabl	lc
;
; Program Loop
start:	dir$	#alun			; Use specified terminal ( not our TI:)
loop:	dir$	#rpr			; read a command line
	cmpb	iosts,#io.suc		; success?
	bne	loop			; - no - get another ( no exit on ^Z)
	mov	iosts+2,spwn+s.pwcl	; set command line length
	mov	#inbuf,r0		; get the command line
	call	$cat5			; make the first chars into RAD50
	bcc	1$			; - successfully
	mov	#qioe,r0		; point to error dpb
	mov	#err1,q.iopl(r0)	; set text address
	mov	#err1l,q.iopl+2(r0)	;  and length
	dir$	r0			; and print it
	br	loop			;  and get next command
1$:	dir$	#spwn			; OK- now start the task requested
	bcc	2$			; if its started, then wait for it
	mov	#qioe,r0		; show this error
	mov	#err2,q.iopl(r0)	; set text address
	mov	#err2l,q.iopl+2(r0)	;  and length
	dir$	r0			; and print it
	br	loop			; and get next command
2$:	wtse$s	#2			; wait for task to complete
	br	loop			; and ask for more commands
;
; data
alun:	alun$	1,TT,0			; Assign TT0 always
qioe:	qiow$	io.wlb,1,1,,,,<0,0,40>	; DPB for error messages
rpr:	qiow$	io.rpr,1,1,,iosts,,<inbuf,80.,,prmpt,prmptl,0>
spwn:	spwn$	XXX,,,,,2,,,inbuf,80.,0	; spawn requested task
;
inbuf:	.blkb	80.
iosts:	.blkw	2
prmpt:	.ascii	<15><12>"CMD>"
prmptl	=.-prmpt
err1:	.ascii	"CMD -- Syntax error"
err1l	=.-err1
err2:	.ascii	"CMD -- Task not in system"
err2l	=.-err2
	.even
	.end	start

