# ------------------------------------------------------------------
# bankClass.s
#	"constructor" for bankClass objects
# not a default constructor
# represents a personal bank account
# returns void
# ..................................................................
# calling sequence:
#	push int starting account balance
#	push address of account ID
#	push address of object
#	call	bankClass	
#	add 12 to stack pointer
# ..................................................................
# author: David Bozarth - 10 May 2004
# modified 12 May 2004
# ------------------------------------------------------------------
#
	.include "bankClass.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
strId	= thisPtr + WORD	# account ID base address
intBal	= strId + WORD		# int starting balance
		
	.text
	.align	WORD
	.globl	bankClass

bankClass:
	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	theId(%ebx), %eax
	pushl	$SZ_ID			# max length of account_ID field
	pushl	%eax			# base address of destination
	pushl	strId(%ebp)		# address of source ID string
	call	copyString
	addl	$(3*WORD), %esp

	leal	theBal(%ebx), %ecx	# address of account_balance field
	movl	intBal(%ebp), %eax	# int balance was passed in
	movl	%eax, (%ecx)		# update account balance	
	
allDone:
	popl	%ebx			# restore registers
	popl	%eax
	movl	%ebp, %esp		# restore stack pointer
	popl	%ebp			# restore caller's base pointer
	ret
