I'm new to SPIM
and using it to write a mock compiler as a part of compiler design course.
Consider the following program:
.data
string_access_violation: .asciiz "Access Violation"
string_illegal_div_by_0: .asciiz "Division By Zero"
string_invalid_ptr_dref: .asciiz "Invalid Pointer Dereference"
global_c: .word 0
_2_func_name: .asciiz "mul"
_5_func_name: .asciiz "inc"
_8_func_name: .asciiz "foo"
_9_func_name: .asciiz "bar"
_10_func_name: .asciiz "main"
.text
.globl main
func1:
sw $t0, -4($fp)
sw $t1, -8($fp)
sw $t2, -12($fp)
...
mul:
...
func3:
...
main:
jal _0_init_i
jal _1_init_c
addi $sp, $sp, -12
sw $fp, 0($sp)
sw $ra, 4($sp)
I'm getting the following error when trying to run it:
spim: (parser) syntax error on line 86 of file FOLDER_5_OUTPUT/MIPS.txt
mul:
^
The following symbols are undefined:
main
Instruction references undefined symbol at 0x00400014
[0x00400014] 0x0c000000 jal 0x00000000 [main] ; 188: jal main
But main
does exists and declare as global. What am I missing?
EDIT: whole code can be found here.
User contributions licensed under CC BY-SA 3.0