;*************************** AMUS Program Label ******************************
; Filename: DEVICE.M68                                      Date: 10/16/89
; Category: SUB          Hash Code: 524-035-610-365      Version: 
; Initials:              Name: JALAL RAISSI
; Company:                                         Telephone #: 
; Related Files: XCALL.M68[100,133]
; Min. Op. Sys.:                               Expertise Level: BEG
; Special: Must get a copy of XCALL.M68 for this to work
; Description: Get a list of devices on current system
; 
; 
;*****************************************************************************
;DEVICE.M68		
;
; Author.............. 	Jalal Raissi
; Last Date Modified.. 	06/23/87
; Reason for Change... 	Write Up
;
; Purpose.............	Gives a list of all mounted devices on the system.
;
;	XCALL DEVICE,DEVICES(1),MOUNTED
;
; Where:
;	MAP1 DEVICES(20),S,6
;	MAP1 MOUNTED,B,1
;

	SEARCH	SYS
	SEARCH	SYSSYM
	SEARCH	TRM
	COPY	XCALL
	
VMAJOR=1.
VMINOR=1.
VSUB=0.
VEDIT=0.
VWHO=0.

DEFINE	DEPACK	ADDR
	IF	NB,ADDR,LEA A1,ADDR
	MOV	XC.AD1(A3),A2
	ADD	D2,A2
	UNPACK
	ENDM

DEFINE	BITW	SRC,DST
	MOVW	DST,D7
	ANDW	SRC,D7
	ENDM

	.OFINI
	.OFDEF	DV.LNK,4		;link to next device entry
	.OFDEF	DV.FLG,2		;flags--.
		DV$LOG=10		; logical unit
		DV$SHR=1000		; shareable device
		DV$MNT=10000		; mounted
	.OFDEF	DV.DEV,2		;device code RAD50
	.OFDEF	DV.DRV,2		;drive number RAD50
	.OFSIZ	DV.SIZ

	OBJNAM	.SBR
	
	PHDR	-1,PV$RSM,PH$REE!PH$REU
	
	JOBIDX
	CLR	D5
	MOVW	JOBTYP(A6),D5
	ANDW	#^CJ.HEX,JOBTYP(A6)

	CMPW	XC.ARG(A3),#2		
	JNE	ERROR

	CMPW	XC.TY1(A3),#XC$STR
	JNE	ERROR
	CMP	XC.SZ1(A3),#6
	JNE	ERROR

	CMPW	XC.TY2(A3),#XC$BIN
	JNE	ERROR
	CMP	XC.SZ2(A3),#1
	JNE	ERROR

	CLR	D2
	CLR	D4
	
	MOV	DEVTBL,A4		;point A4 to first DEVTBL entry
LOOP:
	BITW	#DV$MNT,DV.FLG(A4)	;is device mounted?
	BEQ	NO 			; no
	DEPACK	DV.DEV(A4)
	CLR	D1
	MOVW	DV.DRV(A4),D1
	DCVT	0,OT$MEM
	MOVB	#58.,@A2		; :
	INC	D4
NO:
	MOV	DV.LNK(A4),D0		;get link to next device entry
	BEQ	ENDOFF			;branch on zero (end of table)
	MOV	D0,A4			;set new address into A4
	ADD	#6,D2
	BR	LOOP			;and continue processing
ENDOFF:
	ADD	D2,A2
	CLR	@A2
	MOV	XC.AD2(A3),A2
	MOVB	D4,@A2
	JOBIDX
	MOVW	D5,JOBTYP(A6)
	RTN
ERROR:
	TYPECR	?Parameter Error in DEVICE.SBR
	RTN

	END