# --------------------------------------------------------------------
# personDisplay.s
#	Send the contents of a person object to standard output.
# Returns void.
# ....................................................................
# calling sequence:
#	push base_address of person object
#	call	personDisplay
#	add 4 to stack pointer
# ....................................................................
# author: David Bozarth - 12 May 2004
# modified 12 May 2004
# --------------------------------------------------------------------
#
	.include "personClass.h"
#
WORD = 4
#
# Stack frame
stkTop = strSep				# top-of-stack marker	
strSep = basePtr - WORD		# base address of delimiter string
basePtr = 0
rtnAddr = basePtr + WORD
thisPtr = rtnAddr + WORD	# person_object_base_address argument
	
	.data
strNewl:
	.string "\n"
strSpace:
	.string " "
strTab:	
	.string "\t"
strComma:
	.string ","
		
	.text
	.align	WORD
	.globl	personDisplay

personDisplay:
	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

	# designate separator here
	#movl	$strNewl, %ebx		# address of constant separator
	movl	$strSpace, %ebx		# address of constant separator
	movl	%ebx, strSep(%ebp)
	
#	xorl	%ecx, %ecx		# reset counter
	movl	thisPtr(%ebp), %ebx	# array base address
	leal	theName(%ebx), %eax
	pushl	%eax			# Name field address
	call	writeStr
	addl	$WORD, %esp
	call	newline
	
	leal	theStreet(%ebx), %eax
	pushl	%eax			# Street field address
	call	writeStr
	addl	$WORD, %esp
	call	newline
	
	leal	theCity(%ebx), %eax
	pushl	%eax			# City field address
	call	writeStr
	addl	$WORD, %esp
	#call	newline
	pushl	$strComma
	call	writeStr
	addl	$WORD, %esp
	pushl	$strSpace
	call	writeStr
	addl	$WORD, %esp
		
	leal	theState(%ebx), %eax
	pushl	%eax			# State field address
	call	writeStr
	addl	$WORD, %esp
	#call	newline
	pushl	$strSpace
	call	writeStr
	addl	$WORD, %esp
	
	leal	theZip(%ebx), %eax
	pushl	%eax			# Zip field address
	call	writeStr
	addl	$WORD, %esp
	call	newline

allDone:
	#movl	%ecx, %eax		# return number of ints displayed
	popl	%ecx			# restore registers
	popl	%ebx
	movl	%ebp, %esp		# restore stack pointer
	popl	%ebp			# restore caller's base pointer
	ret
