About two years ago we decided to merge our two trees of 32-bit and 64-bit assembly; it had become a maintainability nightmare with many functions in one that were not in the other and so forth. Loren Merritt did this merging by adding an abstraction layer that automatically handles differences in calling convention between platforms (and was extensible to future ones as well). Thus began the story of common/x86/x86inc.asm.
Over the years, x86inc has grown tremendously as it gained a great deal of functionality. It now supports x86_32, x86_64, and win64 (thanks to Anton Mitrofanov), which covers the three (by far) most popular x86 C calling conventions. It also has macros to abstract between MMX and SSE functions, along with automatic handling of register permutations and other such useful features.
All of this serves to make x264ASM, as we call it, by far the best option for writing platform-independent x86 assembly. It keeps the full optimization capabilities and powerful preprocessor of native assembly while having the platform-independence and convenience of instrinsics and inline assembly.
We’ve received many requests by non-GPL projects (and even commercial proprietary developers) to be able to use this abstraction layer. And now, it’s available under a permissive BSD-like license (specifically the ISC) for anyone to use, on request by a certain Adobe engineer.
Before you jump into the x264 code to see how it’s used, however, let’s go over some of the basics. Note of course this explanation is no substitute for reading x86inc.asm itself.
Read More…