Seriyon 0 Newbie Poster

I have to make a program which takes user inputs until the user enters "-1"
When the user has entered that, it adds up all of the scores that have been entered and outputs the sum.

.data                           # items stored in data segment
        .align 0                        # no automatic alignment

input1:                                
        .asciiz "Enter a set of scores as requested.\n"      
input2:
	.asciiz "Enter the first score: "
input3:
	.asciiz "Enter the next score: "
output:                                
        .asciiz "The sum of the scores is: " 	


        .text                           # items stored in text segment
        .globl main                     # label accessible from other files

main:  
	la 		$a0, input1	# prompt the user for input
	li		$v0, 4		# service code for printing string
	syscall				# perform service

	la		$a0, input2	# prompt the user for input
	li		$v0, 4		# service code for printing string
	syscall				# perform service

					# get the input from user
	li		$v0, 5		# service code for read integer
	syscall				# perform service
	
	move 		$t1, $v0	# save the input to $t1    	



Loop:					
	beq $v0, -1, exit		# while loop - do until input is -1. If input is -1, exit.

	la		$a0, input3	# prompt the user for input
	li		$v0, 4		# service code for printing string
	syscall				# perform service

	
					# get the input from user
	li 		$v0, 5		# service code for read integer
	syscall				# perform service
	
	move		$t2, $v0	# save the input to $t2

	addu 		$t0, $t1, $t2
	
	addu 		$t0, $t0, $t2

	j Loop


exit:
	la		$a0, output
	li		$v0, 4
	syscall

	move		$a0, $t0

	li 		$v0, 1
	syscall

	li              $v0, 10         # service code for exit
        syscall                         # perform service

It takes in the inputs fine, but when it outputs the result, it is not correct, something is wrong with lines 48 and 50 but i am not sure.

I appreciate any help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.