ECE 3055: SPIM Examples

Some SPIM Examples

Some simple SPIM
programs for common functions.

Program

Description

Accessing memory

Reading and writing the data segment

I/O operations

Console I/O

Byte manipulation

Manipulating bytes
from/to the data segment

Constant creation

Constructing a
32-bit constant

Logical operations

Performing bit-wise
logical operations

Iteration example-1

Simple counting for
loop

Iteration example-2

Accessing elements
of an array

Byte access and simple arithmetic

Computing the sum
of bytes in a word

Conditional
statement

If-then-else
construct

Matrix multiplication

More complex
example of iterations, procedure calls and arithmetic

Procedure
Call

Simple procedure
call

 

An additional set of procedures and SPIM programs dealing arithmetic,
procedure calls, and floating point numbers can be found below (Unable
to determine the source for proper attribution but they are quite
helpful).

 

Program

Description

Floating Point Mean

Arithmetic Mean of a single precision floating point array.

Print Vector

Print a vector

Print Vector (Double)

Print a vector of doubles

Mean of double Precision Numbers

Compute the Mean of Double Precision Numbers

Floating Point Example

Working with Floating Point Numbers

Unsigned Multiply

Unsigned Multiply

Vector Multiply

Unsigned element-buy-element multiply

Division

Example of division

Multiply-Divide

Mutiply-Divide Example

Vector Product

Cumulative Product

Print Vector (Floats)

Print Vector of Floats