This assignment will use the "Rosetta" program provide in Module 6 of the Decker/Hirshfield text. The practice problems will include an introduction to this 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
Overall, please type your answers to all of these questions in a single text document to be submitted.
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 two points if you find a solution which optimizes Rosetta's solution, using only two registers rather than three. We will give you four points if your solution uses only one register!
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.