Microsoft KB Archive/48444

From BetaArchive Wiki

The Interrupt Attribute Pushes Registers on the Stack


5.10 6.00 6.00a 6.00ax 7.00 | 1.00 1.50 MS-DOS | WINDOWS kbprg ---------------------------------------------------------------------- The information in this article applies to: - Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, and 6.0ax - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0 and 1.5 ---------------------------------------------------------------------- SUMMARY ======= The interrupt attribute can be applied to a function to tell the compiler that the function is an interrupt handler. When an interrupt function is called, all registers (except SS) are saved on the stack. Examining the assembler code the compiler generates for an interrupt handler could cause confusion. When compiling without the /G1, /G2, or /G3 switch (these switches inform the compiler to generate 186, 286, or 386 code accordingly. /G3 was first available with C/C++ 7.0) the assembler code appears as it should; however, when using one of the three aforementioned switches, the assembler output may be deceiving in that the registers appear as though they are not being saved on the stack as advertised. This potential misinterpretation results from the use of the PUSHA and PUSHAD instructions. These instructions do not exist in the 8086 instruction set, but do exist in the 80186 and later sets. The PUSHA and PUSHAD instructions push the general purpose registers onto the stack in the following order: AX, CX, DX, BX, SP, BP, SI, DI. The PUSAD instruction is available only on 80386 and later processors. For further information regarding the PUSHA and PUSHAD instructions, you should consult a reference manual for Intel's 80x86-based assembly. MORE INFORMATION ================ The text that follows displays three partial assembler listings of an interrupt handler called func. The second case demonstrates the usage of the 186-, 286-, 386-, and 486-specific instruction PUSHA (for loadall). The third case demonstrates the usage of the 386- and 486- specific instruction PUSHAD. /* Without G1, G2, or G3 */ _func PROC FAR push ax push cx push dx push bx push sp push bp push si push di push ds push es /* With G1 or G2 */ _func PROC FAR pusha ; This pushes all general purpose registers push ds ; for the 80186 processors and above. push es /* With G3 */ _func PROC FAR pushad ; This pushes all general purpose registers push ds ; for the 80386 and later processors. push es Additional reference words: kbinf 1.00 1.50 5.10 6.00 6.00a 6.00ax 7.00 KBCategory: kbprg KBSubcategory: CLngIss

Keywords : kb16bitonly
Issue type :
Technology : kbVCsearch kbAudDeveloper kbPTProdChange kbvc150 kbvc100 kbCCompSearch kbZNotKeyword3 kbCComp510DOS kbCComp600DOS kbCComp600aDOS kbCComp600axDOS kbCVC700DOS

Last Reviewed: May 6, 2001
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.