	.Title	SHOW_SPOOL
;	Program Show Spool
;	Written by:	Frank Penner
;			September 1988
;	This program will show what queue a given device is spooled to
;	to use, type:
;		SHOW_SPOOL TXA0:
;	where TXA0: is the device
	$UCBDEF				;define UCB offsets
	$VCBDEF				;define VCB offsets
	.PSECT	DATA,WRT,NOEXE
COMMLD:	.ASCID	/                  /	;temporary device name for chan assign
PROMPTD:.ASCID	/device name:/		;prompt string
FAODESC:.ASCID	/                                                        /-
		/                                                        /
FORSTR:	.ASCID	/ !AD /
QNAME:	.BLKB	100
	.PSECT	CODE,NOWRT,EXE
	.ENTRY	START,^M<>		;start of program
	PUSHAW	COMMLD			;address of word to get read byte count
	PUSHAL	PROMPTD			;address of prompt string descriptor
	PUSHAL	COMMLD			;address of descriptor to get command
	CALLS	#3,G^LIB$GET_FOREIGN	;use run time library to get command
	BLBC	R0,ERROR		;low bit clear error
	$CMKRNL_S FIND_DEV		;change mode to kernel to find UCB add
	BLBC	R0,ERROR		;low bit clear error
	$CMEXEC_S GET_QUE
	BLBC	R0,ERROR		;low bit clear error
	$FAO_S	CTRSTR=FORSTR,-		;format string 
		OUTBUF=FAODESC,-	;char descript for formatted output
		OUTLEN=FAODESC,-	;long word to hold length of output
		P1=R7,-			;length of que name
		P2=#QNAME		;que name
	BLBC	R0,ERROR		;low bit clear error
	PUSHAL	FAODESC
	CALLS	#1,G^LIB$PUT_OUTPUT
	BLBC	R0,ERROR		;low bit clear error
	BRB	EXIT
	.ENTRY	NOCRASH,^M<>		;Kernel mode exit handler
EXIT:
ERROR:	$EXIT_S	R0			;exit with error if any
	.ENTRY	FIND_DEV,^M<>		;beginning of kernel mode code
	MOVAL	NOCRASH,(FP)		;so we don't crash
	MOVAL	COMMLD,R1		;address of device name descriptor
	JSB	IOC$SEARCHDEV		;exec routine to find device
					; see fiche 54 M 9 IOSUBPAGD.LIS
	BLBC	R0,KEXIT		;low bit clear error
	MOVL	R1,R8			;R1 has UCB address of device we want
	MOVL	#SS$_NORMAL,R0		;set normal exit status
KEXIT:	RET				;end of kernel mode code
	.ENTRY	GET_QUE,^M<>		;beginning of kernel mode code
	MOVL	UCB$L_VCB(R8),R9	;get VCB address from UCB
	BEQL	1$			;if equal no VCB
	MOVZBL	VCB$B_QNAMECNT(R9),R7	;queue length
					;MOVC blats R0-R5
	MOVC3	R7,VCB$T_QNAME(R9),QNAME ;save qname
	MOVL	#SS$_NORMAL,R0		;set normal exit status
	RET				;end of kernel mode code
1$:	MOVL	#CLI$_DEVNOTSPL,R0	;set exit status
	RET				;end of kernel mode code
	.END	START			;end of program
