Assembly Mips错误。指令引用0x00400024[0x00400024]0x3c010000 lui$1,0[word]处的未定义符号;8:la$t0,字
这是我的Mips代码 但是当我运行它时,我得到了错误。我是QTSpim和assembly的新手,如果可能的话,我将非常感谢您的帮助。谢谢大家! 错误代码:指令引用0x00400024处未定义的符号Assembly Mips错误。指令引用0x00400024[0x00400024]0x3c010000 lui$1,0[word]处的未定义符号;8:la$t0,字,assembly,mips,Assembly,Mips,这是我的Mips代码 但是当我运行它时,我得到了错误。我是QTSpim和assembly的新手,如果可能的话,我将非常感谢您的帮助。谢谢大家! 错误代码:指令引用0x00400024处未定义的符号 [0x00400024]0x3c010000路易$1,0[字];8:la$t0,word是一个未定义的标签,但它不是在汇编时抱怨,而是将这些指令标记为错误,如果您试图执行这些指令,它会在运行时传递该错误 就QtSPIM而言,这不是非常友好的行为 而且,实际的处理器在运行时不会发出这样的错误,而是会给您
[0x00400024]0x3c010000路易$1,0[字];8:la$t0,word是一个未定义的标签,但它不是在汇编时抱怨,而是将这些指令标记为错误,如果您试图执行这些指令,它会在运行时传递该错误 就QtSPIM而言,这不是非常友好的行为
而且,实际的处理器在运行时不会发出这样的错误,而是会给您一个空地址或其他东西,让您的程序在尝试使用该空地址时崩溃。谢谢!但是我不知道如何修复它。你能给我一个提示吗?在某个地方定义标签
word
,或者,引用一个已经定义的标签。很抱歉,我不知道如何定义标签词。我该怎么做?您不必定义标签word
,您可以使用已定义的标签。如果你不知道标签是什么,你应该研究一下。
#include <stdio.h>
int main() {
int i, min, min2 = 0;
int arr[ 10 ] = {7,93,37,43,53,79,57,82,2,85};
min = min2 = arr[ 0 ];
for( i = 0; i < 10; i++ ) {
if( min2 > arr[ i ] ) {
if( min > arr[ i ] ) {
min2 = min;
min = arr[ i ];
}
else {
min2 = arr[ i ];
}
}
}
printf( " %d", min2 );
return 0;
}
.data
digit: .word 7, 93, 37, 43, 53, 79, 57, 82
str:.asciiz"Second smallest number is"
.text
main:
la $t0, word
lw $s0, 0($t0) #Sets Min1 to first value in array
move $s1, $s0 #Sets Min2 to first value in array
addi $t1, $0, 0 #Sets the counter to 0
li $t1, 0 #Index for the array
addi $s2, $s2, 10
loop:
bge $t0, 9 EndLoop
bgt $t1, $s1, Else
bgt $t1, $s0, Else2
move $s2, $s1
move $s1, $t1
addi $t1, $t1, 4 #Increases the index for the array
addi $t0, $t0, 1 #Increments the counter
Else2:
move $s2, $t1
addi $t1, $t1, 4 #Increases the index for the array
addi $t0, $t0, 1 #Increments the counter
j loop
Else:
j loop
EndLoop:
li $v0, 1
la $a0, str
syscall
j EndLoop2
EndLoop2:
li $v0, 1
addi $a0, $s1, 0
.end