Fall 2000

Lab 3: FIRST MIPS PROGRAM

CS61C

Purpose:

To practice writing and running short MIPS programs. MAKE SURE YOU DO THE PRELAB BEFORE COMMING TO LAB.

Prelab:

    You should be able to answer these from reading pages A-39 to A-48 of Appendix A of COD (including looking at the figures). Have the answers written BEFORE your lab starts.

     

    1. Which  button/command loads the program into memory of SPIM so that it is ready to execute?
    2. Which button/command starts executing the program loaded into memory?
    3. Which button/command lets you set the value of a register from the command console?
    4. Which button/command lets you clear (set to zero) all registers?
    5. What register number (R0, R1 ... R31) correspond to  a) $s1 b) $t0 c) $t7 d) $t8

Introduction:

The "main" function of a MIPS program always begins with the label "__start:" (to the left of the first instruction, note that there are two underscores therE) and ALways ends with the instruction "done". A file containing MIPS code should have the extension ".s" to work properly.

Task:

Write a piece of MIPS code that should take the values in $s0 and put the values $s0*2^i into register $ti, for 0<=i<=7. For example, if $s0 contains the value 3, then after running your code, registers $t0 through $t7 should contain these values:
$t0 = 3	(3*2^0)
$t1 = 6	(3*2^1)
$t2 = 12 (3*2^2)
.
.
.
$t7 = 384 (3*2^7)
Test out your program using XSPIM. Start XSPIM by typing
> xspim 
at the command prompt. Play around with it until you feel comfortable with xspim.

Additional Requirements:

You are only allowed to use the instructions learned in class so far for this assignment.
Do not set the value of $s0 from within your code. Learn how to manually set the register from XSPIM.
For check-off, create a directory named lab3 in your home directory, name the file you wrote exp.s, and place exp.s in the lab3 directory. cd into lab3, and type submit lab3.

Last updated: 9/7

solution