The program prints "ello SPIM!"
The
read integer service reads an entire line of input from
your keyboard—all the characters you type up to the newline
character.
These characters are expected to be ASCII digits '0', '1', .., '9'
with an optional leading '-' or '+'.
The characters are converted into a 32-bit two's complement representation
of the integer which is returned in $v0
.
li $v0,5 # code 5 == read integer syscall # Invoke the operating system. # Read in one line of ascii characters. # Convert them into a 32-bit integer. # $v0 <-- two's comp. int.
The print integer service prints the
integer represented by the 32 bits in
$a0
to the SPIM terminal.
Of course, there are many ways that the integer can be placed in
$a0
,
not just lw
.
li $v0,1 # code 1 == print integer lw $a0,int # $a0 == the integer syscall # Invoke the operating system. # Convert the 32-bit integer into characters. # Print the character to the monitor.
The print integer prints an integer on the simulated monitor. But what must it do first, before printing?