Assignment 5, due June 23Machine Problem 2, due June 28
Part of
the homework for 22C:50, Summer 2004
|
Create a working directory called mp2, and then either: Install the source code from
http://homepage.cs.uiowa.edu/~dwjones/syssoft/hw/mp0.txtOr make a copy of your solution to MP1 to this directory and continue development here, so you end up with all your solutions integrated into one program.
Having done this, note that the assembler, as currently configured, supports only the following forms of expressions, as documented in the header comments of parse_operand in parser.c:
<term> ::= <identifier> | <number> | .
<operand> ::= <term> { (+|-|&||) <term> }
Modify the code so it supports and evaluates expressions with the following grammar:
<term> ::= <identifier> | <number> | . | ( <operand> )
<sub expression> ::= <term> { (+|-|&||) <term> }
<operand> ::= <sub expression> [ = <sub expression> ]
Note that there are two distinct changes here: First, we allow parentheses, such as a-(b&c), and second, we allow a comparison operator, and equals-to. The comparison operator has a lower precidence than arithmetic, so a+b=c+d is equivalent to (a+b)=(c+d) and is definitely not equivalent to a+(b=c)+d. Comparison should produce zero for false and all ones for true (all ones is FFFF16).
Make sure your modified version of EAL claims to be written by you and that it claims to be a solution to MP2 (by default, it claimed to be MP0). These are settings in the Makefile.
Make sure that all of your code conforms to the style guidelines
http://homepage.cs.uiowa.edu/~dwjones/syssoft/style.htmlPay close attention to indenting (depending on how you downloaded your code, tab-to-space conversion may have seriously damaged the indenting), and pay close attention to the commenting rules for documenting revisions. Specifically, use comments of the form /*MP1*/ to mark any line you added, and add an appropriate revision line to the header block of any file you change.
Write an EAL program that thoroughly tests your modified code, specifically, this should demonstrate all of the operators supported by the expression package, it should demonstrate all operator precidence relationships and the effect of parenthesizing expressions. This expression grammar offers an infinite range of
Comments and organization in test files are just as important as they are in the programs they test, so your test data should be well documented! Comments in the test data should document what is being tested and what the expected results of the test are.
Paper listings of every file from the EAL source code that you changed (obviously, parser.c will be one of these). and a paper listing of the listing file produced by EAL when it processes your test data.
#define plus(a,b) a + b
If, in the body of the program, someone wrote
i = plus(i,1);
The result would be
i = i + 1;Write a set of macros that allow a C programmer to write code in this horrible notation:
assign(i,times(plus(i,1),times(j,2)));
This should end up having a meaning something like this:
i = (i + 1) * (j * 2);
Note, you may need to use more parentheses.
MOVE src,dst
The result should be identical to having written this:
W src W dstWrite a macro, using the macro notation presented in Chapter 6, that will produce this result.