◄Up► ◄Contents► ◄Index► ◄Back► ─────C/C++ Language───────────────────────────────────────────────────────── Keyword: __saveregs Syntax: __saveregs declarator Summary: Saves and restores CPU registers when entering and exiting a function, respectively. See also: __loadds, __interrupt, __export 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 ); -♦-