Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Draw stack for C code. Consider the following C code fragment: and the following

ID: 3817389 • Letter: D

Question

Draw stack for C code.

Consider the following C code fragment:

and the following two C function definitions:

Example of stack going downwards:

Be as complete as possible, indicating values on the stack if known (e.g., “12”) or, if unknown, the name of the parameter/variable (e.g., “x = ?”). When indicating return addresses on the stack, whenever possible include the function returned to (e.g., “Return @ to f” as opposed to “Return @”). Assume that only the EBP register is saved by all the functions, and that the C calling convention is respected. You can assume that local variables are stored on the stack in the order in which they appear in the code (not in reverse order).

Hint: There should be 13 elements on the stack.

a -12 Saved EBP Return to h y E 12. Saved EBP 42 Return a to foo

Explanation / Answer

Stack will be as below:

x=2 y=4 Saved EBP a= 6 (3*2) stuff = 13 Saved EBP a= 6 b = 2 (b=x) c = 13 (c= stuff) z=? z = 78 (a*c) a = 10
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote