<<< Invoking a C Function from Assembly | Index | Running Total Prototype >>> |
Your assignment is to build a small command-based arithmetic calculator.
The calculator understands arithmetic operators + - * / % =
followed by an integer:
+ 1 ; addition - 3 ; subtraction * 8 ; multiplication / 4 ; division % 2 ; modulo (remainder) = 5 ; assignment
After each input the calculator does the required math and displays the result. The result is a running total: it is used in the next calculation. Lastly entered arithmetic operator is "sticky": the user can enter numbers without an operator to continue using the same operator. For example, (all user inputs are highlighted):
0+ 10 ; addition is a default operation = 10 10+ 10 ; user enters a number without an operator = 20 20+ 10 = 30 30+ /3 ; the user wants to divide by 3 = 10 10/ 2 ; division becomes the default operation = 5 5/ quit ; quit exits the program
<<< Invoking a C Function from Assembly | Index | Running Total Prototype >>> |