MIPS 程序:检查数字是否为素数

MIPS program: check if number is prime

.data 
    userInput: .asciiz "give an integer to check if prime: "
    prime: .asciiz "Prime"
    notPrime: .asciiz "No prime"
.text
    main:
        li $v0, 4
        la $a0, userInput
        syscall
    
    li $v0, 5
    syscall
    move $t0, $v0
    
    addi $t1, $t1, 1
    addi $t2, $t2, 2
    ble $t0, $t1, no
    beq $t0, $t2, yes
    div $t0, $t2
    mflo $s0
    mfhi $s1
    bgt $s1, $zero, yes
yes:
    li $v0, 4
    la $a0, prime
    syscall
    j exit
no:
    li $v0, 4
    la $a0, notPrime
    syscall
    j exit
exit:
    li $v0, 10
    syscall

出于某种原因,程序总是跳转到“是”,即使有余数 (mfhi),我似乎找不到它为什么这样做的问题。当我给出输入 4 时,它应该跳转到“否”标签,因为余数为 0,所以它不大于常量 0。

你想用这部分代码完成什么:

    bgt $s1, $zero, yes
yes:

玩电脑,如果 gt 为真,gt 为假,则决定去哪里。