Useful SPIM Examples
SPIM
SPIM manual
SPIM's homepage
Download SPIM:
Local SPIM
SPIM FTP site
Exrecise examples
Basic program to print "The Answer = " and a number
Basic program to print the numbers between 1 to 100
C++ program to compute the factorial of a read number
Assembler program to compute the factorial of a read number
Local examples
Basic program to compute sum of squares from 1 to 4
Same program, but correct...
Here, we first save some IMPORTANT registers on the stack (such as the address from where we were called),
and so, after doing whatsoever, we can jump back to that address.
Another variation of the same stuff.
Here we use the memory commands "load-word" & "store-word" to save some data, instead in registers.
Last variation, here we ask for an integer (n),
and compute sum of squars from 1 to n
A recursive program to compute factorial(n)
Strlen(string)
Other SPIM examples:
Find maximum in a list
Find number of positive and negative integers in a list
Use of switch for selection
General use of syscalls
Simple. Add integers in a loop. 0 stops
Simple. sum squars from 0 to 100
Calulate 100!
Compute the sum of two vectors.
bubble sort