	.mcall	.MODULE
	.MODULE	SHOWDU,comment=<Show DU partitions>,release=V09,version=07

;**************************************************************;
;                                                              ;
;   Copyright (c) 1987            Bob Schor                    ;
;                                 Eye and Ear Hospital         ;
;                                 230 Lothrop St.              ;
;                                 Pittsburgh, PA   15213       ;
;                                                              ;
; All rights reserved.  May not be copied without this notice. ;
;                                                              ;
;**************************************************************;

;**************************************************************;
;                                                              ;
;   Copyright (c) 1989            Bob Schor                    ;
;                                 Eye and Ear Institute        ;
;                                 203 Lothrop St.              ;
;                                 Pittsburgh, PA   15213       ;
;                                                              ;
; All rights reserved.  May not be copied without this notice. ;
;                                                              ;
;**************************************************************;

;show current DU MSCP partitions

;b schor	september, 1987

;modifications --
;	sep, 1987	made compatible with new (incompletely-documented)
;			MSCP table structure, new behavior of .SPFUN 372
;	jul, 1989	Psects $CODE and $DATA added


;define our .psects before calling SUMAC to force ours low

	.psect	$code	ro,i,lcl,rel,con
	.psect	$data	rw,d,lcl,rel,con

;uses SUMAC for structured macro code

	.library	/lib:sumac/	;use external macro definition file

	.mcall	SUMAC
	SUMAC				;initialization macro

	.dsabl	gbl			;if undefined symbol, force error


HEAD	sysmac, <system macros>
	.mcall	.PRINT			;to announce identification
	.mcall	.EXIT			;return to RT-11 on errors
	.mcall	.LOOKUP			;to map to DU
	.mcall	.SPFUN			;to get partition map

HEAD	spfun, <SPFUN constants>
	du.sho	=	372		;to get MSCP table


	.psect	$code

LABEL	start, <start of program>
	NOTE
	.PRINT	#modnam			;identify module
	NOTE
	.LOOKUP	#emtarg, #1, #dudblk	;map to DU
	IF	cs
		NOTE	<Lookup failed!>
		.EXIT
	ENDIF
	.SPFUN	#emtarg, #1, #du.sho, #dubuff	;get map
	IF	cs
		NOTE	<SPFUN failed!>
		.EXIT
	ENDIF
	mov	#dubuff, r1
	PUSH	(r1)+			;pass rad50 name
	mov	#du.asc, r4		;set output pointer
	INVOKE	unrad			;translate from rad50 to ascii
	movb	(r1)+, maxun		;get number of units
	dec	maxun			;start numbering with unit 0
	inc	r1			;skip over extra byte
	FOR	r3, #0, maxun
		.PRINT	#du.asc		;print name
		TYP.8	r3
		PNOTE	< -- >
		PNOTE	<MSCP unit >
		TYP.8	(r1)+
		movb	(r1)+, r2
		PNOTE	<   Partition >
		TYP.8	r2
		movb	(r1)+, r2
		PNOTE	<   Port >
		TYP.8	r2
		NOTE
	ENDFOR
	.EXIT

PROCED	unrad, <Translate rad50 to ascii>
;enter with rad50 on stack, ascii pointer in r4
	IF	2(sp), ne		;if not done,
		PUSH	<r2, r3>
		mov	2+4(sp), r3	;get rad50 string
		clr	r2		;set up division
		div	#50, r2		;split off low character
		PUSH	r2		;recurse with quotient
		INVOKE	unrad
		IF	r3, eq		;rad50 space
					;ignore
		ELSE
			IF	r3, le, #32	;A-Z
				add	#'A-1, r3
			ELSIF	r3, lt, 36	;illegals
				mov	#'$, r3
			ELSE			;numeric
				add	#'0-36, r3
			ENDIF
			movb	r3, (r4)+	;save as ascii
			movb	#200, (r4)	;keep asciz
		ENDIF
		POP	<r3, r2>
	ENDIF
	POP	<(sp)>			;discard argument
ENDPROC


	.psect	$data

HEAD	var, <variable storage>
modnam:	.NLCSI				;generates .asciz module string
du.asc:	.asciz	/DU /			;name of MSCP device
	.even
emtarg:	.blkw	10
dudblk:	.rad50	/DU /
	.word	0, 0, 0
maxun:	.word	0			;max unit number
dubuff:	.word	0			;rad50 name
	.byte	0			;units
	.byte	0
	.rept	10
	.word	0			;MSCP unit
	.byte	0			;partition
	.byte	0			;port
	.endr

	ENDEND

	.end	start
