MIPS - 程序集计数下降但进入无限循环

MIPS - Assembly count goes down but goes into infinite loop

我正在尝试从用户输入的数字开始倒计时,并希望显示该数字和 0 之间的所有整数。我相信我的输出会下降,但随后会变成无穷大在 1 循环。它似乎永远不会达到零。

我刚开始学习汇编,所以如果这是一个糟糕的问题,我会提前道歉。

谢谢

这是我的代码:

.globl  main

.data
    msg: .asciiz "Input a number: "
    x: .word 1

    .text
main:

    li  $v0,4       # display the first message
    la  $a0, msg
    syscall 

    li  $v0, 5      # call for an input read, stores in $v0
    syscall

    move    $t0, $v0    # move the input to a temporary register
    lw  $t1, x          # loads x into $t1 registers

# Show Output
doLoop:
    sub $v0, $t0, $t1   # subtracts 1 from given input stores in $v0

    move $s0, $v0

    li $v0, 1       # Prepares to print integer
    move $a0, $v0
    syscall

    bgt $a0, 0, doLoop

    li  $v0,10      # load the "exit" number into register $v0
    syscall 

这似乎对我有用,我总是搞砸我在寄存器中放置常量的地方。因此每次我尝试打印寄存器时都包含一个 1。

doLoop: 

sub     $t2, $t0, $t1   # subtracts 1 from given input stores in $v0

li  $v0, 1      
move    $a0, $t2    # Places answer in $a0
la  $v0, 1
syscall

move    $t0, $t2    
bgt $a0, 0, doLoop

li  $v0,10      # load the "exit" number into register $v0
syscall