Search This Blog

Thursday, March 25, 2010

How to create a DLL in VC++ and use Assembly code in it?

Create a DLL in VC++ and use assembly code in it.
----------------------------------------------------
sysinfo.h

#include
extern "C" __declspec(dllexport) int __stdcall getCPUFamily());


---------------------------------------------------------------------
sysinfo.cpp

#include "SysInfo.h"
extern "C" __declspec(dllexport) int __stdcall getCPUFamily() {
    int retVal;
 //This is how to use assembly code
    _asm {
        mov eax, 1
        cpuid
        mov retVal, eax
    }

    return (retVal >> 8);
}

No comments:

Post a Comment