There is more of importance of keeping compatibility with platforms.
There are cases where there is no gain going to asm. Number one asm does not optimize by most compliers. So can not be processed out by the complier. Ie block of code called with all constant values and a constant result. Many not even exist in the completed binary.
Poor Example
- Code: Select all
void reducing() {
int c,a;
c=10;
a=c+5;
c=a;
};
A function like this would not even exist in completed code. Because the complier knows it does nothing. It would simplely be removed by the optimiser.
Now if you put some asm in there the complier is no longer sure.
Note compliers like gcc and msvc will produce a lot of MMX/3DNow!/SSE code from C just by telling it to build for a processor supporting it. And in some cases turning on options.
Its not only compatibility with aging processors. There are still new X86 compatible processors produced where CPUID is optional. Transmedia processors for one.
Asm is for special things. Really special things. Using it can have real negative effects.
The best way of handling processor depend features is not cpuid because that can get you into trouble. The best way is as hto said GetSystemInfo(). If it needs to be patched for the reason that CPUID is missing or not working ie chip broken. Your code will still work.
Also other version functions. With dlls have exports as points to functions when dll is loaded points set to the correct functions for current processor.
Yes it is possible to build a C files with different processor options and bind it into one dll. So the speed boost can be gained in some cases without droping to asm. Lot simpler in the long run. Since if setup right the C code can be exactly the same for all processor types. Even that it performs a lot differently at run time. Spliting of functions inside C is done by using the complier command line define so that the start of the function gets named processor type.
There is more than one way of getting to the same end resualt.
Some are simpler to look after.
If working at kernel level there should be a equal function to GetSystemInfo().
Please just don't use ASM because you think it will be faster. It better be faster than what the C complier will produce.