# Machine Problem 1, due Feb 24

## Assignment:

Build a data structure in the file mp1.a in your home directory that puts out your name on the screen using the following basic rules:

• Your source file must be titled with mp1.a and your name. Failure to follow this requirement will result in your assignment being ignored. We, the instructor and teaching assistants, will not engage in detective work to determine who to credit with an assignment.

• The label HEAD marks the first element of the list.

• Each list element is a record consisting of the following items:
1. A word, the pointer to the next element, or NULL.
2. A word, the X coordinate at which this element's string should be displayed.
3. A word, the Y coordinate at which this element's string should be displayed.
4. A word, a pointer to this element's string.

• Screen coordinates are measured from the upper left of the display area, in units of characters.

• Your first string should be your given name, at coordinates [x,y] = [1,1].

• Your second string should be your family name, at coordinates [x,y] = [1,2].

• Your third string should be "Machine Problem 1", at [x,y] = [4,4].

• Your source file must be based on the following skeleton, with the TITLE and the included data structures changed to meet the above requirements.
```        TITLE   "mp1 -- Douglas Jones"
USE     "hawk.h"
NULL    =       0       ; the null pointer, points to nothing
NUL     =       0       ; the ASCII character, end of string

; first list element
HEAD:   W       NULL    ; next field
W       12      ; X coordinate
W       1       ; Y coordinate

; the strings
HEADST: ASCII   "This is the wrong string",NUL

END
```

If you turn in the above code, unchanged, you will receive no credit because the title is unchanged and it outputs the wrong string in the wrong place on the screen. Furthermore, the list contains only one element when your list ought to contain three elements.

By way of explanationm, the INT directive tells the assembler to tell the linker about the symbol HEAD so that the linker can tell the main program where the list is.

The object file of a main program will be provided called mp1test.o so that you can test your data structure. Specifically, you can assemble and link your data structure to this main program and then run the program using the following sequence of Unix/Linux shell instructions:

```smal mp1.a
```

You should use the submit command on the departmental Linux cluster to submit your work. See the help page at

for help on using the coursework submission tools or just follow the very long winded instructions output by the submit shell command.

In short, submit the file mp1.a from your home directory into the submit repository for course c_060 in the submit directory mp1. Sounds easy, but the submit command is remarkably verbose. Here is an abridged transcript of a successful submission:

```[HAWKID@serv16 hw]\$ submit

1) You must supply at least one file/directory name or ...
2) You must be in the directory that contains the homework ...
3) Case does matter.
4) Submitting the same homework assignment multiple times will ...
5) Enter only one assignment per line, when finished press
[ENTER] on a line by itself

File/directory name:  mp1.a
File/directory name:

Course (22C:016 would be c_016): c_060
Possible submit directories for /group/submit/c_060 are:

mp1

Choice:   mp1
mp1.a
* File/directory mp1.a has been
*  copied to /group/submit/c_060/mp1/mp1.a.HAWKID.
[HAWKID@serv16 hw]\$
```

As mentioned above, the assignment number mp1 and your name must appear on the title of the listing. In addition, the file name of the file you submit must be mp1.a. No upper case, no alternatives.

• If all you did is change the title line, you will get 0.5 points.

• If you also changed the output to include your first name, last name, and "Machine Problem 1" you will get 1.5 points.

• If this output appears as three lines on the correct places on the display screen, You will get 2.5 points.

• If the output is entirely correct and your program is properly readable, you will get 5 points. Demerits of up to 1/2 point will be assessed for irregular or nonstandard indenting, for excessive or inadequate white space, for poor choice of identifiers (such things as labels), and for disorderly code.

## Notes

A student asked, what does the test program do? In answer to that questionm here is the test program, expressed using the syntax of the C language. It would look very similar (and it would be about the same size) in languages like Java and Python. If you know those languages, it should not be too hard to read this example:

```/* description of the structure of a list element */
struct record {
struct record * next;
int x;
int y;
char * s;
};

/* linkage to the student's definiton of head, the first list element */