# --------------------------------------------------------------------
# personGet.s
#	get update for person object
# Prompts the user for new values for each field in the person object.
# Returns void.
# ..................................................................
# calling sequence:
#	push address of person object
#	call	personGet
#	add 4 to stack pointer
# ..................................................................
# author: David Bozarth - 12 May 2004
# modified 12 May 2004
# ------------------------------------------------------------------
#
	.include "personClass.h"
#
TRUE = 1
FALSE = 0
WORD = 4
#
# Stack frame
stkTop = basePtr		# top-of-stack marker
basePtr = 0
rtnAddr = basePtr + WORD
thisPtr = rtnAddr + WORD	# object base address argument

	.data
strNamePrompt:
	.string "Name <Enter>: "
strStreetPrompt:
	.string "Street <Enter>: "
strCityPrompt:
	.string "City <Enter>: "
strStatePrompt:
	.string "State <Enter>: "
strZipPrompt:
	.string "Zip <Enter>: "
strNewl:
	.string "\n"
		
	.text
	.align	WORD
	.globl	personGet

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

	call	newline
	pushl	$strNamePrompt		# prompt for Name
	call	writeStr
	addl	$WORD, %esp
	movl	thisPtr(%ebp), %ebx	# object base address
	leal	theName(%ebx), %eax	# Name field address
	pushl	$SZ_NAME		# max n_chars
	pushl	%eax			# destination address
	call	readStr
	addl	$(2*WORD), %esp
	
	call	newline
	pushl	$strStreetPrompt	# prompt for Street
	call	writeStr
	addl	$WORD, %esp
	movl	thisPtr(%ebp), %ebx	# object base address
	leal	theStreet(%ebx), %eax	# Street field
	pushl	$SZ_STREET		# max n_chars
	pushl	%eax			# destination address
	call	readStr
	addl	$(2*WORD), %esp

	call	newline
	pushl	$strCityPrompt		# prompt for City
	call	writeStr
	addl	$WORD, %esp
	movl	thisPtr(%ebp), %ebx	# object base address
	leal	theCity(%ebx), %eax	# City field
	pushl	$SZ_CITY		# max n_chars
	pushl	%eax			# destination address
	call	readStr
	addl	$(2*WORD), %esp
	
	call	newline
	pushl	$strStatePrompt		# prompt for State
	call	writeStr
	addl	$WORD, %esp
	movl	thisPtr(%ebp), %ebx	# object base address
	leal	theState(%ebx), %eax	# State field
	pushl	$SZ_STATE		# max n_chars
	pushl	%eax			# destination address
	call	readStr
	addl	$(2*WORD), %esp
	
	call	newline
	pushl	$strZipPrompt		# prompt for Zip
	call	writeStr
	addl	$WORD, %esp
	movl	thisPtr(%ebp), %ebx	# object base address
	leal	theZip(%ebx), %eax	# Zip field
	pushl	$SZ_ZIP			# max n_chars
	pushl	%eax			# destination address
	call	readStr
	addl	$(2*WORD), %esp
		
allDone:
	call	newline
	movl	%ecx, %eax		# return number of integers stored
	popl	%ecx			# restore registers
	popl	%ebx
	movl	%ebp, %esp		# restore stack pointer
	popl	%ebp			# restore caller's base pointer
	ret
