li $s5, 2
add $a0, $s5, $0
li $v0, 4
syscall
Why system out is (null) in spim ?
li $s5, 2
add $a0, $s5, $0
li $v0, 4
syscall
Why system out is (null) in spim ?
Looks like you are trying to print an int, but the system call code you are providing stands for "print string".
As you have no label called 2
(hence no string starting at address of label 2
), the console prints out (null)
.
Try this
li $a0, 2 #integer to be printed
li $v0, 1 #system call code 1: print_int
syscall
Now it should print 2
Check out this table for syscall op codes.