	# startup glue for IBM RT running BSD

	.globl	.oVncs
	.globl	_prog_edata
	.globl	_close
	.globl	_.close
	.globl	_read
	.globl	_.read
	.globl	_unlink
	.globl	_.unlink

zero:
entry:	.long	0		# address of real start code
_prog_edata:
	.long	0

	.text	2
_close:	.long	_.close
	.text
_.close:
	ls	r0,0(r1)
	svc	6(r0)
	br	r15

	.text	2
_unlink:
	.long	_.unlink
	.text
_.unlink:
	lcs	r0,0(r2)
	svc	10(r0)
	bntbr	r15
	brx	r15
	cal	r2,-1(r0)

	.text	2
	.align	2
_read:	.long	_.read
	.text
_.read:	lcs	r0,0(r3)
	svc	3(r0)
	bntbr	r15
	brx	r15
	cal	r2,-1(r0)

	.globl	start
start:
	j	0f
	.short	1
	.long	1
	.long	0		# replaced with value from executable
0:
	mr	r6,r0
	stm	r2,-56(sp)
	balix	r7,1f
	cal	r7,zero-1f(r7)
1:
	.using	zero,r7
	ls	r6,entry
	get	r0,$_decode(r7)
	get	r2,$0x10000000
	ls	r3,_prog_edata
	balix	r15,_.decode
	cal	sp,-56(sp)
	mr	r0,r6
	lm	r2,0(sp)
	cal	sp,56(sp)
	brx	r0
	mr	r0,r6
