EnexoOnoma
EnexoOnoma

Reputation: 8836

Basic MIPS explanation

I am new to MIPS and I am working with the QtSpim.

On my first example the console prints 5.

li $a0, 5
li $v0, 1
syscall

In this example it will print hello

str: .asciiz "hello"

li $v0, 4
la $a0, str
syscall

When I changed the 1 to 4 on example 1 I didn't get the 5 as a result.
When I changed the 4 to 1 on example 2 I didn't get the hello as a result.

What is the purpose of 1 in

li $v0, 1

and what is the purpose of 4 in

li $v0, 4

Thank you!

Upvotes: 0

Views: 1423

Answers (1)

Vincenzo Maggio
Vincenzo Maggio

Reputation: 3869

syscall call a different function depending on the value in $v0: 1 for print-int, 4 for print-string. They print the value stored with li (load immediate) instruction in $a0. Refer to a tutorial on MIPS for further information.

Upvotes: 4

Related Questions