Assignment 2, due June 14

Part of the homework for 22C:50, Summer 2004
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Always, on every assignment, please write your name legibly as it appears on your University ID and on the class list! All assignments will be due at the start of class on the day indicated, and unless there is what insurance companies call "an act of Godt" (something outside your control), the only exceptions to this rule will be by advance arrangement.

  1. This question is a preassignment for the first machine problem. Creat a working directory called mp0, and then download into this directory a copy of the following file:
    http://homepage.cs.uiowa.edu/~dwjones/syssoft/hw/mp0.txt

    Having done so, use a text editor to look at the file and follow the directions you find there for unpacking the file. Having done this, you will find that your directory contains a file called README. Read it and you will find instructions for building the assembler for the example assembly language. Follow those instructions!

    Depending on how you capture a copy of the file, you may need to replace all sequences of 8 leading blanks in the Makefile with single tabs. This is annoying, but some modern web browsers try to be clever and change tabs to blanks in text you download. Worse yet, some versions of the make utility care about the difference between tabs and blanks. Poor software compounds the problems posed by other poor software!

    To prove that you've done this: Change the AUTHOR line in the Makefile so it gives your name, and then run make and run the application using the -help option and capture the output it gives (screen shot, script file, any form of capture will do, even a handwritten copy of the output), and turn that in with your solutions to this assignment. Do not turn in a listing of any of the C source files that make up the assembler!

  2. Here is a small bit of code in our example assembly language, EAL.
    NULL	=	0
    
    A:	W	NULL	; left
     	W	NULL	; right
     	B	1	; data
    
    B:	W	A
     	W	NULL
     	B	2
    
    C:	W	NULL
     	W	NULL
     	B	4
    
    D:	W	B
     	W	E
     	B	3
    
    E:	W	C
     	W	NULL
     	B	5
    

    a) Assemble the above code using the the EAL assembler you got for problem 1. Turn in the assembly listing file -- the assembler's output from assembling this input.

    b) This code describes a binary tree with nodes named A through E. draw that tree in graphical form, showing, in each node, the node name and the data stored there. Identify the root!

    c) There is something wrong with this tree that isn't visible in the assembly code but is obvious if you read the assembly listing showing the result of this assembly. What is the problem?

  3. The part of the EAL grammar given in figures 2.9 and 2.10 (using two different formal notations) does not entirely agree with the grammar parsed by the EAL assembler. In the file parser.c, there are differences in parse_definition() and parse_line()

    a) Looking only at syntax issues and ignoring the added code for graceful error handling, what is the difference between parse_definition() and the grammar from the notes?

    b) Again, looking only at syntax issues, and not at semantics, what is the difference between parse_line() and the notes?