# ------------------------------------------------------------------
# personClass.s
#	"constructor" for personClass objects
# default constructor
# represents a bank customer
# returns void
# ..................................................................
# calling sequence:
#	push address of allocated struct personClass
#	call	personClass
#	add 4 to stack pointer
# ..................................................................
# author: David Bozarth - 10 May 2004
# modified 12 May 2004
# ------------------------------------------------------------------
#
	.include "personClass.h"
#
	.data
strName:
	.string "Good Customer"
strStreet:	
	.string "123 Fourth Street"
strCity:	
	.string "State College"
strState:	
	.string "PA"
strZip:
	.string "12345"	
#
# constants
#MAX_NAME = theStreet - theName
#MAX_STREET = theCity - theStreet
#MAX_CITY = theState - theCity
#MAX_STATE = theZip - theState
#MAX_ZIP = personSize - theZip
TRUE = 1
FALSE = 0
WORD = 4
#
# Stack frame
stkTop = basePtr		# top-of-stack marker
#intLoc = basePtr - WORD
basePtr = 0
rtnAddr = basePtr + WORD
thisPtr = rtnAddr + WORD	# object base address argument *** must have
		
	.text
	.align	WORD
	.globl	personClass

personClass:
	pushl	%ebp			# save caller's base pointer
	movl	%esp, %ebp		# establish our base pointer
	addl	$stkTop, %esp		# allocate local variables
	pushl	%eax			# save registers
	pushl	%ebx

	movl	thisPtr(%ebp), %ebx	# base address of object
	leal	theName(%ebx), %eax
	pushl	$SZ_NAME		# max length of name field
	pushl	%eax			# base address of destination
	pushl	$strName		# base address of default customer name
	call	copyString
	addl	$(3*WORD), %esp
#**********
#jmp allDone
#**********
	leal	theStreet(%ebx), %eax
	pushl	$SZ_STREET		# max length of street field
	pushl	%eax			# base address of destination
	pushl	$strStreet		# base address of default street
	call	copyString
	addl	$(3*WORD), %esp

	
	leal	theCity(%ebx), %eax
	pushl	$SZ_CITY		# max length of city field
	pushl	%eax			# base address of destination
	pushl	$strCity		# base address of default city
	call	copyString
	addl	$(3*WORD), %esp

	leal	theState(%ebx), %eax
	pushl	$SZ_STATE		# max length of state field
	pushl	%eax			# base address of destination
	pushl	$strState		# base address of default state
	call	copyString
	addl	$(3*WORD), %esp

	leal	theZip(%ebx), %eax
	pushl	$SZ_ZIP			# max length of postal-code field
	pushl	%eax			# base address of destination
	pushl	$strZip			# base address of default postal-code
	call	copyString
	addl	$(3*WORD), %esp

allDone:
	popl	%ebx			# restore registers
	popl	%eax
	movl	%ebp, %esp		# restore stack pointer
	popl	%ebp			# restore caller's base pointer
	ret
