/*
	A initialization code for get a address isolation BSS section,
	StackPoint and buffer start address.
				MICETEK International Inc, Shanghai,2001
*/

	.extern	DoMain
	
/* .text is used instead of .section .text so it works with arm-aout too.  */
	.text
	.code 32
	.align 	0

	.global	_start
_start:
	mov v1, pc		     /* Qin: */
	sub v1, v1, #8       /* Qin: get the current PC */

    /* Start by setting up a stack */
	/* Set up the stack pointer to end of bss */
	ldr	r3, .LC2
	sub r3, v1, #0x2000  /* Qin: get the offseted SP */
	mov sp, r3
	sub	sl, sp, #512	 /* Still assumes 512 bytes below sl */

	mov a2, #0		     /* Second arg: fill value */
	mov	fp, a2		     /* Null frame pointer */
	mov r7, a2

	ldr	a1, .LC1	     /* First arg: start of memory block */
	ldr	a2, .LC2	     /* Second arg: end of memory block */
	sub	a3, a2, a1	     /* Third arg: length of block */

	sub a1,v1,#0x9000    /* Qin: get memory address as Para-buffer*/

 /*	mov	r0, #0		     /*  no arguments  */
 /*	mov	r1, #0		     /*  no argv either */

	bl	DoMain
	bl	_start

	/* For Thumb, constants must be after the code since only
	   positive offsets are supported for PC relative addresses.
	 */
	.align 0
.LC1:
	.word	__bss_start__
.LC2:
	.word	__bss_end__

