1
li $s5, 2
add $a0, $s5, $0
li $v0, 4
syscall

Why system out is (null) in spim ?

Stack Player
  • 1,470
  • 2
  • 18
  • 32
Yanh Huan
  • 153
  • 2
  • 3
  • 6

1 Answers1

3

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.

Tom
  • 43,810
  • 29
  • 138
  • 169