
# entry point code for N64

# macro to zero a section for initialising bss areas
# assumes the section is a multiple of 4 bytes long
# the parameter (sec) must have been declared in a section statement

// Wolff sez:	  oy, what a mess. 
// Any code that's commented out shouldn't be;  it's there to
	// get it to build. 

#include <asm.h>
#include <regdef.h>
#include <R4300.h>

	.text 
zerosect:	
#	macro	sec
#	local	l1,l2

#	la	t0,sect(\sec)
#	la	t1,sectend(\sec)
	beq	t0,t1,l2	# in case section is empty
	nop
l1:
	addiu	t0,t0,4
#	sltu	at,t0,t1
#	bne	at,zero,l1
	sw	zero,-4(t0)
l2:
#	endm


# 4k header area for front of cartridge

#	.header
#	dcb	4096,0


# declaration of sections were going to initialise to 0

#	.bss

# start up code

#	xref	boot

#	.start

#	la	sp,$80400000-(16+256)	# initialise stack pointer
					# LEAVE 256 BYTES FOR STORAGE ACROSS RESETS!

#	zerosect  .bss	# clear out .bss section

	jal	boot	# go execute users program
	nop

#	break	$402	# just in case it returns
	break	0	# just in case it returns


