I want to write a program using loops that prints the asterisk character '*' five times, so I wrote this:
.data
ast: .word '*'
.text
.globl main
main:
la $a0, ast
add $t0, $zero, $zero #counter
loop:
slti $t1, $t0, 5
beq $t1, $zero, exit
li $v0, 1
syscall
addiu $t0, $t0, 1
j loop
exit:
li $v0, 10
syscall
but instead of printing five asterisks, it gives me this huge number: 268500992268500992268500992268500992268500992
By running step by step I see that $t0 that I use for the counter has the correct value for each loop (1 to the 2 to the 3 to the 4 to the 5). With the slti and beq lines I try to control the loops till the counter reaches the number 5.
What is it missing?