I keep getting the error "Error in : invalid program counter value: 0x00000000

Go: execution terminated with errors." when running my program

  .data
output: .asciiz "Result: "
    .text
    .globl main

print_int:
    li $v0, 1
    syscall
    li $v0, 4
    la $a0, output
    syscall
    jr $ra

Myfun:
    # Prologue
    addi $sp, $sp, -4
    sw $ra, 0($sp)

    # Check if N > 3
    ble $a0, 3, else_case

    # N > 3, calculate Myfun(N-2)
    addi $a0, $a0, -2
    jal Myfun
    move $v0, $v0
    j exit

else_case:
    # N <= 3, return 0
    li $v0, 0
    j exit

exit:
    # Epilogue
    lw $ra, 0($sp)
    addi $sp, $sp, 4
    jr $ra

main:
    # Prompt user for input
    li $v0, 4
    la $a0, output
    syscall

    # Get user input
    li $v0, 5
    syscall
    move $a0, $v0

    # Call Myfun(N)
    jal Myfun

    # Print the result
    jal print_int

    # Exit
    li $v0, 10
    syscall

Does anyone know why I keep getting this error, and how to fix it? I cant even enter the input value

I tried creating a exit case specific for the else case to reset the stack but I keep getting the same error

0

There are 0 best solutions below