Assignment 2 solution
Part of
the homework for 22C:50, Summer 2004
|
% eal -help eal <infile> [-l <listfile>] [-d] assemble EAL code from <infile>, listing directed to to <listfile> (defaults to <basefile>.l), where <infile> = <basefile>.<suffix>; -d adds symbol table to listing. EAL V0.0 by Douglas W. Jones. %
EAL V0.0 by Douglas W. Jones; Fri Jun 11 14:49:53 2004 1 |NULL = 0 2 | 3 0000: 0000 |A: W NULL ; left 4 0002: 0000 | W NULL ; right 5 0004: 01 | B 1 ; data 6 | 7 0005: 0000 |B: W A 8 0007: 0000 | W NULL 9 0009: 02 | B 2 10 | 11 000A: 0000 |C: W NULL 12 000C: 0000 | W NULL 13 000E: 04 | B 4 14 | 15 000F: 0005 |D: W B 16 0011: 0014 | W E 17 0013: 03 | B 3 18 | 19 0014: 000A |E: W C 20 0016: 0000 | W NULL 21 0018: 05 | B 5
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!
D --- the root /3\ / \ B E /2\ /5\ A C /1\ /4\
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?
It will be difficult to distinguish between a pointer to the root and a null pointer, since both will be represented as 000016.
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?
In Figures 2.9 and 2.10, there is only one form of definition, <identifier>=<operand>. In parse_definition there is an additional form, .=<operand>.
b) Again, looking only at syntax issues, and not at semantics, what is the difference between parse_line() and the notes?
In Figures 2.9 and 2.10, comments are handled in the syntax for <line>. In parse_line there is nothing to handle comments because this issue was handled in the lexical analyzer.