I am having trouble writing a delay loop that will return a constant 0x80000. The output should be like Hello, world! 0 Hello, world! 1 Hello, world! 2 ... but when I run my program, the terminal doesn't show anything even though I believe one Hello, world! should be showing up. I tried to figure out what is wrong by debugging the code, but that does not seem to be helping me. Any suggestions on how to fix this?
.ent getDelay
.text
.global getDelay
getDelay:
addi $sp, $sp, -1
sw $ra, 0($sp)
la $a0, helloStr
lw $a1, counter
jal printf
nop
lw $ra, 0($sp)
addi $sp, $sp, -1
lw $t0, ($a1)
addiu $t0, $t0,1
la $t1, counter
sw $t1, ($a1)
$v0 = 0x80000
jr $ra
.end getDelay
.data
helloStr: .asciiz "Hello, world %d\n"
counter: .word 100
$spin multiples of 4 (the word size). You should useaddiu $sp, $sp, -4andaddiu $sp, $sp, 4.$t0but then storing$t1. You don't need thela $t1, counterand instead ofsw $t1, ($a1)you should usesw $t0, ($a1).$v0 = 0x80000is not an instruction, you probably wantli $v0, 0x80000.