Hennessy-Patterson

CS 2731 Computer Organization II -- Spring 2003
Laboratory 1 [Jan 13, 15]: Introduction to the Sun Laboratory

Laboratory 1 is an introduction to the CS Systems Laboratory, to the Sun unix system, and to the mechanics of assembling programs. The CS Systems Laboratory is located in room 3.02.04 SB. The first course laboratory will meet in the official lab classroom (HSS 2.02.20 on Mondays and BB 3.02.24 on Wednesdays) for administrative purposes, but otherwise the lab will meet in 3.02.04 SB except for quizzes, which will be given in HSS 3.02.24 during class.

Because this class is so large, there is not room in the lab for everyone at once. For this reason, you are not required to be in the lab at the official lab times. You can also download the MIPS simulator software (which also runs on other Unix flavors such as Linux and Mac OS X, as well as (gulp!) Xxxrosoft Zzzindows) and do much of the work at home, if that is more convenient.

  1. CS Sun accounts are now supposed to be assigned automatically at the beginning of the semester. If you are new, an account should be created for you. If you end up with no account on the CS Sun network, get an account form just inside the lab door, fill it out, sign it, and leave it in the CS Department Office.

  2. You will be getting familiar with the Unix environment during this course. This first lab starts this process. You could use some Unix reference book, such as the old CS 1713 text: UNIX SYSTEM V A Practical Guide, by M. Sobell.

  3. You should become familiar with the following UNIX features:

    If you are a new user, you may want to download a sample C shell initialization file: sample .cshrc, which you could use as your .cshrc

  4. If you do not already have a personal homepage, you should set one up by following these directions. You should create a homepage at UTSA as described above, but this page can just have a link to your "real" homepage. You may use UTSA as the main location for your email. Even if you do your email at a separate location, you should also set up things at UTSA so that mail to your UTSA email account is forwarded to your "real" email address.

  5. We will be using the MIPS simulator xspim to run our MIPS assembly language. Documentation for this simulator can be found in your textbook and online in Postscript or PDF.

  6. Appendix A of your text gives very good documentation for the MIPS assembly language (although maybe more detail than you want), and it is available online in Appendix A (PDF).

  7. Create a directory cs2734 in your home directory, with a subdirectory lab1 (or use other names if you wish).

  8. Download the MIPS assembly language test program fact.s into your ~/cs2734/lab1 directory. (You can just select the contents of this web page and copy it into your own file named fact.s.) This is a sophisticated MIPS program which you are not expected to understand at this point.

  9. Run the simulator on fact.s by typing:

        pandora% spim -file fact.s
    

    (You should type 4 (carriage return) at the prompt; then the program will calculate and print 4! or 24.)

    Next use the xwindows (interactive) version of spim, by typing:

        pandora% xspim -file fact.s
    

    When the simulator comes up, you can click on run to execute the entire program. After clicking on ok, you will get the same prompt in a new window as before. After entering 4 followed by Return, the program will respond with 24 just as before. Finally click on quit (twice). It is more interesting and useful to execute one instruction at a time: after invoking xspim, click on step instead of run. In the small prompt window, you should keep clicking on step to execute one MIPS instruction at a time.

    After 4 steps, you will next execute the instruction jal 0x0040020 [main], followed by the first actual instruction of the fact.s program: addu $s7, $zero, $ra, which appears as addu $23, $0, $31 in the xspim window.

    Continue stepping. When you execute the first syscall MIPS instruction, a window with an Enter n: prompt will appear. After executing the next syscall type 4 and Return as before. Then after over 66 more steps, the program will eventually respond with the value 24 and then a newline. (You must enter the 4 and return immediately after stepping through the second syscall instruction.)


To get checked off in this laboratory:


Revision date: 2002-12-20. (Please use ISO 8601, the International Standard.)