;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;	Subroutine:	Get_hit
;	Author:		B Ellis
;	Synopsis:	This subroutine obtains and displays
;			the global buffer hit and miss rates
;			for global buffers on a file.
;	Inputs:		4(ap) - the address of the rab for the file
;			8(ap) - the unit for the file (passed by ref)
;
;	Outputs:	Displays the hit and miss rates on the
;			global buffer to sys$output
;
;
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


	.library	/sys$library:lib.mlb/
	.link		/sys$system:sys.stb/
	.link		/sys$system:rmsdef.stb/
	.macro	check	?l
	blbs	r0,l
	$exit_s	r0
l:
	.endm	check
	$impdef		;Impure area offsets
	$fabdef		;File access block offsets
	$rabdef		;Record Access block offsets
hit:	.blkl	1
miss:	.blkl	1
unit:	.blkl	1
out_d:	.long	80
	.address	10$
10$:	.blkb	80

fmt:	.ascid	/Global buffer hits: !10UL   misses: !10UL on unit: !10UL/
	
	.entry	get_hit,^m<>
	clrl	hit			;counters
	clrl	miss			;
	clrl	unit
	movl	#80,out_d
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;	Get into exec mode and the hit and miss counts
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

	$cmexec_s	routin=gbh_hit,arglst=(ap)
	check
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;	Format and spill the info
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	$fao_s	ctrstr=fmt,outbuf=out_d,outlen=out_d,-
		p1=hit,p2=miss,p3=@8(ap)
	check
	pushal	out_d
	calls	#1,g^lib$put_output
	ret


;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;	Exec mode routine to return the hits and misses
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	.entry	gbh_hit,^m<r6,r7>
	movl	4(ap),r6		;get the rab address
	movl	rab$l_fab(r6),r6	;locate the fab
	movzwl	fab$w_ifi(r6),r6	;get the internal file identifier
	moval	g^pio$gw_iioimpa,r7	;get the image impure area address
	movl	imp$l_ifabtbl(r7),r7	;locate the ifab table
	movl	(r7)[r6],r7		;get the internal fab 
	movl	ifb$l_gbh_ptr(r7),r7	;locate the global buffer
	beql	outta_here		;if none scram
	movl	gbh$l_hit(r7),hit	;else return the hits
	movl	gbh$l_miss(r7),miss	;and misses on the global buffer
	movl	#ss$_normal,r0
outta_here:				;Sayonara
	ret
	.end
