; fxCG_STARTUP is designed to provide for a header, 
; which informs the Upload'n'Run-function about the start-address
; 27.02.2011
;;;;;;;;;;;;;;;;;;;;;;;;;;
	.SECTION B,DATA,ALIGN=4
	.SECTION D,DATA,ALIGN=4
	.SECTION R,DATA,ALIGN=4
	
	.SECTION P_TOP,CODE,ALIGN=4
	.import _G3A_main
	.export _R_BGN
	.export _D_ROM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; see SHC Manual.PDF Rev. 1.0, 08/00, page 162 of 890
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
entry:	
	mov.l	r14, @-r15
	sts.l	pr, @-r15
	add		#-4, r15
	mov.l	r4, @r15
	
	mov.l	#InitializeRAM, r2
	jsr		@r2
	mov		r5, r14
	
	mov.l	#G3A_Setup, r2
	mov		#1, r6
	mov		#0, r4
	jsr		@r2
	mov		r6, r5
	
	mov.l	#_G3A_main, r2
	extu.w	r14, r5
	mov.l	@r15, r4
	
	add		#4, r15
	lds.l	@r15+, pr
	jmp		@r2
	mov.l	@r15+, r14
	
G3A_Setup:
	mov.l	#h'80020070, r2
	jmp		@r2
	mov		#h'29, r0
	
InitializeRAM:
	mov.l	#_B_BGN, r7
	mov		#0, r6
	mov.l	#_B_END, r4
	bra		l1
	mov.l	@r7, r2
l0:	
	mov.l	r6, @r2
	add		#4, r2
l1:	
	mov.l	@r4, r5
	cmp/hs	r5, r2
	bf		l0
	mov.l	#_R_BGN, r1
	mov.l	#_D_ROM, r4
	mov.l	@r1, r6
	mov.l	#_R_END, r1
	bra		l2
	mov.l	@r4, r5
l3:
	mov.l	@r5+, r2
	mov.l	r2, @r6
	add		#4, r6
l2:	
	mov.l	@r1, r4
	cmp/hs	r4, r6
	bf		l3

	mov.l	#h'08100000, r1
	mov.l	@r7, r5
	sub		r5, r4
	add		#4, r4
	rts
	mov.l	r4, @r1
	
	.align 4
_B_BGN .DATA.L (STARTOF B)
_B_END .DATA.L (STARTOF B) + (SIZEOF B)
_R_BGN .DATA.L (STARTOF R)
_R_END .DATA.L (STARTOF R) + (SIZEOF R)
_D_ROM .DATA.L (STARTOF D)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	.end