Question

The table shows the PPT functions we learned in class. You will try to get the sum of 0 to N. First, modify the following fun

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Translation of given function in C to ARM code:
function(int):
push rbp
mov rbp, rsp
sub rsp, 16
mov DWORD PTR [rbp-4], edi
cmp DWORD PTR [rbp-4], 0
jg .L2
mov eax, 1
jmp .L3
.L2:
mov eax, DWORD PTR [rbp-4]
sub eax, 1
mov edi, eax
call function(int)
imul eax, DWORD PTR [rbp-4]
.L3:
leave
ret


Process by substituting 3 for N value:

call function(int)

imul eax, DWORD PTR [rbp-4]

.L3:

leave

ret

main:

push rbp

mov rbp, rsp

sub rsp, 16

mov DWORD PTR [rbp-4], 3

mov eax, DWORD PTR [rbp-4]

mov edi, eax

call function(int)

mov eax, 0

leave

ret

Add a comment
Know the answer?
Add Answer to:
The table shows the PPT functions we learned in class. You will try to get the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use the Summation recursive program you did in the class to also work with minus integers....

    Use the Summation recursive program you did in the class to also work with minus integers. For example, the sum of -3 will be -6 which is (-3)+(-2)+(-1)+0. USE THIS CODE package project5; import java.util.Scanner; public class SingleRecursion { /** Main method */ public static long sum(int n) {    if (n<0) throw    new IllegalArgumentException ("Can't calculate factorial of negative");    if (n==1)        return 1;    else if (n==0)        return 1;    else       ...

  • Write the definitions of the member functions of the class integerManipulation not given in Example 10-11....

    Write the definitions of the member functions of the class integerManipulation not given in Example 10-11. Also, add the following operations to this class: Split the number into blocks of n-digit numbers starting from right to left and find the sum of these n-digit numbers. (Note that the last block may not have ndigits. If needed add additional instance variables.) Determine the number of zeroes. Determine the number of even digits. Determine the number of odd digits Also, write a...

  • Get the file “HW4Part4a.java” from the repository. Modify the program class to match the new file...

    Get the file “HW4Part4a.java” from the repository. Modify the program class to match the new file name. Complete it by writing a recursive static int function named “pow2” with one parameter, an integer n. The function is defined as follows: if n ≤ 0 then pow2(n) = 1. Otherwise, pow2(n) = 2 · pow2(n − 1). public class HW4Part4a { public static void main(String[] args) { for (int i = 0; i <= 20; i++) { System.out.println("pow2("+i+") = "+pow2(i)); }...

  • Please try to explain the answers as well. It will be highly appreciated. Output of the...

    Please try to explain the answers as well. It will be highly appreciated. Output of the following expression: 5 * 4 % 2 = ? Output of a loop: Example: What will be the output of the Java code (Assume all variables are properly declared.) num = 10; while (num <= 32)                 num = num + 5; System.out.println(num); What will be the output of the Java code (Assume all variables are properly declared.) public class test {   ...

  • Use c++ to code: Problem 1 Implement a class Clock whose get hours and get_minutes member functions return the current...

    Use c++ to code: Problem 1 Implement a class Clock whose get hours and get_minutes member functions return the current time at your location. To get the current time, use the following code, which requires that you include the <ctime>header time_t current_time time (e); ta local time - localtime(current, tine)i int hours -local_time->tm hour int minutes-local time->tm_min; Also provide a get_time member function that returns a string with the hours and minutes by calling the get_hours and get_minutes functions. Provide...

  • C++ Object Oriented assignment Can you please check the program written below if it has appropriately...

    C++ Object Oriented assignment Can you please check the program written below if it has appropriately fulfilled the instructions provided below. Please do the necessary change that this program may need. I am expecting to get a full credit for this assignment so put your effort to correct and help the program have the most efficient algorithm within the scope of the instruction given. INSTRUCTIONS Create a fraction class and add your Name to the name fraction and use this...

  • ​​​​​ You should now be able to edit the IntTree class. Implement each of the functions labeled...

    ​​​​​ You should now be able to edit the IntTree class. Implement each of the functions labeled with You are not allowed to use any kind of loop in your solutions. You may not modify the Node class in any way You may not modify the function headers of any of the functions already present in the file. You may not add any fields to the IntTree class. You may not change or remove the line that reads “package hw2;”...

  • class AVLTree The following functions are the minimum requirements for the AVL class. You can add...

    class AVLTree The following functions are the minimum requirements for the AVL class. You can add any function from Assignment 2 to this class. You should modify the BSTree insert function so that the tree remains balanced after each insertion. Required Public Member Functions void insert(const string &): Insert an item to the binary search tree and perform rotation if necessary. int balanceFactor(Node*): Return the balance factor of a given node. void printBalanceFactors(): Traverse and print the tree in inorder...

  • Solve using C programming 3. lf you are given this code. #include <stdio.h> int main() int...

    Solve using C programming 3. lf you are given this code. #include <stdio.h> int main() int var1, var2; int sum; printf("Enter number 1:\n "); scanf("%d",&var1); printf("Enter number 2:In ); scanf("%d",&var2); sum-var1+var2; printf ("Vnsum of two entered numbers : %d", //printf ("Output: %d", res); sum); return e; Modify this code by creating a function called "addition". Make the arguments of the functions numberl and number 2. Add the two values in the function. Return a value called "result". Print "result" in...

  • Please help with this coding problem, and use the ARM sim# to test run your code....

    Please help with this coding problem, and use the ARM sim# to test run your code. Implement functions in assembly language. You are asked to write a program to compute the Fibonacci numbers, using recursive function calls. Fib(n){if (n == 0 || n == 1) return 1; else return Fib(n-2) + Fib(n-1);}

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT