Machine Problem 1, due September 12

Part of the homework for 22C:60, Fall 2005
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Concept:

The Hawk machine has rather limited tools for graphics. It can only display text from the ISO-7 character set (ASCII) on the screen. We can, however, still construct graphics like this:

.........................................................
.    +---------------+           +---+    +             .
.    | text in a box |------+    | A |    |             .
.    +---------------+      |    | B | +-----------+    .
.       |                   |    | C |    |             .
.       +-------------------+    +---+    +             .
.........................................................

The above example contains 5 graphical objects, two of which contain text. One contains the string "text in a box", while another contains the string "A[CR][LF]B[CR][LF]C" (where square brackets have been used to delimit names of control characters).

Each graphical object can be described by the coordinates of its upper left corner. In the example above, for example, the upper left box has its upper left corner in row 1 column 5. Each object has a height and a width. The two rightmost objects are degenerate, with either a height or width of zero. The leftmost object has height 2 and width 16. When objects overlap, the last object displayed will blot out any object under it.

A screenful of these graphical objects can be represented as a linked list of records (call them structures if you want), where each record has the following form:

NEXT
X
Y
WIDTH
HEIGHT
TEXT
pointer to next graphical object
X coordinate of upper left corner
Y coordinate of upper left corner
Width of this object
Height of this object
pointer to null-terminated string of text for this object

Each record field can be represented as a 32-bit word. Records are displayed starting at the head of the list and continuing to the end, so the leftmost object in the example must not have been the first item in the list. If there is no text in the object, the TEXT pointer may be null or it may point to an empty string (both ideas work well). Null pointers can be represented by zero. Non-null pointers hold the memory address of the object they point to.

The Assignment

Write a file of SMAL assembly code that builds this data structure for the example display screen shown above. Your file should conform to the following requirements:

  1. The file must be named mp1.a.

  2. It must begin with a TITLE directive saying MP1 followed by your name as it appears on your university ID card.

  3. The file must be named mp1.a right after the title.

  4. The file must contain the line INT ITEM1 right after the title.

  5. The first item in your linked list must have the label ITEM1.

  6. The 6 consecutive words of each list element must be word aligned.

  7. The referent of each pointer must be labeled and the label should for the reference.

  8. Blank lines, indenting and comments should be used in order to maximize readability.

You will want to run the SMAL assembler to check that your file is syntactically correct and to see that the appropriate values go into memory in the appropriate way.

Running SMAL

Before you use the SMAL assembler, you will have to install the following text in a special file named .cshrc under your account on the departmental machines.

Log into the lab machines (remotely using an ssh client or locally) and use the text editor of your choice to open the file .cshrc for editing. You will see something like this:

# KEEP THESE TWO LINES FIRST !!
source /etc/CSHRC

# Add personal Customizations here.

(What does it do? When you start your shell, it looks in .cshrc to initialize itself. Lines starting with hash marks are comments, so the only thing here by default is a line telling it to look in the file /etc/CSHRC to initialize itself.) What you need to do is add the following three lines of personal customizations to the end of your .cshrc file:

alias smal ~dwjones/smalstuff/smal32.intel -U ~dwjones/hawk
alias link ~dwjones/hawk/link
alias hawk ~dwjones/hawk/hawk.intel
These lines add the commands smal, hawk and linketo your environment. After you have added these lines to to the end of your .cshrc file, exit the editor, log off the machine, and then log in again in before you test them.

Now, you can type the command smal mp1.a and the assembler will process your file, putting the listing in mp1.l. If you are in 303 MLH and need to print a SMAL assembly listing file named mp1.l, the following print command is likely to produce the most legible results: lp -o landscape mp1.l

Submit your result

Use the submit command on the department linux cluster to submit your solution. Your complete submit dialogue will look like this:

        [you@serv16 ~/assem]$ submit mp1.a
        Course (22C:016 would be c016): c060
        Possible submit directories for /group/submit/c060 are:
        
        mp1
        
        Choice:   mp1
        mp1.a
        * File/directory mp1.a has been 
        *  copied to /group/submit/c060/mp1/mp1.a.you.
        [you@serv16 ~/assem]$

Grading

Your program will be assembled and the result linked to a program that traverses the data structure you have built and displays the requisite information on the screen. If the output is right, you will get half credit. The other half of the credit will be assigned based on the quality of your source file (see the list of requirements for the assignment).