MIPS架构下不使用J-Type指令如何保存程序计数器地址

How to save program counter address without using J-Type instructions in MIPS architecture

我必须在不使用 J-Type 指令的情况下将 jal 指令实现为伪指令。我可以用 jr 实现它,但我知道 jal 将当前 PC+8 存储在 $ra 中。我该如何实施?我如何在没有J类型的情况下将PC地址存储在ra中?

试试这个:

    la  $ra, ret    # load return address (pseudo instruction!)
    j   dest        # call the function
    nop             # delay slot
ret:                # return here
    ...

dest:               # destination function
    ...
    jr  $ra