KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q67357: Void _saveregs Function Does Not Preserve AX Register

Article: Q67357
Product(s): See article
Version(s): 
Operating System(s): 6.00 6.00a | 6.00 6.00a
Keyword(s): MS-DOS | OS/2 | mspl13_c
Last Modified: 15-FEB-1991

ENDUSER | s_quickc buglist6.00 buglist6.00a

Functions with a void return type that are declared with the _saveregs
attribute do not preserve the AX register. An arbitrary return value
is stored in AX unnecessarily.

The C online help states the following:

   The _saveregs keyword causes the compiler to generate code that
   saves and restores all CPU registers when entering and exiting the
   specified function. Note that _saveregs does not restore registers
   used for a return value (the AX register, or AX and DX).

The second sentence states that AX will not be preserved whenever
there is a return value, but a void function has no return value.
Thus, there is no reason the AX register should not be preserved.

Microsoft has confirmed this to be a problem in C versions 6.00 and
6.00a and QuickC version 2.50 (buglist2.50). We are researching this
problem and will post new information here as it becomes available.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.