	.title	r$guic - get uic associated with open file
;+
;	jsr	pc,r$guic
;
;	inputs:
;		r1	FDB address of open file
;
;	outputs:
;		r0	binary UIC value
;		c bit	set if error
;		c bit	clear is success
;		all other registers are maintained across the call
;-
	.mcall	qiow$s
	.psect	$r.roi,con,ro,rel,lcl,i
	.enabl	lsb
r$guic::
	jsr	r5,.savr1		; save all regs but r0
	clr	-(sp)			; make space for UIC
	mov	sp,r4			; save address
	clr	-(sp)			; end of attribute list
	mov	r4,-(sp)		; address of buffer to receive UIC
	mov	(pc)+,-(sp)		; read UIC
	.byte	-1,2
	mov	sp,r3			; address of control block
	movb	f.lun(r1),r2		; lun
	add	#f.fnb+n.did,r1		; address of DID
	qiow$s	#io.rat,r2,r$ioef,,#r$iosb,,<r1,r3>	; read UIC
	bcs	30$			; c set => error
	tstb	r$iosb			; check for error
	blt	30$			; YES
	mov	(r4),r0			; place UIC value in r0
	clc				; c clear => success
	br	40$
30$:
	sec				; c bit set => failure
40$:
	rol	r1			; save c bit in r1
	add	#10,sp			; restore stack
	ror	r1			; restore c bit
	return
	.end
