Search code examples
cassemblyx86standard-library

Should you backup registers before calling a C Standrd Library function?


  • In assembly, should you backup registers before calling a C Standard Library function?
  • Does the Standard Library guarantee that all of its functions backup the caller's registers and recover them in the end?
  • Where can I find official information about this matter?

Solution

  • It is platform specific, usually you don't need to specifically save and restore registers at the call site, the callee usually does it. You just need to follow the linkage convention for your particular platform. The C-library is not state-less, it is generally not a good idea to just call some functions without initializing the library as it is done in a typical c program object which contains main().