loops - mips array not printing -


main: la $t3 array loop:  la $a0, msg1 #output message li $v0, 4 syscall li $v0, 5 #read in user input syscall move $t0, $v0 beq  $t0, -99, endloop beq  $t1,20,endloop #get user input 20 times   addi $t1, $t1, 1 sw $t0,($t3) addi $t3,$t3,4  b loop #loop until reaches 20   endloop: li $v0,4 la $a0, msg2 syscall li $v0, 1  move $a0, $t1 syscall li $v0, 4 la $a0, newline syscall li $t5, 0 #t1 counter  #t3 array address printloop: beq $t5, $t1, printend lw $a0,4($t3) li $v0, 1 syscall addi $t5, $t5, 1 addi $t3, $t3, 4 j printloop printend:  

} before move adding array value trying make sure when user enters values being stored array. dont know if being stores because when print printing zeros. can tell me if array loop wrong or print loop. thanks,

pretty simple problem here.

before printloop you've forgotten reload starting address of array $t3.

add la $t3 array before printloop label.

also, don't know why you're loading @ 4 offset: lw $a0,4($t3). use 0 offset instead: lw $a0,0($t3).


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -