我是学习MIPS汇编代码的新手,我们得到了第一份编码作业。运行程序时出现错误(应该是我们必须编写的另一个函数的测试器),说
“spim :(解析器)标签是在文件/home/jlr247/215_A2_work/jlr247-a2-A.s的第13行上第二次定义的
主要的:
^”
我的代码是:
.data
.align 4
_arrA: .space 400
_arrB: .space 400
.text
main:
la $t0, _arrA #load base address of array A
la $t1, _arrB #load base address of array B
addi $t2, $zero, 0 #$t2 = i = 0
FILL_LOOP: #initializes all A[] values to 5, all B[] values to 10
slti $t3, $t2, 100 #check i<100
beq $t3, $zero, LOOP_DONE #end loop when i=100
sll $t3, $t3, 2 #multiply shift by 4
add $t4, $t3, $t0 #$t4 = address of A[i]
add $t5, $t3, $t1 #$t5 = address of B[i]
addi $t6, $zero, 5
sw $t6, 0($t4) #A[i] = 5
addi $t6, $zero, 10
sw $t6, 0($t5) #B[i] = 10
j FILL_LOOP
LOOP_DONE:
li $v0, 1 #get ready to print test values for A[0], A[396]
lw $a1, 0($t1)
lw $a2, 396($t1)
syscall #should print 55
li $v0, 1 #get ready to print test values for B[0], B[396]
lw $a1, 0($t2)
lw $a2, 396($t2)
syscall #should print 1010
EXIT:
有任何想法吗?我敢肯定,这只是我尚未设法学习的基础知识和显而易见的知识。谢谢!
最佳答案
"spim: (parser) Label is defined for the second time on line 13 of file /home/jlr247/215_A2_work/jlr247-a2-A.s main: ^"
如果两次使用“加载文件”命令而未在其间重新初始化模拟器,则可能发生这种情况。
为了避免这种情况,请使用“Simulator”->“Reinitialize Simulator”,然后使用“File”->“Load File”,或使用“File”->“Reinitialize and Load File”。
关于assembly - 为什么QtSPIM告诉我 “Label is defined for the second time”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31393822/