1. The function fun a has the overall structure shown below: long fun a(unsigned long x){...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. The function fun a has the overall structure shown below: long fun a(unsigned long x){ long val 0; while ( ){ } = return val; # x in %rdi fun a: .L6: .L5: mov imp хося sh.ca $0, %eax .L5 %rdi, %rax %rdi # shift right 1 testa %rdi, %rdi ine .L6 andl $1, %eax ret } The gcc C compiler generates the x86-64 assembly code on the right. Reverse engineer this assembly code and fill in the missing parts of the fun a definition so the C code does the same thing. 1. The function fun a has the overall structure shown below: long fun a(unsigned long x){ long val 0; while ( ){ } = return val; # x in %rdi fun a: .L6: .L5: mov imp хося sh.ca $0, %eax .L5 %rdi, %rax %rdi # shift right 1 testa %rdi, %rdi ine .L6 andl $1, %eax ret } The gcc C compiler generates the x86-64 assembly code on the right. Reverse engineer this assembly code and fill in the missing parts of the fun a definition so the C code does the same thing.
Expert Answer:
Answer rating: 100% (QA)
The image shows two panels side by side The left panel contains the skeleton structure for a C funct... View the full answer
Related Book For
Computer Systems A Programmers Perspective
ISBN: 9781292101767
3rd Global Edition
Authors: Randal E. Bryant, David R. O'Hallaron
Posted Date:
Students also viewed these algorithms questions
-
A function test_one has the following overall structure: Reverse engineer the operation of this code and then do the following: A. Determine what loop translation method was used. B. Use the...
-
7. Arrange the following nitrogen containing compounds in decreasing order of basicity NH NH -H (P) (a) S>R>Q> P NO (R) (2) (b) P>Q>S>R -H (S) (c) P>Q>R>S (d) R>Q> P > S
-
Choose five U.S. government policies that affect trade with foreign nations. Identify three factors of production, and describe how their mobility is good or bad for U.S. trade 2. Distinguish between...
-
In a random sample of males, it was found that 23 write with their left hands and 217 do not. In a random sample of females, it was found that 65 write with their left hands and 455 do not (based on...
-
Where is the place of UML in the process of software development?
-
Mystic Herbals processes exotic plant materials into various fragrances and biological pastes used by perfume and cosmetic firms. One particular plant material, Xubonic root from the rain forest in...
-
The Outlet Mall has a cost of equity of 15.39 percent, a pretax cost of debt of 8.3 percent, and a return on assets of 12.48 percent. Ignore taxes. What is the debt-equity ratio?
-
Peter Piper has applied for a mortgage of $120,000. Interest is computed at 8.5 percent compounded semiannually. The mortgage will be paid off over 20 years. a. Calculate Peter's monthly payment. b....
-
Consider the signaling model of educational choice. Assume that a low ability majority individual has the same productivity as a low ability minority (both have marginal productivity of 5) and a high...
-
Suppose TCPs measured RTT is 1.0 except that every Nth RTT is 4.0. What is the largest N, approximately, that does not result in timeouts in the steady state (i.e., for which the Jacobson/Karels...
-
In the following list, you will find pairs of individuals. For each pair, check your ASSIGNMENT 6.2 state code and answer three questions: Can the individuals marry? If the marriage is prohibited, is...
-
Show that the Internet checksum can be computed by first taking the 32-bit ones complement sum of the buffer in 32-bit units, then taking the 16-bit ones complement sum of the upper and lower...
-
a. Is your state statutory code on the Internet? If so, give its address (uniform resource locator or URL) and quote from any statute on this site that covers divorce. b. Try to find the Internet...
-
Predict the solubility (in mole fraction) of phenol at the cited conditions using the specified model. (i) Use the MAB model. (ii) Use the SSCED model. (iii) Use the UNIFAC model. (a) Solubility in...
-
The average expenditure of a man for the first seven months is Rs. 140 and for the next five months it is Rs. 110. If he saves Rs. 330 in that year, his monthly average income is : 1. Rs. 140 2. Rs....
-
Read the following description and Write a response of it. The discretion of public administrators can be decreased, but not altogether eliminated. Officials will use their discretion in any given...
-
The problems that follow will help reinforce your understanding of how caches work. Assume the following: . The memory is byte addressable. . Memory accesses are to 1-byte words (not to 4-byte...
-
Suppose we want to generate assembly code for the following C function: The code that follows is a portion of the assembly code that performs the actual shifts and leaves the final value in register...
-
The traditional implementation of the merge step of mergesort requires three loops [98]: The branches caused by comparing variables i1 and i2 to n have good prediction performancethe only...
-
Find the conditional distribution of happiness by marital status for the data in Table 9. Then draw a bar graph that represents the conditional distribution of happiness by marital status. Approach...
-
One growing concern regarding the U.S. economy is the inequality in the distribution of income. The data in Table 1 represent the distribution of household income for various levels of income in...
-
One growing concern regarding the U.S. economy is the inequality in the distribution of income. An economist wants to know if the distribution of income is changing, so she randomly selects 1500...
Study smarter with the SolutionInn App