This preview shows page 1. Sign up to view the full content.
Unformatted text preview: B's variables. This does not mean that procedure C is completely isolated from procedure B; procedure C is called by procedure B, so the pointer to the returning stack frame is a pointer to procedure B's stack frame. In addition, procedure B can pass parameters to procedure C either on the stack or through variables global to both procedures (that is, variables in the scope of both procedures). Old EBP Main's EBP Main's EBP Main's EBP Procedure A's EBP Procedure A's EBP Display Main's EBP Procedure A's EBP Procedure B's EBP Dynamic Storage EBP ESP Figure 6-9. Stack Frame After Entering Procedure B 6-24 Vol. 1 PROCEDURE CALLS, INTERRUPTS, AND EXCEPTIONS Old EBP Main's EBP Main's EBP Main's EBP Procedure A's EBP Procedure A's EBP Main's EBP Procedure A's EBP Procedure B's EBP Procedure B's EBP Display Main's EBP Procedure A's EBP Procedure C's EBP Dynamic Storage EBP ESP Figure 6-10. Stack Frame After Entering Procedure C Vol. 1 6-25 PROCEDURE CALLS, INTERRUPTS, AND EXCEPTIONS 6.5.2 LEAVE Instruction The LEAVE instruction, which does not have any operands, reverses the action of the previous ENTER instruction. The LEAVE instruction copies the contents of the EBP register into the ESP register to release all stack space allocated to the procedure. Then it restores the old value of the EBP register from the stack. This simultaneously restores the ESP register to its original value. A subsequent RET instruction then can remove any arguments and the return address pushed on the stack by the calling program for use by the procedure. 6-26 Vol. 1 CHAPTER 7 PROGRAMMING WITH GENERAL-PURPOSE INSTRUCTIONS
General-purpose (GP) instructions are a subset of the IA-32 instructions that represent the fundamental instruction set for the Intel IA-32 processors. These instructions were introduced into the IA-32 architecture with the first IA-32 processors (the Intel 8086 and 8088). Additional instructions were added to the general-purpose instruction set in subsequent families of IA-32 processors (the Intel 286, Intel386, Intel486, Pentium, Pentium Pro, and Pentium II processors). Intel 64 architecture further extends the capability of most general-purpose instructions so that they are able to handle 64-bit data in 64-bit mode. A small number of general-purpose instructions (still supported in non-64-bit modes) are not supported in 64-bit mode. General-purpose instructions perform basic data movement, memory addressing, arithmetic and logical, program flow control, input/output, and string operations on a set of integer, pointer, and BCD data types. This chapter provides an overview of the general-purpose instructions. See Intel 64 and IA-32 Architectures Software Developer's Manual, Volumes 3A & 3B, for detailed descriptions of individual instructions. 7.1 PROGRAMMING ENVIRONMENT FOR GP INSTRUCTIONS The programming environment for the general-purpose instructions consists of the set of registers and address space. The environment includes the following items: General...
View Full Document
This note was uploaded on 10/01/2013 for the course CPE 103 taught by Professor Watlins during the Winter '11 term at Mississippi State.
- Winter '11