This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ogram counter into an integer register. B.3. MACHINE LEVEL REPRESENTATION OF C PROGRAMS
Problem 3.15 Solution: [Pg. 136] 707 This problem makes concrete the discussion of register usage conventions. Registers %edi, %esi, and %ebx are callee save. The procedure must save them on the stack before altering their values and restore them before returning. The other three registers are caller save. They can be altered without affecting the behavior of the caller. Problem 3.16 Solution: [Pg. 139] Being able to reason about how functions use the stack is a critical part of understanding compiler-generated code. As this example illustrates, the compiler allocates a signiﬁcant amount of space that never gets used. A. We started with %esp having value 0x800040. Line 2 decrements this by 4, giving 0x80003C, and this becomes the new value of %ebp. B. We can see how the two leal instructions compute the arguments to pass to scanf. Since arguments are pushed in reverse order, we can see that x is at offset relative to %ebp and y is at offset . The add...
View Full Document
- Spring '10
- The American