This just cannot be done in C#.
I suppose you want to use the MMX instruction set to do this.
You should build a library in C/C++ which
- Checks if the processor has the MMX instruction set.
- Emit assembly code for using MMX.
- If the processor does not support MMX, you'll have to supply a fallback using normal calculations.
Do not call this library for every calculation you want to perform: gather a fair bit of application data, and then P/Invoke your lib to do a series of calculations. If you call your library for every calculation, the overhead of P/Invoke will easily negate any performance gain, and your program will be slower than if you'd just let the CLR do it's thing.
A nice writeup on this can be found
Here[
^]