#=======================================================================#
# Project Name:RUPUTER 													#
#  Copyright (c) Seiko Instruments Inc. 1998-1999. All rights reserved.	#
#																		#
#	onHand/Ruputer API Startup Routine 									#
#																		#
#=======================================================================#

	.section	.bss

.include	"address.def"

reg86:
	.fill	12,2,0

	.global		_main
	.global		_InitRupAPI
	.global		_EndRupAPI

	.section	.text
	.global		_start

_start:
	jmp	Startup
	nop
	nop
	nop

	.fill	128,1,0

Startup:

		mov		_edata,a0			# Get the start/end of bss
		mov		_end,a1

		cmp		a0,a1				# If no bss, then do nothing
		beqx	L0

		sub		d0,d0				# clear d0

L1:
		movb	d0,(a0)				# Clear a byte and bump pointer
		add		1,a0
		cmp		a0,a1
		bnex	L1

L0:
		jsr		_InitRupAPI			# Init RupAPI Service
		jsr		_main				# Call main program
		jsr		_EndRupAPI			# End  RupAPI Service

## DOSsystem call
		mov		0x0b18,d0
		mov		0x0001,d1

## INTSYS	D0						# DOS call
		add		-4,a3				#
		mov		a2,(0, a3)			#
		mov		A_SWINTENT,a2		#
		jsr		(a2)				#

		mov		reg86,a0
		mov		0x4c,d0				# func 4c
		movb	d0,(1,a0)			#

		mov		20,d0				#
## INTSYS	D0						# DOScall
		add		-4, a3				#
		mov		a2, (0, a3)			#
		mov		A_SWINTENT, a2		#
		jsr		(a2)				#

## END

		.section ._stack
_stack: .long	1

