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 18:30
Which cultural aspect does this type of song best portray? a german polka dance
Answers: 1
question
Computers and Technology, 22.06.2019 22:10
Asequential circuit contains a register of four flip-flops. initially a binary number n (0000 ≤ n ≤ 1100) is stored in the flip-flops. after a single clock pulse is applied to the circuit, the register should contain n + 0011. in other words, the function of the sequential circuit is to add 3 to the contents of a 4-bit register. design and implement this circuit using j-k flip-flops.
Answers: 1
question
Computers and Technology, 23.06.2019 17:00
The camera still is bad even with the new iphone xr and especially in low light it is even worst because you can see the pixels more if its in low light. if all you apple customers want apple to fix this then lets fill there feedback with complaints about the can apple do to fix this issue?
Answers: 1
question
Computers and Technology, 23.06.2019 18:30
Report all segments of identity by descent longer than 20 polymorphisms between pairs of individuals in the following cohort of 15 individuals across 49 polymorphisms: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 numeric input 2 points possible (graded) you have 2 attempts to complete the assignment below. for example if the sequence is "bcd", which occurs in "abcdef" , the starting point would be 2 (b), and the finishing point would be 4(d). individuals 7,10 between positions
Answers: 1
You know the right answer?
You are required to turn in the following source file:

assignment7.s

Objecti...
Questions
question
History, 20.05.2021 19:10
question
Mathematics, 20.05.2021 19:10
Questions on the website: 13722367