1. Homepage
  2. Programming
  3. COMPSCI 210 : Computer Organisation - Assignment 1: LC-3 Calculator

COMPSCI 210 : Computer Organisation - Assignment 1: LC-3 Calculator

Engage in a Conversation
AucklandCOMPSCI 210Computer OrganisationLC-3 CalculatorLC-3 simulatorAssembly

COMPSCI 210 Assignment 1 CourseNana.COM

2024 Semester 2 CourseNana.COM

1. Overview CourseNana.COM

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. CourseNana.COM

2. GettingStarted(RunningtheLC-3Simulator) CourseNana.COM

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. CourseNana.COM

3. LC-3Calculator(ExpectedBehaviouroftheFinishedProduct) CourseNana.COM

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). Aer 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. CourseNana.COM

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. CourseNana.COM

The following series of pictures show the expected behaviour of the calculator with the key presses as annotated (aer assembling the OS and calculator program files, and loading them into the LC-3 simulator). CourseNana.COM

COMPSCI 210 Assignment 1 CourseNana.COM

2024 Semester 2 CourseNana.COM

1. Click “Continue” CourseNana.COM

2. Click the display
(For focus and user input)
CourseNana.COM

3. Press “2” on keyboard CourseNana.COM

4. Press “3” on keyboard CourseNana.COM

5. Press “4” on keyboard CourseNana.COM

6. Press “7” on keyboard CourseNana.COM

7. Press “1” on keyboard CourseNana.COM

8. Press “1” on keyboard CourseNana.COM

9. Press “Enter” (Program stops) CourseNana.COM

4. Tasks CourseNana.COM

To get you started, there’s a code skeleton provided to you on the A1 Canvas page. The unmodified code runs without errors, but the results are incorrect. There are three faults due to the unimplemented parts of the code, and your job is to fill in these unimplemented parts. All the unimplemented parts are tagged with “[TODO]”, you can Ctrl+F “[TODO]” or scroll to Line 112 of the code skeleton to find them. CourseNana.COM

The first fault is that the program uses the addition operation regardless of the operation index entered by the user. You need to write code for this part such that the program branches to the appropriate arithmetic operation according to the operation index entered by the user. The operation index is stored in R2. CourseNana.COM

The second fault is due to the lazy programmer who called it quits aer writing the addition function (F_PLUS), and the other arithmetic operations are unimplemented. You need to write code to carry out the arithmetic operations. The two operands are stored in R1 and R3 respectively, and your code should carry out the appropriate arithmetic operation using the operands from R1 and R3 and store the result in R4. CourseNana.COM

The third fault is that the program prints “0” for the result regardless of the result stored in R4. You need to write code such that the program prints the appropriate result according to the value in R4 (the corresponding number character if the result is 0~9, “OUT OF BOUNDS” otherwise). CourseNana.COM

COMPSCI 210 Assignment 1 CourseNana.COM

2024 Semester 2 CourseNana.COM

In summary, you need to complete the following tasks to achieve the expected behaviour described in Section 3. (“F” stands for “Function”, “P” stands for “Print”.) CourseNana.COM

  1. Branch to the appropriate operation (SELECT) CourseNana.COM

  2. Subtraction (F_MINUS) CourseNana.COM

  3. Multiplication (F_TIMES) CourseNana.COM

  4. Floor division (F_DIV) CourseNana.COM

  5. Modulo/Remainder (F_MOD) CourseNana.COM

  6. Print result (P_RES) CourseNana.COM

Note: You may assume that the key presses are always reasonable (only number keys and the Enter key are pressed), and the operations are always well-defined (no dividing by 0). Here are some examples of expected results from the arithmetic operations. CourseNana.COM

Subtraction (F_MINUS) CourseNana.COM

Multiplication (F_TIMES) CourseNana.COM

9-3=6
8-7=1
0-0=0
4-9=OUTOFBOUNDS 0-6=OUTOFBOUNDS CourseNana.COM

1*7=7
0*4=0
0*0=0
2*5=OUTOFBOUNDS 9*9=OUTOFBOUNDS CourseNana.COM

Floor Division (F_DIV) CourseNana.COM

Modulo/Remainder (F_MOD) CourseNana.COM

6/3=2 9/5=1 8/3=2 5/7=0 0/2=0 CourseNana.COM

6%3=0 9%5=4 8%3=2 5%7=5 0%2=0 CourseNana.COM

5. Tips CourseNana.COM

  1. If you want to debug your arithmetic operations more easily, then you may want to finish Task 1 (SELECT) and Task 6 (P_RES) first, since then you can utilise the calculator functionalities to enter and check your operands with ease. Otherwise you can still debug using the values shown in the registers. CourseNana.COM

  2. You may use the examples listed in Section 4 to debug your implementations of the arithmetic operations, but also come up with your own examples to more thoroughly check for edge cases. CourseNana.COM

CourseNana.COM

COMPSCI 210 Assignment 1 CourseNana.COM

2024 Semester 2 CourseNana.COM

3. It may be helpful to understand the program as a whole to more clearly understand the underlying mechanics and how they relate to the functions you write. You can do so by reading and understanding the provided portions of the program. Everything used in the program has been covered in lectures. CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
Auckland代写,COMPSCI 210代写,Computer Organisation代写,LC-3 Calculator代写,LC-3 simulator代写,Assembly代写,Auckland代编,COMPSCI 210代编,Computer Organisation代编,LC-3 Calculator代编,LC-3 simulator代编,Assembly代编,Auckland代考,COMPSCI 210代考,Computer Organisation代考,LC-3 Calculator代考,LC-3 simulator代考,Assembly代考,Aucklandhelp,COMPSCI 210help,Computer Organisationhelp,LC-3 Calculatorhelp,LC-3 simulatorhelp,Assemblyhelp,Auckland作业代写,COMPSCI 210作业代写,Computer Organisation作业代写,LC-3 Calculator作业代写,LC-3 simulator作业代写,Assembly作业代写,Auckland编程代写,COMPSCI 210编程代写,Computer Organisation编程代写,LC-3 Calculator编程代写,LC-3 simulator编程代写,Assembly编程代写,Aucklandprogramming help,COMPSCI 210programming help,Computer Organisationprogramming help,LC-3 Calculatorprogramming help,LC-3 simulatorprogramming help,Assemblyprogramming help,Aucklandassignment help,COMPSCI 210assignment help,Computer Organisationassignment help,LC-3 Calculatorassignment help,LC-3 simulatorassignment help,Assemblyassignment help,Aucklandsolution,COMPSCI 210solution,Computer Organisationsolution,LC-3 Calculatorsolution,LC-3 simulatorsolution,Assemblysolution,