Lab 2 - Assembling MIPS code on Helios

The software installed on Helios is MIPS Technologies SDE (Software Development Environment) version 6.0. This differs from the SPIM and SDELite software available on the book CD. All code turned in for the class should assemble using SDE. You may use SPIM or SDELite at home if you cannot access Helios remotely, but confirm that the code also works on Helios using SDE before turning it in.

Setting up SDE

Follow these instructions to set up your PATH, MANPATH and directory structure for SDE. With respects to the directory structure, it is important that you have a symbolic link called kit to the sde/kit subdirectory is that rooted exactly two directories up from your code. The example/make.mk file assumes that the kit directory is located at ../../kit relative to the directory you are in when you type sde-make. This is what I did to set up my directory structure for this lab:
mkdir cs321
chmod og-rx cs321
cd cs321
mkdir sde
cd sde
cp -r /usr/local/sde/sde/examples .
cp -r /usr/local/sde/sde/kit .
cd ..
ln -s sde/kit
ln -s sde/examples
mkdir lab2
cd lab2
ln -s ../sde/examples/make.mk
mkdir hello
cd hello
ls ../../kit
If the last command does not show you the contents of the kit directory, you do not have the correct directory structure assumed in the make.mk file. If followed as above, you should have the following directory structure:
                                cs321
                         ______/ | | \_____
                        /       /   \      \
                       /       |     |      \
                     lab2     sde   kit   examples
                      |      /    \
                      |     |      |
                    hello  kit  examples
Note: You can locate the sde directory elsewhere in your home directory tree as long as the cs321/kit and cs321/examples symlinks point to the appropriate directories.

Testing SDE with "Hello World" in MIPS assembly

Make sure you are in the cs321/lab2/hello subdirectory. Use the following commands to copy the "Hello World" assembly code to your directory, assemble it and run it. Note that the "hello" program in the SDE examples is a C program while this hello.s program is in MIPS assembly.
cp /usr/users/mdanfor/public_html/cs321-w07/code/hello/* .
sde-make
sde-run helloram
If this is the first time you have seen a MIPS assembly program, refer to Appendix A in the book for more details about the allowed syntax. In brief, the code has two sections, a data section for the "Hello world" string and a text portion containing the code to be executed. The la instruction loads the address into the register, which is most useful for arrays and strings. The li instruction loads a constant into the register. The syscall instruction executes the specified syscall (see page A-44 for the syscall codes).

Assignment

Create another subdirectory off cs321/lab2 called sum and change to that directory. Copy the Makefile from hello and edit it to change all instances of hello to sum. Create an assembly file called sum.s that takes two constants and adds them together.

You can use printf to print the results by adding the following to your .data section:

format:
        .asciiz "The sum is %d\n"
and by adding the following to your .text section:
        la      $a0,format      # Put format string in $a0
        move    $a1,$v0         # Put the sum in $a1, $v0 contains the sum
        jal     printf          # Call the printf function
Email your sum.s file to me before noon on Wednesday.