Description
Your Friendly TAs 😉
Contents
1 Rules – Please Read 2
2 Overview 2
2.1 Purpose 2
2.2 Task 2
2.3 Criteria 2
3 Detailed Instructions 3
3.1 middleaverage algorithm 3
4 Grading 4
5 Deliverables 4
6 Local Autograder 5
7 LC-3 Assembly Programming Requirements 6
7.1 Overview 6
8 Appendix 7
8.1 Appendix A: LC-3 Instruction Set Architecture 7
Please take the time to read the entire document before starting the assignment. It is your responsibility to follow the instructions and rules.
1 Rules – Please Read
You are allowed to submit this portion of the final exam starting from the moment your timed lab/coding portion of the exam period begins until your individual period ends. You have 75 minutes to complete both of the timed lab (LC3-Assembly and C) portions of the exam, unless you have accommodations that have already been discussed with your professor. Gradescope submissions will close precisely at the end of your allotted exam period. You are responsible for watching your own time.
2 Overview
2.1 Purpose
The purpose of this coding section of the final exam is to test your understanding of coding in LC-3 assembly.
2.2 Task
In this section of the final exam, you will be implementing a short assembly program. Please see the detailed instructions on the following page. We have provided pseudocode for the program—you should follow the algorithm when writing your assembly code.
2.3 Criteria
This section will be graded based on your ability to correctly translate the given pseudocode for an algorithm into LC-3 assembly code. Please use the LC-3 instruction set when writing these programs. Check the Deliverables section for what you must submit to Gradescope.
You must produce and save the correct value for the algorithm, and your code must assemble with no warnings or errors (Complx and the autograder will tell you if there are any). If your code does not assemble, we will not be able to grade that file and you will not receive any points.
3 Detailed Instructions
For this coding section of the final exam, you will be implementing an algorithm in assembly that calculates a measure of the center value of an array. This subroutine will call two other subroutines which have been provided to you. The result should be stored on the stack in accordance with the LC-3 Calling Convention.
3.1 middleaverage algorithm
The middle average subroutine will use a pointer to the head of an array and the length of the array to calculate the center value of the array. This statistic should be resistant to outliers, so it should be calculated as the mean of the array while ignoring the two smallest and two largest values in the array. We have made two subroutines available to you which your implementation must call according to the LC-3 Calling Convention.
The following pseudocode is provided for your reference:
middle_average(arr, len) { selection_sort(arr, len); ans = 0; for (i=2; i< len-2; i++): ans+=arr[i];
ans = divide(ans, len – 4); return ans;
}
The selection sort subroutine is made available to you, so you do not need to implement it. When provided a pointer to the head of an array and the length of that array, this subroutine will sort the array in-place.
The divide subroutine is also made available to you. When provided two integer arguments a and b, this subroutine will return the value of floor(a / b).
Examples:
• Given arr: [-2,2,3,9,12], len: 5, the algorithm should return 3.
• Given arr: [-10,-20,0,0,30,40], len: 6, the algorithm should return 0.
• Given arr: [1,1,2,3,5,8,13], len: 7, the algorithm should return 3.
Please refer to Grading for details on how middleaverage will be graded.
4 Grading
Point distribution for this coding portion of the final exam is broken down as follows:
• middleaverage (85 points): Correct return value.
• Other requirements (5 points): Calls the selectionsort and divide subroutines and follows the LC-3 Calling Convention.
5 Deliverables
1. middleAverage.asm
6 Local Autograder
To run the autograder locally, follow the steps below depending upon your operating system:
• Mac/Linux Users:
1. Navigate to the directory your files are in (in your terminal on your host machine, not in the Docker container via your browser)
2. Run the command sudo chmod +x grade.sh
3. Now run ./grade.sh
• Windows Users:
1. In Git Bash (or Docker Quickstart Terminal for legacy Docker installations), navigate to the directory your files are in
2. Run chmod +x grade.sh
3. Run ./grade.sh
7 LC-3 Assembly Programming Requirements
7.1 Overview
1. Your code must assemble with NO WARNINGS OR ERRORS. To assemble your program, open the file with Complx. It will complain if there are any issues. If your code does not assemble, you WILL get a zero for that file.
2. DO NOT assume that ANYTHING in the LC-3 is already zero. Treat the machine as if your program was loaded into a machine with random values stored in the memory and register file.
3. You can randomize the memory and load your program by going to File > Advanced Load and selecting RANDOMIZE for registers and memory.
4. Do NOT execute any data as if it were an instruction (meaning you should put HALT or RET instructions before any .fills).
5. Do not add any comments beginning with @plugin or change any comments of this kind.
6. You should not use a compiler that outputs LC3 to do this assignment.
7. Test your assembly. Don’t just assume it works and turn it in.
8. Comment your code! (not a hard requirement, but will make your life much easier) This is especially important in assembly, because it’s much harder to interpret what is happening later, and you’ll be glad you left yourself notes on what certain instructions are contributing to the code. Comment things like what registers are being used for and what less intuitive lines of code are actually doing. To comment code in LC-3 assembly just type a semicolon (;), and the rest of that line will be a comment.
Avoid stating the obvious in your comments, it doesn’t help in understanding what the code is doing.
Good Comment
ADD R3, R3, -1 ; counter–
BRp LOOP
Bad Comment ; if counter == 0 don’t loop again
ADD R3, R3, -1 ; Decrement R3
BRp LOOP ; Branch to LOOP if positive
8 Appendix
8.1 Appendix A: LC-3 Instruction Set Architecture
Reviews
There are no reviews yet.