When I run this code,There is an error in the main and it does not operate normally.
I changed the main function or thought there was a problem with the main and global main, so I repeated the correction several times.
.data
message: .asciiz " The final result is "
.text
.global main
main:
addi $a0, $zero, 3
addi $a1, $zero, 10
addi $a2, $zero, 15
addi $a3, $zero, 7
jal leaf_example
li $v0, 4
la $a0, message
syscall
li $v0, 1
syscall
leaf_example:
addi $sp, $sp,-12
sw $t1, 8
sw $t0, 4
sw $s0, 0
add $t0,$a0,$a1
add $t1,$a2,$a3
sub $s0,$t0,$t1
add $v0,$s0,$zero
lw $s0,0
lw $t0,4
lw $t1,8
addi $sp,$sp,12
jr $ra
spim: (parser) syntax error on line 4 of file C:/Users/user/Desktop/qtspim16.asm .global main ^
User contributions licensed under CC BY-SA 3.0