gpt4 book ai didi

mips - 尝试在 mips 汇编程序中执行非指令?

转载 作者:行者123 更新时间:2023-12-05 08:58:50 29 4
gpt4 key购买 nike

    .data
stack: .word 3, 2
.text
.globl main
main:
la $s1, stack #assign stack start memory to $s1
addi $t3, $t3, 0 #clear $t3
addi $t3, $t3, 4 #assign 4 to $t3
add $s1, $s1, $t3 #second member of stack
lw $t1, 0($s1) #d2
addi $t3, $t3, -4 #move $t3 forward
add $s1, $s1, $t3 #first member of stack
lw $t0, 0($s1) #d1
add $t0, $t0, $t1 #d1 = d1 +d2
sw $t0, 0($s1) #store new d1 at d1's location

我正在尝试创建一个 mips 程序,它获取堆栈的 last-1 和 last 成员,添加它们并存储它。我不关心 addi $t3, $t3, 4 或 stack: .word 3, 2 它只是为了测试。

但是,当我在 qtspim 上运行它时,我收到一条错误消息“试图在 0x0040004c 处执行非指令”,请告知我问题出在哪里。

最佳答案

您需要使用 jr $ra 结束您的程序,否则处理器将继续执行 sw $t0, 0($s1) 之后发生的任何随机指令

关于mips - 尝试在 mips 汇编程序中执行非指令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20172655/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com