Mips Output syscall

2019-09-04 08:21发布

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

Why system out is (null) in spim ?

1条回答
Lonely孤独者°
2楼-- · 2019-09-04 08:58

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.

查看更多
登录 后发表回答