Reputation: 1
I got the following message after trying to run my code:
The following symbols are undefined:
printf
Here is part of what my code looks like:
main__loser:
.asciiz "You lose!"
(...)
main__body:
jal whole_grid
nop
jal direction
nop
sw $v0,24($fp)
lw $a0,24($fp)
jal update_snake
nop
bne $v0,$zero,main__body
nop
la $v0,length
lw $v1,0($v0)
li $v0,3 # 0x3
bne $v0,$zero,main__epilogue
div $zero,$v1,$v0
break 7
mfhi $v0
mflo $v0
sw $v0,28($fp)
lw $a1,28($fp)
la $a0, main__loser
jal printf
nop
move $v0,$zero
main__epilogue:
(...)
Does anyone know what it means by the error that I have not defined the symbol printf
?
Upvotes: 0
Views: 697
Reputation: 18493
Does anyone know what it means by the error that I have not defined the symbol
printf
?
A typical program consists of multiple files.
The function printf
that you call in the following line of code:
jal printf
... is defined in another assembler (or C) source file.
Typically, such functions are defined in a "library" file that contains pre-compiled assembler and C code.
The error:
You compiled your program without adding this "library" file to your project.
If you cannot use the library file (for example you don't have a library file that is suitable for your CPU or OS), you cannot use printf
but you must write the message directly to the OS (or even to the hardware).
Upvotes: 1