Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
_saveregs
◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
Keyword: _saveregs
Syntax: _saveregs declarator
Summary: Saves and restores CPU registers when entering and exiting
a function.
The _saveregs keyword is useful in any case in which it is not
certain what the register conventions of the caller might be. For
instance, _saveregs could be used for a general-purpose function
that will reside in a dynamic-link library. Because a function in
a dynamic-link library might be called from any language, you may
choose not to assume Microsoft C calling conventions in some
cases.
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).
It is not possible to declare a function with both the _saveregs
and the _interrupt attributes.
The following statement declares <funcptr> as a far pointer to a
function with no arguments, returning a char pointer. The presence
of _saveregs tells the compiler that the function called through
<funcptr> saves and restores register contents. In this example,
the _loadds keyword also tells the compiler that the target
function loads its own data segment.
char *(_far _saveregs _loadds *funcptr)( void );
-♦-