How to verify that assembly code preserves registers correctly for Windows 2000 or Windows XP (232587)



The information in this article applies to:

  • Microsoft Win32 Application Programming Interface (API), when used with:
    • the operating system: Microsoft Windows 2000
    • the operating system: Microsoft Windows XP

This article was previously published under Q232587

SUMMARY

When your applications for Microsoft Windows 2000 or Microsoft Windows XP include assembly-language code that uses CPU registers, make sure that the following registers contain the same value when you leave a procedure as they did when you entered the procedure:
  • ESI
  • EDI
  • ESP
  • EBP
This is required both when you're developing modules that are written entirely in assembly language and also when you are using the Visual C compiler's inline assembler. This does not apply to programs written entirely in Visual C or Visual C++.

Registers are preserved on the stack with a PUSH instruction at the beginning of a procedure and restored from the stack with a POP instruction before the procedure returns.

REFERENCES

For more information about using assembly-language code and the inline assembler, see Assembler (Inline): Overview topic in the Adding Program Functionality section of the Visual C++ Programmer's Guide. This documentation is available online at:

Modification Type:MajorLast Reviewed:11/16/2004
Keywords:kbhowto kbKernBase KB232587