![]() |
ANU College of Engineering and Computer Science
School of Computer Science
|
|
|
Introduction to Computer SystemsAssignment 2 Specification - rPeANUt - Reverse Polish CalculatorThe aim of this assignment is to give you a challenging assembly program to write. Unlike the first assignment, this assignment will be completely marked by computer. Thus the focus is on correctness and performance. Coding style and coding formatting will not be marked (not to say these are not important as a clear consisted approach in your formatting and coding style will help with the correctness of your submission).The basic part of the assignment aims to be simple enough for most students to be able to complete in less then 5 hours. The assignment also aims to provided a more challenging programming task for the student who wish to gain extra experience (and a higher mark). The assignment will be marked out of 100. And is worth 10% of the final mark. A late penalty of 10% per day applies (these are working days and apply from after the assignment is collected. The assignment will be collected some time after noon on the Friday. Also note this penalty is caped, so it does not take your final mark below 40 out of 100. Assignment work will not be accepted after the last day of semester. Extensions are possible in documented exceptional cases (e.g. medical certificate).
Reverse Polish CalculatorThe calculator program takes input commands from the terminal and uses these to calculate a result. This is done one line at a time. An empty line halts the program.Expressions are given as a list of space separated numbers or operators. The new line signifies the end of an expression and that the expression should be calculated with the resulting value returned to the terminal. These expressions are in reverse polish form (see http://en.wikipedia.org/wiki/Reverse_Polish_notation). You may assume the input provided to the program has no formatting problems. You may also assume that all the numbers given to the calculator (or used in a partial calculation) will be represtable via a 32 bit signed integer. If you type the below into the terminal (the last line is empty making the calculator halt): 2 4 + 4 1 4 + - -3 -1 -1 * 4 2 * 7 + 4 2 / 4 2 % 5 ! 2 10 ^then you would expect the flowing output: 6 -1 -3 1 15 2 0 120 1024 Such a calculator can be implemented by making use of a stack. An expression is parsed from left to right and there are basically three situations. Firstly, if a number is encountered then that number is pushed onto the stack. Secondly, if a binary operator is encountered (+, -, *, /, %, ^) the top two numbers on the stack are popped off which are used by the binary operator and the result is pushed onto the stack. Thirdly, if a unary operator is encountered (!) then one number is popped, applied to the unary operator, and the result is pushed onto the stack. The operators you need to implement are:
Note, you may apply optimisations, however, any changes must result in the same evaluations of the expressions. MarkingThe marking of this assignment will be automatic. So it is important that your solution compiles and works. Also, get the assignment working in stages. Different tests will be performed such that if you only complete some of the assignment you will still gain marks for the parts you get working. If you can't get the harder parts of the assignment working just leave them out of your submission and get the marks for the earlier parts. The marking stages of the assignment are as follows:
TestsSome test sets are available to give you an idea of the type of automatic testing that will be done on your solution. All marks will be done via this automatic testing so you need byte identical solutions.Tests are available from: http://cs.anu.edu.au/students/comp2300/ass2tests (or as one tar file alltests.tar). These give you an idea of the types of tests performed. To run a test you need to check that when your program is given a set of commands it produces identical output. This can be done using the following terminal command: java -jar rPeANUtxxx.jar yoursolution.s < testX.rp | diff -s - testX.rp.resThere should be no difference between your output and what is expected. Individual AssignmentThis is an individual assignment. You may help each other, however, the final submission must be original and your own work. Take care not to give parts of your solution to other students.Assignment SubmissionThe assignment must be submitted via a computer in the CSIT labs (or remotely via ssh to "partch" or one of our servers). To submit the assignment use the following command:submit comp2300 ass2 calculator.s A few hits for submission:
| |||||||||||||||||||||||||||||||||||||||||||||||||
|
Please direct all enquiries to: ericm@cs.anu.edu.au Page authorised by: Head of School, SoCS |
| The Australian National University — CRICOS Provider Number 00120C |