post #1 of 1
Thread Starter 
Hey guys, the program is about done, I am just having an issue with getting the value of $v0 to be put into the array "intarray" each time it loops through.

The program asks for 5 integers via a loop. I need to set the integers into the intarray at each of the 5 spots. I don't understand how to do this in MIPS.

I am also trying to get the final value of $t1 into the variable "total", but I think that requires the same thing as intarray. The printing of these arrays would be good to know too.

Thanks for your help.

Here is the code:
Code:
.data
intarray: .word -1, -1, -1, -1, -1
total: .word 0
result: .asciiz  "Enter a series of 5 integers, one per line: "
thetot: .asciiz "Your total is: "
.text
main:
li $v0, 4 #call to print string
la $a0, result #print string from location
syscall

li $t0, 0 #set $t0 = i = 0
li $t1, 0 #set $t1 = tot = 0
la $t2, intarray #puts the address of intarray into $t2
loop:
        li $v0, 5 #system call code to accept integer
        syscall
        add $t1, $t1, $v0 #moves integer to $t0
        add $t0, $t0, 1
blt $t0, 5, loop #end loop if i<5

li $v0, 4
la $a0, thetot
syscall
li $v0, 1
la $a0, ($t1)
syscall


li $v0, 10 #exits program
syscall