Hi,

I need some help on completing my little project I'm doing to enhance my skills a little bit. My program is to read in an amount transaction and add the amounts together. If the amount added together exceeds the nth bit, then an overflow occurs. Below is my code for what I've done so far:

Code:
#####################################

	.data			# Data declaration section

Head: 	.ascii	"\n\tThis program"

	.ascii	" can be used to balance your check book."

	.asciiz	"\n\n\t\t\t\t\t\t\t\t\t  Balance"

tabs:	.asciiz	"\t\t\t\t\t\t\t\t\t"

tran:	.asciiz	"\nTransaction:"

error:	.asciiz	"Overflow Occurred  Last Transaction Ignored"	#### Overflow message

bye:	.asciiz	"\n  ****  Adios Amigo  **** "



	.text			# Executable code follows

main:

	li	$v0, 4		# system call code for print_string

	la	$a0, Head		# load address of Header message into $a0

	syscall			# print the Header



	move	$s0, $zero		# Set Bank Balance to zero

loop:

	li	$v0, 4		# system call code for print_string

	la	$a0, tran		# load address of prompt into $a0

	syscall			# print the prompt message



	li	$v0, 5		# system call code for read_integer

	syscall			# reads the amount of  Transaction into $v0



	beqz	$v0, done		# If $v0 equals zero, branch to done

	addu $s0, $s0, $v0	# add transaction amount to the Balance



	li	$v0, 4		# system call code for print_string

	la	$a0, tabs		# load address of tabs into $a0

	syscall			# used to space over to the Balance column

	

	li	$v0, 1		# system call code for print_integer

	move	$a0, $s0		# move Bank Balance value to $a0 

	syscall			# print Bank Balance

	b 	loop		# branch to loop



done:	li	$v0, 4		# system call code for print_string

	la	$a0, bye		# load address of msg. into $a0

	syscall			# print the string



	li	$v0, 10		# terminate program run and

	syscall			# return control to system



				# END OF PROGRAM

Last edited by shabbir; 4Sep2007 at 08:22.. Reason: Code block - http://www.go4expert.com/forums/misc.php?do=bbcode#code