Starting from:

$115

LCProjects Lab 4 Solution



Summary

For this lab you will implement a basic LC3 assembly program which calculates the sum of all odd numbers stored between x3200 and x32FF inclusive.

Program Details


The final sum will be stored at memory location x3300. Once stored, your program will halt the machine using the HALT command.

You must place any .FILL pseudo-ops after your HALT command. Placing .FILL pseudoops before the HALT will cause the data stored at those locations to be executed as instructions. This can cause your code to produce unexpected results and prevent Gradescope from executing correctly.

Bonus: +10 points for making and using an IsEven subroutine to determine if a specific value is even or odd. The subroutine must start at a label named IsEven and expect a single input parameter (a 2s complement number) in R0. If the given number is even, the subroutine will return 0. If the number is odd, it will return any non-zero value. The result of the subroutine will be stored in R0. You must define your subroutine after your halt instruction so that the subroutine will only execute if jumped to.

The IsEven subroutine must also implement callee save and preserve the values of registers R1-R5. NOTE: If your subroutine doesn't touch a register (i.e. modify its value) then you don't need to push that registers value onto the stack!




Development Notes


When testing if a number is odd or even, please remember that a number can be negative or positive and to account for that in your program. Also note that if you use the user stack, you will need to initialize R6 with the stack pointer value first. The user stack should always start at xFDFF per the LC3 ISA.

For developing and testing your assembly program I recommend using the online LC3 simulator at: https://wchargin.com/lc3web/ . While this is the simulator I recommend, you are allowed to use any LC3 simulator to develop this project. **I also highly recommend downloading the LC3’s ISA from Canvas to use as a reference for this project. It is an invaluable resource which is vital for the project.** When saving your assembly program for Gradescope, you will need to use a text editor such as sublime text or notepad++


AND R0,R0,#0

A good comment would be: ;sets R0 to 0

A poor comment would be: ;ANDs the value of R0 to 0 and stores the result

Final Notes


Rubric

Category Points
Autograder 70
Code Formatting 15
Comments 15

More products