In this problem you will modify an existing assembly-language program.

Your work for this problem should go in the file ps7pr1.txt that we have given you in the ps7 folder. Begin by opening the file in a text editor. Remember that you may need to change the file type in order for your text editor to find the file.

Start by assembling and running the existing program that we have given you.

Enter an integer (e.g., 32000), and you should see the program counting upward from that number. When it gets to 32767, which is the maximum possible value, it will stop. If you want to stop the program early, you can do so by hitting Control-C.

Look over the code, and make sure that you understand how it works!

Your task is to modify the code in ps7pr1.txt so that it does the following:

1. Asks the user for an input. You may assume that the input will be positive and less than 30.

2. Computes the cube of that input, and prints the result. You will need multiple multiplications to compute the cube! Before proceeding to the next step, add a temporary halt statement, and test the current version of your program to ensure that it works.

3. Counts downward from the cube of the input to 0, one integer at a time, and printing each value. Consider starting this step by just adding the statements needed to compute and print one less than the cube of the input, and then halt. Test the program to confirm that it correctly prints that value, and then add the statements needed to create a loop that continues the countdown all the way to 0.

4. When the count is less than 0, the program should stop. Note that the last value printed should be 0, not -1.

Important notes:

Make sure to follow the style guidelines that weve specified. In particular, you must have a comment on every line except for nop statements.

You will need to decide how many additional registers you need, and which one(s) you wish to use. You can use any register from r1 to r15. Register r0 is not available for our purposes.

In all of your work on this problem set, we strongly encourage you to take a one-step-at-a-time approach like the one that weve outlined above. Gradually add functionality to your program, and test each new addition before continuing. This should make your program development and debugging much more manageable.

Remember that nop statements are useful as spacers that provide room for you to grow your program without needing to renumber lines.

After each change that you make to your assembly code, make sure to resave the file before you assemble and run it.

Your work for this problem should go in the file ps7pr2.txt that we have given you in the ps7 folder. Begin by opening the file in a text editor. Remember that you may need to change the file type in order for your text editor to find the file.

Your task is to write an assembly-language program that uses a loop to compute a power. Your program should do the following:

1. Ask the user to enter two inputs. You may assume that these inputs will be nonnegative integers.

2. Use a loop to compute the result of raising the first input to the power of the second input.

3. Print the result and exit.

For example:

Enter number: 2

Enter number: 5

32

One good model for this problem is the loop-based facorial program that we reviewed in lecture. Weve reproduced it below:

00 read r1 # get # from user and store it in r1

01 setn r2 1 # initialize r2, which will store the result

02 jeqzn r1 08 # jump to line 08 if r1 == 0

03 mul r2 r2 r1 # r2 = r2 * r1

04 addn r1 -1 # r1 = r1 - 1

05 jumpn 02 # jump back to line 02

06 nop

07 nop

08 write r2 # write out the result

09 halt

Notes/hints:

Dont forget to follow the style guidelines that weve specified. In particular, you must have a comment on every line except for nop and halt statements.

Here again, you should take one step at a time, and test each new addition or change that you make before continuing.

Make sure to test your program carefully, including edge cases in which one or both of the inputs are 0. Note that any number to the power of 0 should produce a result of 1including 00. Here are some additional sample runs:

Enter number: 3

Enter number: 4

81

Enter number: 111

Enter number: 1

111

Enter number: 111

Enter number: 0

1

Enter number: 10

Enter number: 4

10000

Enter number: 0

Enter number: 0

1

Your work for this problem should go in the file ps7pr3.txt that we have given you in the ps7 folder. Begin by opening the file in a text editor. Remember that you may need to change the file type in order for your text editor to find the file.

The Fibonacci sequence is one of the most famous sequences in mathematics. The first Fibonacci number (F0) is 1, the second Fibonacci number (F1) is also 1, and each of the remaining Fibonacci numbers can be found by adding the previous two numbers in the sequence:

F0 = 1

F1 = 1

F2 = 1 + 1 = 2

F3 = 1 + 2 = 3

F4 = 2 + 3 = 5

F5 = 3 + 5 = 8

F6 = 5 + 8 = 13

F7 = 8 + 13 = 21

etc.

Your task is to write a Hmmm assembly-language program that takes a single input from the user, call it n, and that uses a separate function to print the first n Fibonacci numbers, and to compute and return their sum. The program should end by printing the sum of the numbers (i.e., the return value of the function). You may assume that the input n will always be at least 2. For example:

Enter number: 10

1

1

2

3

5

8

13

21

34

55

143

Note that the first 10 values printed (the numbers 1 through 55) are the first 10 Fibonacci numbers, and the final value (the 143) is the sum of those 10 numbers.

Important: For full credit, your solution must employ a separate function to generate and print the Fibonacci numbers, and to compute and return their sum. Use call and jumpr instructions as we did in lecture. The function should compute and return the sum, but the function itself should not print it. Rather, the sum should be printed after the function returns, by code that is outside of the lines that make up the function.

Notes/hints:

Remember to follow the style guidelines that weve specified. In particular, you must have a comment on every line except for nop and halt statements.

As always, you should take one step at a time, and test each new addition or change before continuing.

This program will be somewhat similar in structure to the assembly-language program that you wrote for before. In this problem, each new Fibonacci number is derived from the previous two numbers. In addition, dont forget that the code for generating and printing the Fibonacci numbers should go in a separate function, and that you also need to compute and return the sum of the numbers.

You will need at least two registers for Fibonacci numbers: one for the current number (the one that will be printed next) and one for the last number. In addition, you will need a separate register for the sum of the numbers. You will need to initialize these registers appropriately before you begin looping.

The sum of the numbers will be a cumulative sum that is gradually built up as your loop executes. After each new Fibonacci number is generated, add it to the register that youre using to accumulate the sum. We followed a similar approach in lecture when we used a loop to compute the factorial of a number.

Test your program carefully, starting at n == 2.

Academic Honesty!

It is not our intention to break the school's academic policy. Projects posted are only used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.

Kindly fill out the form.
Please provide a valid email address and we'll get back to you in less than 24 hours.
We will be sending an invoice through PayPal upon confirmation.
We are a non profit organization however we need an amount to keep this organization running,
and to be able to complete our research and development.