subject
Computers and Technology, 03.03.2020 05:43 MC2007

You are required to turn in the following source file:

assignment7.s

Objectives:

-write assembly language programs to:
-define a recursive procedure and call it.
-use syscall operations to display integers and strings on the console window
-use syscall operations to read integers from the keyboard.

Assignment Description:

Implement a MIPS assembly language program that defines "main", and "function1" procedures.

The function1 is recursive and should be defined as:

function1(n) = 2*n if n <= 4

= n*function1(n-2) + function1(n-3) + n otherwise.

The main asks a user to enter an integer for n and calls the function1 by passing the n value, then prints the result. If your program causes an infinite loop, press Control and 'C' keys at the same time to stop it. Name your source code file assignment7.s.

C program that will ask a user to enter an integer, calls the fuction1, and prints the returned value from the function1.

// The function1 is a recursive procedure defined by:
// function1(n) = 2*n if n <= 4
// = n*function1(n-2) + function1(n-3) + n otherwise.

int function1(int n)
{
if (n <= 4)
{
return 2*n;
}
else
{
int comp = n*function1(n-2) + function1(n-3) + n;

return comp;
}
}

// The main calls function1 by entering an integer given by a user.
void main()
{
int ans, n;

printf("Enter an integer:\n");

// read an integer from user and store it in "n"
scanf("%d", &n);

ans = function1(n);

// print out the solution computed by function 1
printf("The solution is: %d\n", ans);

return;
}

The following is a sample output (user input is in bold):

Enter an integer:
8
The solution is: 527



What to turn in:

-Upload your assignment7.s file through the assignment submission link in the Blackboard by the assignment deadline. You must have your name, email address, program description, and other information in the header block as it was described in the assignment 1, and your programs should be well commented.

Each procedure needs to have a header using the following format:


# Procedure findMax
# Description:
# parameters: $a0 = address of array, $a1 = length
# return value: $v0 = max
# registers to be used: $s3 and $s4 will be used.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 03:10
This program reads a file called 'test.txt'. you are required to write two functions that build a wordlist out of all of the words found in the file and print all of the unique words found in the file. remove punctuations using 'string.punctuation' and 'strip()' before adding words to the wordlist. write a function build_wordlist() that takes a 'file pointer' as an argument and reads the contents, builds the wordlist after removing punctuations, and then returns the wordlist. another function find_unique() will take this wordlist as a parameter and return another wordlist comprising of all unique words found in the wordlist. example: contents of 'test.txt': test file another line in the test file output: ['another', 'file', 'in', 'line', 'test', 'the']
Answers: 1
question
Computers and Technology, 22.06.2019 09:40
Sarah is having a hard time finding a template for her advertising business that she may be able to use at a later date and also make it available to her colleagues
Answers: 1
question
Computers and Technology, 22.06.2019 19:00
Which parts of a presentation should be the most general? a. introduction and conclusion b. introduction and outline c. outline and conclusion d. outline and body
Answers: 1
question
Computers and Technology, 23.06.2019 10:50
Your friend kayla is starting her own business and asks you whether she should set it up as a p2p network or as a client-server network. list three questions you might ask to kayla decide which network to use and how her answers to those questions would affect your recommendation.
Answers: 2
You know the right answer?
You are required to turn in the following source file:

assignment7.s

Objecti...
Questions
question
Mathematics, 01.07.2019 03:50