我尝试将以下代码加载到winMIOS64中,但是过程失败了,因为它在第2行给了我一个错误,可以帮我识别问题,是否应该更改其他指令?? !!
.data
m1:.asciiz "enter the total number of digits"
m2:.asciiz "enter total number of digits"
m3:.asciiz "entered number:"
m4:.asciiz "sum of product:"
m5:.asciiz "not an armstrong number"
.text
main:
addi.d $sp,$sp,-20
sd $ra,0($sp)
sd $a0,4($sp)
sd $a1,8($sp)
sd $a2,12($sp)
sd $a3,16($sp)
jal start
start: ld $a0,0($sp) #restore a0 from stack
ld $a1,4($sp)
ld $a2,8($sp)
ld $a3,12($sp)
ld $ra,16($sp)
addi.d $sp,$sp,20 #restore stack pointer
jr $ra #return to calling routing
halt
以下是代码未下载时对话框中出现的错误:
1。第一个对话框说:传递1 - 第2行错误
2. 第二个对话框说:在第1遍检测到错误
答案 0 :(得分:1)
该错误可能是错位的地址。
您正试图在第2行存储双字:
sd $ra, 0($sp)
但是你没有传递一个双字对齐的地址(8
的倍数)。
因为你要存储双字,所以每个字应该相隔8
个字节,你应该在堆栈中为40
个寄存器分配5
个字节而不仅仅是20
个字节。 }:
addi.d $sp, $sp, -40