Question: Projects may be done in a pair or individually and in accordance with the Projects: I&P . Collatz: Project Description For this project, you are
Projects may be done in a pair or individually and in accordance with the Projects: I&P
Collatz: Project Description
For this project, you are to use subroutines to complete the LC assembly language program template that we provide.
The Collatz Conjecture, also known as the x conjecture, is a popular math conjecture that's not yet proven see WikiLinks to an external site., online toolLinks to an external site. It states that any positive number can be reduced to using the simple algorithm mentioned in the COLLATZSTEPS description below.
First, download the program template: HERE Download HERE. Read the documentation in that text file after reading this page.
Subroutines You're to Complete
Complete the subroutines in the order listed below.
Note the COLLATZSTEPS subroutine is to be completed last since it uses subroutines MULADD and DIVIDEBY
You must use the registers specified in the program template for each subroutine's argument and return value.
This ensures your code will work with our main program and testers.
Be careful to properly handle the return address in R or else your program will fail!
Properly preserve the register R wherever required or else the test harness will fail!
MULADD subroutine pts
pts Implement the subroutine MULADD as specified in the program template.
The subroutine should return the result A given A as the input.
pt Properly preserve the register values as needed.
DIVIDEBY subroutine pts
pts Implement the subroutine DIVIDEBY as specified in the program template.
The subroutine returns the RESULT of N given an even positive integer N as input
and using the following algorithm:
RESULT
while N
subtract from N
increment RESULT by
pt Properly preserve the register values as needed.
COLLATZSTEPS subroutine pts
pts Implement the subroutine COLLATZSTEPS as specified in the program template.
This subroutine calculates the number of STEPS required to transform a positive integer X to using the following algorithm:
STEPS
while X is not equal to :
if X is even decrease X to X
if X is odd increase X to X
increment STEPS by
You are to use the MULADD and DIVIDEBY subroutines in this subroutine.
pt Properly preserve the register values as needed.
Code We've Provided
We provide a program template file for you to complete. Please refer to the Project Description section above for the link to download the program template. The template file is structured as follows:
Header comments that you need to fill in and boxes you need to mark.
Descriptions of each subroutine, followed by a placeholder where you need to implement the subroutine's LC assembly code. You are to implement each subroutine only within its designated regions.
Three helper subroutines PRINTDIGIT, PRINTINT, COLLATZ are provided to help you check your code.
The main section includes tester subroutines to test the subroutines you're coding. You can skim through this section to understand what the testers are doing. A sample output of our tester is provided below. Do NOT modify any lines beyond the start of the main section. Doing so can break our code.
Except for the labels to call the helper subroutines, DO NOT USE ANY OF THE OTHER LABELS in our code's main section.
Do not change the tester code in the main section to do additional tests. Additional tests can be done by editing the simulator's register and memory values instead of changing our tester code.
If you've successfully implemented all three subroutines, our testers will display the output below. If you see the message "Check for callee saving failed" as part of the tester outputs, then one or more registers are not being correctly preserved.
Steps for reaching from
Number of Collatz Steps for
Grading and Submission
pts The program has good commenting and a good coding style.
pts The MULADD subroutine is successfully completed.
pts The DIVIDEBY subroutine is successfully completed.
pts The COLLATZSTEPS subroutine is succ
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
