# --------------------------------------------------------------------
# bankDisplay.s
#	Send the contents of a bank object to standard output.
# Returns void.
# ....................................................................
# calling sequence:
#	push base_address of bank object
#	call	bankDisplay
#	add 4 to stack pointer
# ....................................................................
# author: David Bozarth - 12 May 2004
# modified 12 May 2004
# --------------------------------------------------------------------
#
	.include "bankClass.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	# bank_object_base_address argument
	
	.data
strNewl:
	.string "\n"
strSpace:
	.string " "
strTab:	
	.string "\t"
strComma:
	.string ","
strDollar:
	.string "$"
		
	.text
	.align	WORD
	.globl	bankDisplay

bankDisplay:
	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)
	
	movl	thisPtr(%ebp), %ebx	# base address of bank object
	leal	theId(%ebx), %eax
	pushl	%eax			# Account_ID field address
	call	writeStr
	addl	$WORD, %esp
	call	newline

	pushl	$strDollar
	call	writeStr
	addl	$WORD, %esp
	pushl	$strSpace
	call	writeStr
	addl	$WORD, %esp
	
	pushl	theBal(%ebx)		# int account_bal to standard output
	call	putDec
	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
