由于程序计数器无效而崩溃

Crash due to invalid program counter

所以我的问题是如何修复此错误。是我程序的结构吗?或者我是如何使用寄存器的?

#JTWILKI - Just The Way I Like It Cooking Assistant 
# Created By: Samuel Buzas
#For CS2028 Sect.002
.data
    preface: .asciiz "Place you Steak in the oven, and kick back. I'll take care of the rest! \n"
    RED: .asciiz    "Steaks Not Ready Yet Come Back Soon! \n"
    YELLOW: .asciiz "Get Ready to Eat!! \n"
    GREEN:  .asciiz "Were Ready to Go!!! \n Get The Steak Out Now, Before it Burns!\n"
    BROWN: .asciiz "Quick It's Starting to Burn!! \n Take it Out!!! \n"
    BLACK: .asciiz "So how about Soup? \n"

.text
main:
# Tell User the program is starting
    li $v0, 4   
    la $a0, preface
    syscall
# Pause for 10 seconds while users places steak in oven, handy MARS Feature
    li $v0, 32
    la $a0, 10000
    syscall
#Display message,Start Cooking
    j red

    addi $s1, $zero, 150000  # Tihs is 2 min 30seconds
    addi $s0, $zero, 0

    #Start The cooking Loop
    jal loop

loop: beq $s1,$s0,exit  # Exit if t9 == t1
    bge $s0, 120000, yellow  # If 30secs from being ready, print yellow warning
    #Otherwise, Increment
    addi $s0, $zero, 1000
    #Pause for 1 sec
    #li $v0, 32
    #la $a0, 1000
    #syscall
    j loop

exit:
#Display message, Cooking complete
    jal green
#Wait 30 Seconds, then overcooking
    li $v0, 32
    la $a0, 30000
    syscall
#Now overcooked
    jal brown
#Wait another 30 seconds
    li $v0, 32
    la $a0, 30000
    syscall
# Now its burned
    jal black

# Terminate Program
    li $v0, 10
    syscall
#Progress Update Functions
red:
    li $v0, 4
    la $a0, RED
    syscall
    jr $ra

yellow:
    li $v0, 4
    la $a0, YELLOW
    syscall
    jr $ra

green:
    li $v0, 4
    la $a0, GREEN
    syscall
    jal beep
    jr $ra

brown:
    li $v0, 4
    la $a0, BROWN
    syscall
    jr $ra

black:
    li $v0, 4
    la $a0, BLACK
    syscall
    jr $ra

beep:
    li $v0, 31
    li $a0, 112
    li $a1, 2000
    li $a2, 10
    li $a3, 100
    syscall
    jr $ra

我认为问题是你没有将你的跳跃链接到红色。

将第 23 行的 j red 更改为 jal red

在第 34 行将 addi $t0, $zero, 1000 更改为 addi $t0, $t0, 1000 以将 1000 添加到 $t0 并存储它。