Homework 6
Overview
Problems 1-2
Complete problems covering topics from Chapter 6 (use either document format; Clearly show work; Typed work is preferred):
Problem 3
This is also described in the documents above.
Link to get the repository / codespace: link
Complete code in numberstats.s
, which should find the minimum, maximum, and sum of elements in a given array. Suggested workflow:
- Review the documentation on Venus in VSCode: https://marketplace.visualstudio.com/items?itemName=hm.riscv-venus
- Write and test the code in a programming language that you know. This will help you identify the concepts and critical logic. Assembly language is much easier if you already have correct logic.
- Once it works, make a new copy to add annotations (comments) to that will help you convert it to assembly language. Use concepts from assembly language, like replacing variables with register names. For example, replace “sum” with “a2” and leave comments that clearly show that every place “a2” is used it represents the sum.
- You’ll need “labels” for loops and if/else statements. Add in comments indicating where you may need to use labels and what the label will be. Labels are like variable names — they should be descriptive.
- On individual lines add comments describing instructions that you may need to use to accomplish comparable work in assembly language.
- Review and run
numberstats.s
before you start modifying it. Make you should and shouldn’t modify it and what is expected. The provided code returns 1, 2, and 3 for the min, max, and sum. Note that the 5th line of the file contains test data that your code will use. You can modify this line to try different test cases. - Start to add your code, but start small. Include just parts for the
sum
first (not min and max).- Use the “Run” button to initially load your program. Always check the “Terminal” panel for error messages.
- If there aren’t any syntax errors, it’s best to try “stepping” through your code one instruction . You can hover your mouse in the “gutter” on the right of your first line of code to add a “breakpoint”. When you hit play the simulator will stop running on any lines with breakpoints. You can then use the “step” buttons to step through each line of code. You can examine the values in registers via the integer register section in the left panel.
- Once sum works, revise work to add in the min, then the max.
Submission
You will need to submit your assignment via Gradescope. There will be two links:
Problems 1-2
As in the past, you need to indicate where your work is for each individual problem.
Problem 3
As with Homework 5, you will need to commit and push work to GitHub and then go to Gradescope to “pull” the work over.
- Submission Link: Gradescope