Description
In our sixth lab, you and your partner will build a calculator program in ARM, as described below.
Steps
Find your lab partner. Then:
- Login to a Systems Lab machine using your MSCSnet username and password. The west side of the Lab has Linux machines, while the opposite side has Windows machines.
That said, if you are on a Linux box, you can open a terminal prompt and run commands accordingly. If you are on a Windows machine or laptop,
you will have to ssh into an appropriate Lab machine (such as morbius) in order to access necessary tools to compile and run your program.
- Organize your lab work how you wish. For example, you may create a parent directory to hold your pi3Playground for this lab. Alternatively, you may untar in a 'Labs' directory, and rename the 'pi3Playground' directory to 'lab6'.
- Untar a fresh Pi3 Playground by running this command: tar xvzf ~pmcgee6/cosc2200/pi3Playground.tgz
- Write your program.
- Once finished, show a demo of your program to the present TA (Note: you do not turn in labs -- simply show a demo).
- Like in the past labs, you can continue to improve your program and show demos to the TA until you receive full points.
Review: using the divide function
The divide subroutine takes a dividend in r0 and a divisor in r1; upon return, the integer quotient is stored in r0. Disregard the remainder for this lab.
The Program: Simple Calculator Using States
Write an assembler program that uses a set of states to calculate a result. When the program begins, let the current result equal zero. The user enters a number representing the type of operation desired:
- 0: add next entered integer to current result.
- 1: subtract next entered integer from current result.
- 2: divide current result by next entered integer.
- 3 or greater: print result and end program.
These numbers dictate the "states" of your program's execution. You can think of it like a selection menu.
After each operation that is not the ending operation, the current result is printed, and the user again is prompted to input a number to select a new operation.
Example:
? 0
? 5
5
? 1
? 2
3
? 0
? 9
12
? 2
? 6
2
? 4
All user process have completed.