Preserving x64 floating point registers from your C/C++ code.
In a previous article I explained how to preserve the x64 floating point registers.
In this article I’m going to provide some code that allows you preserve the x64 floating point registers from your C/C++ code. This will include a tiny bit of x64 assembler, but you’ll never need to call the assembler, its hidden behind a wrapper.
I’m going to provide an API that consists of two functions and a datastructure that should never be inspected. You can align the datastructure how you like, so you can use this in code that has whatever byte packing behaviour you want. The code will take that into account and always save and restore the floating point data correctly without altering the byte packing behaviour.