h15802
s 00037/00000/00000
d D 1.1 82/08/03 08:40:50 cecily 1 0
e
u
U
t
T
I 1
* mcount -- count subroutine calls during profiling

* called at function entry (after the save sequence) by
*	la	r1,LABEL
*	bal	rf,mcount
* where LABEL is a word in the bss segment pointing to the function's
* entry in the count buffer
* each count buffer entry is two words: a pointer to the function entry
* point (actually pointing after the 'bal' to mcount, and initialized
* at the first call of mcount), and the count of calls

	entry	mcount
r0	equ	0
r1	equ	1
r2	equ	2
rf	equ	15

countbase comn		next available count buffer entry
	das	1
	ends

mcount	equ	*
	l	r2,0(r1)	pointer to count buffer entry
	bnz	mc1		skip if already initialized
	l	r2,countbase
	bzr	rf		no buffer - give up
	lr	r0,r2
	ais	r0,8		allocate buffer entry for this function
	st	r0,countbase
	st	rf,0(r2)	set back pointer to function
	ais	r2,4
	st	r2,0(r1)	set forward pointer to count buffer entry
mc1	equ	*
	lis	r0,1
	am	r0,0(r2)
	br	rf
	end
E 1
