MIPS过程调用失败

MIPS过程调用失败,mips,Mips,我正在为一门课做作业,我应该找到一个数n的和0-n(例如:和5=1+2+3+4+5)。我们在前面的任务中已经这样做了,现在的任务是在前面的解决方案中实现函数调用add2(intnum1,intnum2)。当我将我的解决方案加载到QtSpim中时,我得到一个错误,表示该行存在语法错误 move $s1, $v1 # Store returned sum in $s1 当我试图单步执行该程序时,我得到一个错误,说我的Add2过程没有定义。我已经尝试将我的过程移动到

我正在为一门课做作业,我应该找到一个数n的和0-n(例如:和5=1+2+3+4+5)。我们在前面的任务中已经这样做了,现在的任务是在前面的解决方案中实现函数调用add2(intnum1,intnum2)。当我将我的解决方案加载到QtSpim中时,我得到一个错误,表示该行存在语法错误

move  $s1, $v1                 # Store returned sum in $s1
当我试图单步执行该程序时,我得到一个错误,说我的Add2过程没有定义。我已经尝试将我的过程移动到程序的顶部以修复此错误(必须使用my.data节执行此操作才能从中加载任何内容),但这没有起到任何作用。我不太确定我做错了什么。这是我的密码:

.data
msg1:   .asciiz "Please enter a value for n: \n"
msg2:   .asciiz "The sum from 1 to "
msg3:   .asciiz " is:  "
newline:    .asciiz "\n"

.text

.globl main

main:
    # Print string msg1
    li    $v0, 4                  # print_string syscall code = 4
    la    $a0, msg1               # Load msg1 into arg register
    syscall

    # Get and store n value from user
    li    $v0, 5                  # read_int syscall code = 5
    syscall
    move  $s0, $v0                # Move syscall results to saved register
    li    $s1, 0                  # $s1 value keeps total
    li    $s2, 1                  # $s2 = 1 used to increment loop

    LOOP:
    move  $a1, $s1                 # Load current sum into $a1
    move  $a2, $s2                 # Load current counter into $a1
    jal Add2                      # Add both and return in $v1 and $v2
    move  $s1, $v1                 # Store returned sum in $s1
    move  $s2, $v2                 # Store incremented counter in $s2
    bne $s0, $v2, LOOP            # If $v2 not equal to n value branch to loop
    add $s1, $s1, $s0             # Add final value to $s1

    # Print final message and total

    # First half of message
    li    $v0, 4                  # print_string syscall code = 4
    la    $a0, msg2               # Load msg2 into $a0
    syscall

    # Print n value
    li    $v0, 1                  # print_int syscall code = 1
    move    $a0, $s0              # Move $s0 into $a0
    syscall

    # Second half of message
    li    $v0, 4                  # print_string syscall code = 4
    la    $a0, msg3               # Load msg3 into $a0
    syscall

    # Print total
    li    $v0, 1                  # print_int syscall code = 1
    move    $a0, $t0              # Move total in $t0 to $a0
    syscall

    li    $v0, 10                 # exit syscall code = 10
    syscall

    # Add2 function
    Add2:
    add $v1, $a1, $a2            # Add $a1 and $a2 and save in $v1
    addi $v2, $a2, 1             # Increment $a2 by one and store in $v2
    jr $ra

对我来说,QtSpim抱怨的第一行实际上是
move$s2,$v2

MIPS处理器上没有
$v2
寄存器,因此您必须找到其他寄存器来替代它