# ------------------------------------------------------------------
# fillZero.s
#	fills memory with zero from start address to n_bytes
# ..................................................................
# calling sequence:
#	push int n_bytes to fill with zero
#	push starting address
#	call	fillZero	
#	add 8 to stack pointer
# ..................................................................
# author: David Bozarth - 12 May 2004
# modified 12 May 2004
# ------------------------------------------------------------------
#TRUE = 1
#FALSE = 0
WORD = 4
#
# Stack frame
stkTop = basePtr			# top-of-stack marker
#intLoc = basePtr - WORD
basePtr = 0
rtnAddr = basePtr + WORD
ptrStart = rtnAddr + WORD	# array base address argument
intLen = ptrStart + WORD	# number of bytes to fill with zero
	
#	.data
#strMsg:
#	.string ""
	
	.text
	.align	WORD
	.globl	fillZero

fillZero:
	pushl	%ebp			# save caller's base pointer
	movl	%esp, %ebp		# establish our base pointer
	addl	$stkTop, %esp		# allocate local variables
	pushl	%ebx			# save registers
#	pushl	%ecx
#	pushl	%edx
#	movl	$0, intLoc(%ebp)	# initialize local variables

#someLoop:		
#	cmpb	$0, (%eax)		# test for something
#	je	allDone

	#jmp	someLoop


	
	#leal	intList(%ebp), %ebx	
	#movl	$(WORD * LIST), %ecx
	#negl	%ecx
	movl	ptrStart(%ebp), %ebx	# starting address
	movl	intLen(%ebp), %eax	# number of bytes
zeroLoop:
	cmpl	$0, %eax
	je	allDone
	
	movb	$0, (%ebx)
	incl	%ebx			# .. array address
	decl	%eax			# .. array index
	jmp	zeroLoop
	
allDone:
	#movl	$0, %eax		# return value
#	popl	%edx			# restore registers
#	popl	%ecx
	popl	%ebx
	movl	%ebp, %esp		# restore stack pointer
	popl	%ebp			# restore caller's base pointer
	ret
