As123
As123

Reputation: 11

mips how to print numbers from loop

Here is what I have

      addi $s0, $0, 10

top:  beq $s0, $0, end

      addi $s0, $s0,-1
      addi $v0,$0,1
      addi $a0,$s0,0
      syscall
      j top

end:    

The output is 9876543210 but I want the loop start from 10 to 0 109876543210

Upvotes: 0

Views: 3778

Answers (2)

Jose Perales
Jose Perales

Reputation: 11

move your "counter" to subtract -1 after your syscall. This way you're subtracting your counter after you run the loop.

  ...........
  syscall
  addi $s0, $s0,-1
  j top

Upvotes: 1

Scott Hunter
Scott Hunter

Reputation: 49803

Initialize $s0 to 11 instead of 10.

Upvotes: 1

Related Questions