ARM program that takes takes an input n Solvved

85.00 $

Category: Tags: , , , , , , ,
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

5/5 - (2 votes)

Instructions

Objective

Write an ARM program that takes takes an input n and uses recursion to print n down to zero and back to n.

Here is sample output

Here is the c++ code for the procedure.  (This is simply meant to help you understand the assignment!!)

void printFun(int n)
{
if (n == 0) {
cout << 0 << endl;
return;
}
else if (n < 0) {
cout << “Please input a positive number” << endl;
}
else {
cout << n << endl;
printFun(n – 1);
cout << n << endl;
return;
}
}

Requirements and Specifications

Your inputs n cannot be stored as a global variable at any point. This means you cannot store them at a data section address, even when accepting them from scanf; they must be returned from scanf on the stack.

X19-X27 are global variables. You may not use X19-X27 in your recursive function. If you want, you may use X19-X27 in your main function.  You can use any registers you want to in your main function.

A recursion procedure requires:

  • Allocate stack space
  • Save the return address and argument on the stack
  • Recursively call procedure with BL
  • Unwind the stack by restoring the return address and arguments and deallocating stack memory

 

Hints and Warnings

You must put the argument and return address on the stack before any bl call, and restore the argument and the return address after the bl call.   This includes every printf call and every recursive call.

Submission

Submit your ARM assembly language program source code. Name the file “pa2.txt”. Submitting with a different filename or different extension will result in point deductions.

Skeleton Code  pa2.txt

You must give us a file with a .txt extension so we can run it through Turnitin.

We will be applying a filter to compare your file to other student submissions to detect plagiarism.  You must do your own work.

 

  • pa2-n6wypf.zip