Concept explainers
For this exercise, we will examine the code generated by GCC for functions that have structures as arguments and return values, and from this see how these language features are typically implemented.
The following C code has a function process having structures as argument and return values, and a function values, and a function eval that tails process.
Gcc generates the following code for these two functions:
A. We can see on line 2 of function eval that it allocates 104 bytes on the stack. Diagram the stack frame for oval, showing the:Nal= that it stores on the stack prior to calling process. B. What value does eval pass in its call to process?
C. How does the code for process access the elements of structure arguments?
D. How does the code for pro cess set the fields of result structure r?
E. Complete your diagram of the stack frame for eval, showing how eval accesses the elements of structure r following the return from process.
F. What general principles can you discern about how structure values are passed as function arguments and how they are returned as function results?
Learn your wayIncludes step-by-step video
Chapter 3 Solutions
EBK COMPUTER SYSTEMS
Additional Engineering Textbook Solutions
Starting Out With Visual Basic (8th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Absolute Java (6th Edition)
Starting Out with C++: Early Objects
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY