Getting the error: “Instruction references undefined symbol … main” in QTSpim

纵然是瞬间 提交于 2019-11-26 18:40:10

问题


I'm trying to compute (a * c) - (b / d), and so far my assembly code is:

.data
A: .word 5
B: .word 6
C: .word 3
D: .word 2
.text
lw $t0, A
lw $t1, C 
mul $t0, $t0, $t1 
lw $t1, B
lw $t2, D 
div $t1, $t1, $t2
sub $t0, $t0, $t1
li $v0, 1
move $a0, $t0
syscall
li $v0, 10
syscall

But when I run it, I get the error. I am new to QTSpim and assembly so I would appreciate some help if possible. Thank you!

edit:

the exact error is:

"Instruction references undefined symbol at 0x00400014 [0x00400014] 0x0c000000 jal 0x0000000 [main] ;188: jal main"


回答1:


The default startup code expects your program to have a global label main as its entry point. So you need to add one, e.g.:

# (as before)
.text
.globl main
main:
# (as before)


来源:https://stackoverflow.com/questions/47099284/getting-the-error-instruction-references-undefined-symbol-main-in-qtspim

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!