Instructions for asmlib
A multi-platform library of highly optimized functions for C and C++.
By Agner Fog. © 2008. GNU General Public License.
Version 2.00. 2008-09-06.
Contents
1 Introduction .......................................................................................................................1
1.1 Support for multiple platforms .....................................................................................2
1.2 Calling from other programming languages ................................................................2
1.3 Position-independent code..........................................................................................2
1.4 Overriding standard function libraries..........................................................................2
1.5 Comparison with other function libraries .....................................................................3
2 Standard library functions..................................................................................................4
2.1 memcpy......................................................................................................................4
2.2 memmove...................................................................................................................4
2.3 memset.......................................................................................................................5
2.4 strcat...........................................................................................................................5
2.5 strcopy........................................................................................................................5
2.6 strlen...........................................................................................................................6
3 Random number generator functions ................................................................................ 6
3.1 Mersenne Twister .......................................................................................................6
3.2 Mother-of-all generator ...............................................................................................7
4 Other functions..................................................................................................................8
4.1 round .......................................................................................................................... 8
4.2 InstructionSet..............................................................................................................8
4.3 ProcessorName..........................................................................................................9
4.4 ReadTSC....................................................................................................................9
4.5 Serialize.................................................................................................................... 10
5 Library versions...............................................................................................................10
6 File list.............................................................................................................................11
7 License conditions........................................................................................................... 12
8 No support.......................................................................................................................12
1 Introduction
Asmlib is a function library to call from C or C++ for all x86 and x86-64 platforms. It includes:
• Faster versions of several standard C functions.
• Efficient random number generators.
• Functions that are often missing in standard libraries: round, etc.
• Functions for identifying the microprocessor and for testing speed, etc.
These functions are written in assembly language for the sake of optimizing speed. Many of
the functions have multiple branches for different instruction sets, such as SSE2, SSE3, etc.
These functions will automatically detect which instruction set is supported by the computer
it is running on and select the optimal branch.
The latest version of asmlib is always available at www.agner.org/optimize
.