Laboratory

Up

Whats New
Class Info
Calendar
Lecture
Laboratory
Homework
TA Corner
FAQ

CS-30 Laboratory 
(Computer Science is a lab science)

Turn in Lab Reports in class. Also, Email programs as attachments to

    cs30 @ whizbangscholar.com

 

Workarounds

1. In some programs using the label newlin may lead to unexpected behavior. The symptoms are printing graphic characters instead of the expected newline. Problem may also be in the exact characters used for the double quote in a data statement. In isolation, the problem does not occur (Program 3). Changing the label from newlin appears to fix the problem.


 
Put your name and lab number in the subject line
   example:          Jones Lab3

 

Due dates are on Calendar Page

  1. Lab 0    System familiarization (see below)

  2. Lab 1    System familiarization
    A continuation of getting familiar with the SPIM System. SPIM isn't hard, it's just that the interface doesn't have much bling.

  3. Lab 2    Square Root 
    This lab has you computing square roots the way your grandparents did at the dawn of the computer age.  A clever and surprisingly simple algorithm.

  4. Lab 3    Letter Counter
    Getting more comfortable with SPIM we can try some more difficult assignments. This one has us read a line of input from the keyboard and then dissect it.

  5. Lab 4    Cosine
    Some functions like trancendentals are often programmed in assembly for speed.  The algorithm used here is not particularly fast but gives you a feel for programming such functions in assembler.

  6. Lab 5   Conversion to hex.
    By using the shift function it is easy to convert a string of bits to hexadecimal.

  7. Lab 6    Recursion
                Note: Calculate Fibonacci for n = 1, 10 and 100
  8. Lab 7    Simple Plot
                A simple plotter method: Simple Plotter

 

Program 0

The first assignment is to get familiar with the mechanics of using the SPIM programming system. SPIM is installed in the computers in the Instructional Computers Lab.

The SPIM home site is:

http://www.cs.wisc.edu/~larus/spim.html 

You can get a copy to run under Windows from the above site. Pick the executable that runs under Windows (It is in a zip file). 

Link to the Companion Site contains additional information about the CD,  links to software updates and solutions to the "For More Practice" exercises. It also contains links to the course pages of other schools using the book.

Appendix A of  the book is on the enclosed CD.  It contains a description of assembly language and has the best description of the SPIM assembly language around.  If you don't have the CD and are desperate, Google cod-appa.pdf and you will likely find a copy from the second edition of the book. 

Your assignment is to use the program to run a sample program, (for example):

#----------------------------------------------

# Adds numbers from 0 to N and prints result
      .data           # Data section of 
numb: .word  10       # Value of N
      .text           # Code section
main: lw  $a1, numb   # Load the value of N from 
                      #  the label numb into $a1
                     
#  (decrementing number variable)
      move $a0,$zero 
# Set $a0 equal to $zero
loop: add $a0,$a0,$a1 # Add counter variable $a0 
                      # and number $a1
      addi $a1,-1     # Subtract 1 from $a1
      bgtz $a1,loop   # Branch back to the 
                      # beginning of the loop
                       # if $a1 is greater than $zero
      li   $v0,1      # Set up system call for 
                      #    printing integer
      syscall         # Print to screen

 

You don’t have to understand the program, just get familiar with the steps to get it to run. 

Turn in a screen shot of your program running.  Use the print screen key to put an image of the screen on the clipboard. Then paste it into a word document.  Only a single sheet is required.