h47156
s 00040/00000/00000
d D 1.1 82/08/03 08:40:56 cecily 1 0
e
u
U
t
T
I 1
	title	unix c library -- runtime initialization

.exit	equ	1

	extrn	main
	extrn	exit
	entry	_exit
	entry	environ
r0	equ	0
r1	equ	1
sp	equ	7
rf	equ	15
	pure
* rearrange args on stack & call main routine
	sis	sp,2*adc
	lda	r0,2*adc(sp)
	sta	r0,0(sp)
	la	r1,3*adc(sp)
	sta	r1,adc(sp)
envlp	equ	*
	lda	r0,0(r1)
	bz	fndenv
	ais	r1,adc
	b	envlp
fndenv	equ	*
	ais	r1,adc
	sta	r1,2*adc(sp)	clobber orig argc
	sta	r1,environ
	bal	rf,main
* if main routine returns, exit
	sta	r0,0(sp)
	bal	rf,exit
*
_exit	equ	*
	lda	r0,0(sp)
	svc	0,.exit

	bss
environ	das	1
	end
E 1
