C语言问题,编写一个将C语言 变成 MIPS 汇编程序

望各位帮忙看看,现在就想要答案,蟹蟹各位潜水专家,感谢解答,感谢回答,感谢解答。编写一个 MIPS 汇编程序,相当于这个 C 程序:在原有的基础上完成这个程序,我需要答案,我想要的是直接把代码告诉我

// read numbers until a non-negative number entered
#include <stdio.h>

int main(void) {
    int x;

    while (1) {
        printf("Enter a number: ");

        scanf("%d", &x);

        if (x < 0) {
            printf("Enter a positive number\n");
        } else {
            printf("You entered: %d\n", x);
            break;
        }
    }

    return 0;
}

#  read numbers until a non-negative number entered
# x in $t0
main:
    la   $a0, str0       # printf("Enter a number: ");
    li   $v0, 4
    syscall

    li   $v0, 5          # scanf("%d", &x);
    syscall              #
    move $t0, $v0

    la   $a0, str1       # printf("You entered: ");
    li   $v0, 4
    syscall
    move $a0, $t0        # printf("%d", x);
    li   $v0, 1
    syscall
    li   $a0, '\n'       # printf("%c", '\n');
    li   $v0, 11
    syscall
    li   $v0, 0          # return 0
    jr   $ra

.data
str0:
    .asciiz "Enter a number: "
str1:
    .asciiz "You entered: "

代码示例如下

#  read numbers until a non-negative number entered
# x in $t0
main:
    la   $a0, str0       # printf("Enter a number: ");
    li   $v0, 4
    syscall
    li   $v0, 5          # scanf("%d", &x);
    syscall              #
    bgtz $v0,output
    la   $a0, str2       
    li   $v0, 4
    syscall
     li   $a0, '\n'       # printf("%c", '\n');
    li   $v0, 11
    syscall
   
    b main
    
    
    output:
    move $t0, $v0
    la   $a0, str1       # printf("You entered: ");
    li   $v0, 4
    syscall
    move $a0, $t0        # printf("%d", x);
    li   $v0, 1
    syscall
    li   $a0, '\n'       # printf("%c", '\n');
    li   $v0, 11
    syscall
    
    end:
    li   $v0, 0          # return 0
    jr   $ra
.data
str0:
    .asciiz "Enter a number: "
str1:
    .asciiz "You entered: "
str2:
    .asciiz "Enter a positive number"

img