Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C2A2E3 (6 points - Table only - No program required) Figure 8 of note 12.4D and figure 5 of note 12.6C in the course book
C2A2E3 (6 points - Table only - No program required) Figure 8 of note 12.4D and figure 5 of note 12.6C in the course book illustrate the final state of call stacks before any function returns have begun. Your task is to create a similar diagram in instructor-supplied text file C2A2E3_StackDiagram.txt to represent the operation of the program below. Assume: - Any necessary header files and prototypes are present. - "C" calling convention - short: 3 bytes, int: 6 bytes, long: 7 bytes, addresses(pointers): 8 bytes int main() \{ long result = ready(); "startup return 0 ; short ready() { int temp =gcd(125,50); return temp; long gcd(int x,shorty) \{ if (y==0) return x; return gcd(y,x%y); int main() - The "startup" function calls main. Procedure and Requirements: Please refer to file C2A2E3_StackDiagram.txi while reading the following requirements. It contains: 1. A title block. 2. An empty stack diagram for your stack information. 3. A sample stack diagram (for a different program) that illustrates the required format and syntax. IMPORTANT: The assignment checker analyzes your diagram and provides an error report. If you do not use the required format and syntax, the report may be inaccurate and you could lose significant credit. 1. Modify the C2A2E3_StackDiagram.txt title block to contain your own information and add the following two-item "startup" stack frame to the empty stack diagram: BP+8hBP82Ch824h1017h0hFunctionReturnAddressPreviousFrameAddress(8bytes)(8bytes) 2. After reading the "Optional Suggestion" on the next page, complete the stack diagram by pushing items for any additional frames: a. There must be a dividing line before each frame that indicates the name of the function it represents. If the function is being used recursively, that name must be followed by a space and a number indicating the frame's recursive level. b. If a stack item represents a variable, place its name in the "Description" column. Continued on the next page... 3. Numeric values must be decimal or hexadecimal according to the guidelines below. Decimal values do not have a suffix while hexadecimal values must have an h suffix. a. The values of variables x and y and the number of bytes in each item must be decimal. b. All addresses must be hexadecimal. c. The BP offset values of relative addresses may be decimal or hexadecimal. 4. Use a double question mark for the values of: a. All return objects. b. Variables that are assigned values after a function returns. c. Values for which insufficient information is provided. 5. General formatting: a. "Hard" tab characters are not allowed. b. Columns must be aligned and there must be nothing between them but spaces. c. Do not number lines or add additional information. d. No line may exceed 80 columns. 6. Before submitting your modified C2A2E3_StackDiagram.txt file to the assignment checker, delete everything in it except your modified title block and completed stack diagram. Waypoints: Verifying the following can help you determine if there might be a problem: 1. There should be exactly 25 items on the stock. 2. There should be exactly 8 double question mark stack values. 3. The gcd function should have 3 stack frames, each containing 5 items. 4. The absolute address of the last item in the last stack frame should be 78Eh. Optional Suggestion: As each item is pushed onto the stack, I suggest only populating its "Description" and "Item Size" fields. Once this is complete, go back through the items again and populate just the "Abs Adr" field, then do it twice more for the "Rel Adr" and "Stack Value" fields. I recommend this order because the "Rel Adr" BP offset values depend upon values in other fields. The only downside of this approach is that slightly more effort is needed to align columns
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started