Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
1. Overview
Weight: 5% of final grade
Task Description: You are to implement a basic calculator using the LC-3 simulator. The
finished product can take inputs from the user and perform calculations according to the
operands and arithmetic operation specified by the user. The calculator then displays the
calculation results in the console in a well-formatted manner. The arithmetic operations
supported by the calculator are: addition, subtraction, multiplication, division, and modulo.
2. Getting Started (Running the LC-3 Simulator)
This assignment uses the LC-3 simulator shown in class, so please make sure you are
familiar with the tool before going ahead with the assignment. You can familiarise yourself
with the tool by following the instructions provided on the Canvas page L10: LC-3 Simulator
Resources, and running various example scripts provided on Canvas pages of lectures.
3. LC-3 Calculator (Expected Behaviour of the Finished Product)
The LC-3 calculator prompts the user for the first operand, the operation index, and the
second operand in that order. Once all three inputs have been entered, the display then
prints the appropriate equation with the calculated result (as shown below). Aft er printing
the result, the calculator then prompts the user again for the next calculation. This process
continues until the user presses Enter, which stops the program.
Note 1: The calculator only works with single-digit numbers, so the two operands have to be
within the range of 0~9 (both ends inclusive).
Note 2: Every operation index refers to an arithmetic operation: 1 for addition (+); 2 for
subtraction (-); 3 for multiplication (*); 4 for floor division (/); 5 for modulo/remainder (%).
Note 3: The result is also only single-digit. If the result is NOT in the range of 0~9 (both
ends inclusive), then the display prints “OUT OF BOUNDS” as the result.
The following series of pictures show the expected behaviour of the calculator with the key
presses as annotated (aft er assembling the OS and calculator program files, and loading them
into the LC-3 simulator).
1COMPSCI 210 Assignment 1
2024 Semester 2
1. Click “Continue”
2. Click the display
(For focus and user input)
3. Press “2” on keyboard
4. Press “3” on keyboard
5. Press “4” on keyboard
6. Press “7” on keyboard
7. Press “1” on keyboard
8. Press “1” on keyboard
9. Press “Enter”
(Program stops)