HOWTO: Verify That Assembly Code Preserves Registers Correctly For Windows 2000

ID: Q232587

This article discusses a Beta release of a Microsoft product. The information in this article is provided as-is and is subject to change without notice.

No formal product support is available from Microsoft for this Beta product. For information about obtaining support for a Beta release, please see the documentation included with the Beta product files, or check the Web location from which you downloaded the release.
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API), included with:
    • Microsoft Windows 2000
      on the following platforms: x86

This article discusses a Beta release of a Microsoft product. The information in this article is provided as-is and is subject to change without notice.

No formal product support is available from Microsoft for this Beta product. For information about obtaining support for a Beta release, please see the documentation included with the Beta product files, or check the Web location from which you downloaded the release.

SUMMARY

When your applications for Windows 2000 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:

http://msdn.microsoft.com/library/devprods/vs6/visualc/vccore/_core_assembler_.28.inline.293a_.overview.htm

Additional query words: compatguidestability

Keywords : kbKernBase kbWinOS2000 kbSDKPlatform kbSDKWin32
Version : winnt:
Platform : winnt
Issue type : kbhowto


Last Reviewed: September 24, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.