This assignment will use the Rosetta software from the Decker/Hirshfield text. The practice problems will include an introduction to using the software. Also, please see the following information regarding using the Decker/Hirschfield software.
Warning: For larger expressions and longer programs, the software scrolls down as needed. There are scrollbars in the windows which appear to imply that the user is able to scroll back up to the top, however it seems that these scrollbars do not work properly. Just keep this in mind if you play with larger examples.
LOD #3 MUL Y ADD X STO W
LOD X DIV Y STO T1 LOD #3 SUB T1 STO Z
LOD #2 MUL Y STO T1 LOD Z DIV #3 STO T2 LOD T1 SUB T2 STO X
The intended "grammer" which defines the syntax of a valid expression
can be shown, in the style of the Brookshear text through the
following syntax diagram.
To avoid ambiguity, the semantics of an expression is interpretted using the standard rules of operator precedence, as discussed in lecture.
Unfortunately, the software is flawed. Your goal is to identify a well-formed arithmetic expression, according to the above grammer, for which the provided software behaves improperly. To accomplish this testing, you will need to make sure that you understand understand the syntax of the grammer and the semantics of the operator precedence (otherwise, how will you know to recognize incorrect behaviors).
Please note: If the program reports "Expression not well-formed" this means that the expression you typed is flawed, not the program.
In your solutions, you are to provide the following information:
For example, if you look carefully at Rosetta's code generation, you will notice that it generally uses memory locations W,X,Y,Z to signify the original inputs and the final results. It uses 'registers' T1, T2, T3, T4 at times to temporarily store a partial computation.
For extra credit, we are going to examine code for the expression:
W = (X/3) - ( (Y-3) / (Z+2) )If you type this expression into Rosetta and allow it to generate code, you will notice that the code makes use of three extra registers at various times: T1, T2, T3. This is somewhat wasteful. With care, it is possible to design PIPPIN code for evaluating this expression which only uses one such register. This can be done by carefully restructuring the order of various computations along the way.
For extra credit, try to write your own PIPPIN code for evaluating the given expression using as few registers as possible. We will give you three points if your solution uses only one register! If you find a solution which uses only two registers (rather than the original three), we will give you 1 of the 3 possible points.
Save your PIPPIN code in a file named "Optimized" to be submitted.
Note: code optimization is only useful if you are still producing code which produces the correct final result. No points will be given for code which does not correctly evaluate the original expression.