Question

39. Rewrite the following C code segment in x86 (assume bs kebx) x86 switch (b) case 1 case 2: case 3: default: return Walpha

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

Ans 40 : The definition of leaf function is a function that does not call other functions inside. The given function is calling square. So, This is not an example of leaf function.

Add a comment
Answer #2

39: Rewritten code in assembly X86 system language where b=%rbx:

SWITCH, b
CASE1
STATUS, X ; If the case1 is true, then it will return 'alpha' which is TEST1
TEST1
CASE2^CASE1
STATUS, X ; If the case2 is true, then it will return 'beta' which is TEST2
TEST2
CASE3^CASE2
STATUS, X ; If the case3 is true, then it will return 'gamma' which is TEST3
TEST3
CASE1^CASE3
TEST4           ; If none of the above is true, then it will return 'delta' which is TEST4

40. The following function does not qualify as a leaf function:

int quadratic(int x, int a, int b, int c)

{

return a*square(x)+b*x+c;

}

A leaf function is a function which can not call any other function because it’s the last set of operations of an already predefined function. Think of it like a binary tree, all the bottom nodes where no branches are expanded anymore, are the leaf functions.

The above function could be a leaf function if it hadn’t called any function itself, like square(x), which is calling a function square() to get a squared value of a variable. Hence, the function could not be considered as a leaf function.

41. When the GCC calling conventions are being used, the program contains three part of the function, one is the function prolog, body of a function and in the end, epilog of a function.

Function prolog is starting from all the variable declaration to all the meaningful operations in a function. Variable declaration is the very first statement which starts the prolog of a function.

42. When the GCC calling conventions are being used, the program contains three part of the function, one is the function prolog, body of a function and in the end, epilog of a function.

Function epilog is the process of returning the value of the variable to the Calle prior to ending the function. Usually, print statement or return statement initiates the epilog of a function to clear the memory of the stack prior to ending the program after all the calculations that are being done in the function and the resulted output is being send to the Calle variable.

Add a comment
Know the answer?
Add Answer to:
39. Rewrite the following C code segment in x86 (assume bs kebx) x86 switch (b) case...
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 java and write in text a. Rewrite the following code segment using if statements. Assume...

    use java and write in text a. Rewrite the following code segment using if statements. Assume that grade has been declared as of type char. char grade= 'B';; switch (grade) { case 'A': System.out.println("Excellent"); break case 'B': System.out.println("Good"); default: System.out.println("you can do better”); } - b. write Java code that inputs an integer and prints each of its digit followed by ** e.gif the integer is 1234 then it should print 1**2**3**4 e.g. if the integer is 85 then it...

  • I keep getting an error code in my C++ program. It says "[Error] 'strlen' was not...

    I keep getting an error code in my C++ program. It says "[Error] 'strlen' was not declared in this scope" in my main.cpp. Here are my codes. main.cpp #include <iostream> #include <string> #include "functions.h" using namespace std; //definition of the main function. //takes arguments from the command-line. int main(int argc, char *argv[]) { //Determine if you have enough arguments. //If not, output a usage message and exit program if (argc<2 || (argc == 2 && argv[1][0] == '-')) { //call...

  • LANGUAGE IS C++ Lab Ch14 Recursion In this lab, you are provided with startup code which...

    LANGUAGE IS C++ Lab Ch14 Recursion In this lab, you are provided with startup code which has six working functions that use looping (for, while, or do loops) to repeat the same set of statements multiple times. You will create six equivalent functions that use recursion instead of looping. Although looping and recursion can be interchanged, for many problems, recursion is easier and more elegant. Like loops, recursion must ALWAYS contain a condition; otherwise, you have an infinite recursion (or...

  • ASSIGNMENT DUE DATE GOT PUSHED BACK TO LATE THIS WEEK. PLEASE READ COMMENTS AND CODE BEFORE...

    ASSIGNMENT DUE DATE GOT PUSHED BACK TO LATE THIS WEEK. PLEASE READ COMMENTS AND CODE BEFORE ANSWERING CODING SECTIONS HW07 #Q1-Q5 HW08 #Q1-Q2 // READ BEFORE YOU START: // Please read the given Word document for the project description with an illustrartive diagram. // You are given a partially completed program that creates a list of students for a school. // Each student has the corresponding information: name, standard, and a linked list of absents. // Please read the instructions...

  • Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate...

    Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate the number of test scores the user enters; have scores fall into a normal distribution for grades -Display all of the generated scores - no more than 10 per line -Calculate and display the average of all scores -Find and display the number of scores above the overall average (previous output) -Find and display the letter grade that corresponds to the average above (overall...

  • // CSE240 Spring 2019 HW 7 & 8 // Write your name here // Write the...

    // CSE240 Spring 2019 HW 7 & 8 // Write your name here // Write the compiler used: Visual studio or gcc // READ BEFORE YOU START: // You are given a partially completed program that creates a linked list of patient information. // The global linked list 'list' is a list of patients with each node being struct 'patientList'. // 'patientList' consists of struct 'patient' which has: patient name, room number, and a linked list of 'doctors'. // The...

  • Exercise #1: Write a C program that contains the following steps (make sure all variables are...

    Exercise #1: Write a C program that contains the following steps (make sure all variables are int). Read carefully each step as they are not only programming steps but also learning topics that explain how functions in C really work. Ask the user for a number between 10 and 99. Write an input validation loop to make sure it is within the prescribed range and ask again if not. Commenting out the existing coding, write the code to divide a...

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