|
| Initilization code; this is common to both 16 and 32 bit libraries,
| so be careful!
|
	.globl	__app		| short, declared in crtinit.c
	.globl	__base		| BASEPAGE *, declared in crtinit.c
	.globl	__heapbase	| void *
	.globl	__stksize	| long, declared by user or in stack.c

|
| Assumption: basepage is passed in a0 for accessories; for programs
| a0 is always 0.

	.text
	.even
	.globl	__start
__start:
	subl	a6, a6		| clear a6 for debuggers
	cmpw	#0, a0		| test if acc or program
	beq	__startprg	| if a program, go elsewhere
	tstl	a0@(36)		| also test parent basepage pointer
	bne	__startprg	| for acc's, it must be 0
	movel	a0, __base	| acc basepage is in A0
	movel	__heapbase, sp	| stack must be set from heap
	addl	__stksize, sp
	jmp	__acc_main	| function is in crtinit.c
|
| program startup code: doesn't actually do much, other than push
| the basepage onto the stack and call _start1 in crtinit.c
|
__startprg:
	movel	sp@(4), a0	| get basepage
	movel	a0, __base	| save it
	movel	a0@(4), d0	| get _base->p_hitpa
	andl	#0xfffffffe, d0	| round off
	movel	d0, sp		| set stack (temporarily)
	jmp	__crtinit	| in crtinit.c

|
| _setstack: changes the stack pointer; called as
|     void setstack( void *newsp )
| called from crtinit.c once the new stack size has been decided upon
|
| WARNING WARNING WARNING: after you do this, local variables may no longer
| be accessible!
| destroys a0 and a7

	.globl	__setstack
__setstack:
	movel	sp@+, a0	| save return address
	movel	sp@+, sp	| new stack pointer
	jmp	a0@		| back to caller

|
| interfaces for gprof: for crt0.s, does nothing, but for gcrt0.s branches
| to the appropriate subroutines
|
	.globl 	__monstartup
	.globl	__moncontrol
	.globl 	___mcleanup
__monstartup:
__moncontrol:
___mcleanup:
	rts
