Machine Problem 1, due Feb 11

Part of the homework for 22C:60 (CS:2630), Spring 2013
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Note: The Getting Started handout has been updated with web links to the various web pages on how to access the departmental Linux servers from your own Mac, Linux or Windows machines, including the new issues connected with crossing the campus firewall now that access to the default SSH port has been blocked.

Getting ready: First, get access to the departmental Linux machines and follow the instructions in the Getting Started handout. Do not read beyond this point until you have installed the smal, link and hawk commands. To verify that these work, type the following shell commands (typed input shown in boldface):

[name@servXX ~]$ smal
** no input file specified **
[name@servXX ~]$ link
link requires parameters
link -help is available
[name@servXX ~]$ hawk

The last commmand above will erase the screen and display half a screenful of material. In mid-screen, there will be a line saying:


**HALTED** r(run) s(step) q(quit) ?(help)

The above line is a help menu, showing some of the active commands. Merely seeing this menu shows that you have the Hawk command installed, so type the q command. You are now ready to begin working on the machine problem.

Get the program: Machine problem I involves editing a small program, so your first job is to get a copy of that code. The code is here:

http://homepage.cs.uiowa.edu/~dwjones/assem/hw/mp1.txt

Web browsers let you save the source for a web page by using an eccentric click on the link (the details depend on the browser). Or, you can copy and paste from the web browser into a text editor. Your goal is to create a file named mp1.a that contains the text of the above material from the web.

Try the program! Assemble it, link it, and run it using the following sequence of commands (typed input shown in boldface):

[name@servXX ~]$ smal mp1.a

no errors
[name@servXX ~]$ link mp1.o

no errors
[name@servXX ~]$ hawk link.o

The first command above assembles the file mp1.a creating an output object file called mp1.o. The second command processes this object file to produce an executable called link.o. The final command starts the hawk emulator with this executable loaded in its memory. The output will be very similar to the output you saw in your installation test, but since you have a program loaded, it's time to run it.

Type the r command once, and you will see small changes in the output -- those changes are the operating system (such as it is) on the hawk computer setting up to run your program. Type the r command again, and you will see the following material on the bottom half of the screen:

  ---------------------


  ---------------------

This is the output of the program mp1.a (before you make changes). If you see this, you can now make the changes required by this assignment.

A little background: First, a note: You are not required to understand the program! It is written in the SMAL Hawk assembly language, and we have not covered that language yet. The comments on the code, however, are written in something resembling C or C++ or Java. You might understand the comments.

The program traverses a linked list of records, where each record has the following one-word fields: the x coordinate of the next item to output, the y coordinate, the address of a null-terminated character string, and the address of the next record in the list. The final list element contains a NULL in its next field.

The first element of the list has the label LIST. The list in the program, as distributed, contains just two elements, each of which has a pointer to the same string, the string containing a row of dashes.

Make the changes: Your job is to add some new list elements, at least two, but there are obvious ways to add more, so that the output resembles this, but with your name substituted for mine and centered reasonably well:

  ---------------------
      Douglas Jones
    Machine Problem I
  ---------------------

If you want to use more than two additional list elements, you could output each word with a separate list element, or even each letter (but that is silly). No matter how you solve this problem, you should not change the code of the program. The required changes are to data structures.

Your source code must be modified in one other way. The original code begins with a title giving my name. You must change it to your name before you submit your solution:

        TITLE   "MP1.a by Douglas Jones"

Your code will be judged not only on its output (half of the score), but on cosmetic issues. Your code must be clearly indented. The labels you place on each list element must make sense and they must be consistent with each other (don't change label style in mid list, for example, moving from SECOND to FirstName. Stick to one convention for case, and stick to one convention for the relation between the label to the object it labels.

Cosemtic issues also include consistent indenting and comments, where appropriate. The code, as distributed, illustrates an appropriat style of commentary and layout. Your changes should not stand out from the code, but should blend in seamlessly.

Turn in your work: Use the divms coursework submission tools to submit your solved work. Your assignment must be in a file named mp1.a and you must submit it as a solution for mp1 in the course c_060. You may re-submit your work, so if you have something you think might be worth submitting, submit it, and if you improve on that solution, submit again.