MC48 Lab 1: Introduction to Assembly Language Programming (Fall 1996)

Due: October 8, 1996

The goal of this lab is to get familiar with the xspim or NeXTspim simulator, try out some of the simple programs we've been writing in class, and write and test a couple more programs of your own. In this lab, we'll steer clear of fancy things like recursion and other uses of memory; that's what the next lab is for.

Your lab write up can be short and sweet, but it should be English. You should communicate everything you did at some level of detail, but for the uninteresting parts, you can summarize in broad outline, while for the more interesting parts, you can go into detail. Specific details I will expect to see are the two programs you are asked to write, and test data and results from those two programs. Make sure your testing is systematic and thorough. Thorough doesn't mean using large quantities of weird numbers that still only test the same cases; rather, it means using carefully chosen tests to ensure that all cases are covered and all likely bugs exposed, while still allowing the answers to easily be hand-checked. You can do this lab on either a an SGI (in OHS 326) or a PC or NeXT (in OHS 329). If you use a NeXT, you will use the NeXTspim simulator, located in the /LocalApps directory. It is similar enough to the xspim simulator described in the book (though in some ways better, in others worse) and similar enough to other NeXTstep applications, that you should be able to figure it out; let me know if not. If you use an SGI or PC, then you will use xspim, as described in the book. The simplest way to get at it on an SGI is probably to use the ``Find an icon'' menu item to find the xspim icon, then drag it onto your desktop; thereafter you can just double-click it to run it. On a PC, or for that matter on an SGI, you can also just type xspim in a shell window. Let me know if you have troubles with this or other SGI/X-windows user interface stuff.

Start by stepping through simple programs, like one to add two numbers or the one from class for calculating the absolute value of a number. This part of the lab is to make sure you are comfortable with SPIM.

Now you have two programs to write and test and debug (if necessary). You can do these in whichever order seems more natural for you.

  1. (This is exercise A.n1, and should be referred to as such in your questionnaire responses.)

    Write and test using SPIM an adding machine program which repeatedly reads in integers and adds them into a running sum. It should stop when it gets an input that is 0, printing out the sum at that point. Use the SPIM system calls described on pages A-45 and A-46.

  2. (This is essentially exercise A.n2, and should be referred to as such in your questionnaire responses.)

    Write and test using SPIM a program that reads in three integers and prints out the sum of the largest two of the three. Use the SPIM system calls described on pages A-45 and A-46. You can break ties arbitrarily.

    Do not add all three numbers and then subtract off the smallest, since that might fail if the addition of all three overflowed the range of numbers representable in 32 bits. However, you may none the less find it useful to think about identifying which one number is the smallest, rather than about identifying which two numbers are the largest.

Instructor: Max Hailperin