# --------------------------------------------------------------------
# bankTransMulti.s
#	get multiple updates for bank object
# Prompts the user to enter bank account transactions.
# Quits when the user enters "0".
# Returns void.
# ..................................................................
# calling sequence:
#	push address of bank object
#	call	bankTransMulti
#	add 4 to stack pointer
# ..................................................................
# author: David Bozarth - 12 May 2004
# modified 12 May 2004
# ------------------------------------------------------------------
#
	.include "bankClass.h"
#
TRUE = 1
FALSE = 0
NONZERO = TRUE
WORD = 4
#
# Stack frame
stkTop = intVal			# top-of-stack marker
intVal = basePtr - WORD		# value returned by most recent prompt event
basePtr = 0
rtnAddr = basePtr + WORD
thisPtr = rtnAddr + WORD	# object base address argument

	.data
#strPrompt:
#	.string "Transaction amount <-0- to quit> <Enter> : "
#strNewl:
#	.string "\n"
		
	.text
	.align	WORD
	.globl	bankTransMulti

bankTransMulti:
	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
	movl	thisPtr(%ebp), %ebx	# object base address
	movl	$NONZERO, %eax

askLoop:
	cmpl	$0, %eax
	je	allDone

	#leal	theId(%ebx), %eax	# int balance field address
	pushl	%ebx			# bank object address
	call	bankTransact		# prompt for account update
	addl	$WORD, %esp
	movl	%eax, intVal(%ebp)	# save return value
	
	call	newline
	#leal	objBank1(%ebp), %ebx	# address of bank object
	pushl	%ebx			# object address
	call	bankDisplay
	addl	$WORD, %esp

	movl	intVal(%ebp), %eax	# most recent return value
	jmp	askLoop

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
