/
/	SCCS File Type - Emulator Source File
/
/ 	What string
/
.data
<@(#)EM_tcrt0.s	3.3\0>
.even
.text
/ C runtime startoff
/ for KSOS server programs
emt     = 104000^sys
K_relproc = 19.  / K_release_process
	.data
argv:	.=.+64.
	.text

.globl	_exit
.globl  _NKmain
.globl	start
.globl  _edata

start:
	mov     $177776,sp
			/ Zero memory
	mov     sp,r0
1:      clr     -(r0)
	cmp     r0,$_edata
	bge     1b

	sub	(sp),sp
	mov	(sp)+,r0		/ argc
	mov	sp,r1			/ first argument
	mov	$argv,r2		/ address of argv
	mov	r0,r3			/ Remember argc
	blos	3f			/ branch if no args
1:	mov	r1,(r2)+		/ Add entry to argv
	dec	r0			/ Finished yet?
	beq	3f			/ 
2:	tstb	(r1)+			/ Find end of argument
	bne	2b			/ it's terminated by a single null
	br	1b			/ Back for next arg
3:	mov	$-1,(r2)+		/ Stash -1 at end of argv
	mov	$argv,-(sp)		/ Push argv and argc so
	mov	r3,-(sp)		/ they appear in correct place
	jsr     pc,_NKmain              / on entry to main
_exit:
	emt     K_relproc
