        .code
        .import _mFdynload,code
        .export &mFNAME,entry
&mFNAME
	.proc
	.callinfo calls, save_rp, frame=16, args_saved
	.entry
	std	%rp, -16(%sp)		; Save RP
	ldo	96(%sp), %sp	; Create us a stack
	std	%r27, -88(%sp)		; Save GP
	std	%r29, -96(%sp)		; Save AP
	; Save the arguments (like we said we would).
	std	%arg0, -64(%r29)
	std	%arg1, -56(%r29)
	std	%arg2, -48(%r29)
	std	%arg3, -40(%r29)
	std	%r22, -32(%r29)
	std	%r21, -24(%r29)
	std	%r20, -16(%r29)
	std	%r19, -8(%r29)
	;
	; See if the _mFdynload addr is zero. If it is, we need to call off to
	; _mFdynload to locate the module so we can call it.
	;
	; The copy from r31 to arg3 will only occur if branch NOT taken
	addil	lt'D.&mFNAME, %r27
 	ldd	rt'D.&mFNAME(%r1), %r31
 	ldd	0(%r31), %ret0
        combf,=,n	 %ret0, %r0, T.&mFNAME
 	copy	%r31, %arg3	
	;
	; Build up the arguments for _mFdynload
	;
	addil   lt'L.&mFNAME,%r27
	ldd     rt'L.&mFNAME(%r1),%arg0
	addil   lt'S.&mFNAME,%r27
	ldd     rt'S.&mFNAME(%r1),%arg1
	addil   lt'PL.&mFNAME,%r27
	ldd     rt'PL.&mFNAME(%r1),%r1
	ldd	0(%r1), %arg2
	ldi	&mFflag, %r22
	;
	; Make call to _mFdynload
	;
	b,l	_mFdynload, %rp
	ldo	-16(%sp), %r29
	; ... and back
	ldd	-88(%sp), %r27		; Restore GP
	ldd	-96(%sp), %r29		; Restore AP
	; Restore the original register arguments
	ldd	-64(%r29), %arg0
	ldd	-56(%r29), %arg1
	ldd	-48(%r29), %arg2
	ldd	-40(%r29), %arg3
	ldd	-32(%r29), %r22
	ldd	-24(%r29), %r21
	ldd	-16(%r29), %r20
	ldd	-8(%r29), %r19
T.&mFNAME
	;
	; Destroy our stack frame and jump off to the desired entrypoint
	; so that it appears like we never existed to the caller & callee
	; 
	ldd	16(%ret0), %r1
	ldd	24(%ret0), %r27
	ldd	-96-16(%sp), %rp
	bve	(%r1)
	.exit
	ldo	-96(%sp), %sp
	.procend
        .data
	.align 8
D.&mFNAME
	.dword	0
PL.&mFNAME
	.dword	P'&mFNAME
S.&mFNAME
        .stringz        "&mFNAME"
L.&mFNAME
        .stringz        "&mFNAM2"
	.global
