void GetCPUID()
{
int s1, s2, s3, s4;
_asm
{
mov eax, 00h
xor edx, edx
cpuid
mov dword ptr[ebp - 4], edx
mov dword ptr[ebp - 8], eax
mov eax, 01h
xor ecx, ecx
xor edx, edx
cpuid
mov dword ptr[ebp - 12], edx
mov dword ptr[ebp - 16], eax
}
}
int* GetGPUID()
{
__asm
{
//push ebp
//mov ebp,esp
//sub esp,0C0h
//push ebx
// push esi
// push edi
// lea edi,[ebp-0C0h]
// mov ecx,30h
// mov eax,0CCCCCCCCh
// rep stos dword ptr es:[edi]
mov eax,00h
xor edx,edx
cpuid
mov dword ptr [ebp-4],edx
mov dword ptr [ebp-8],eax
mov eax,01h
xor ecx,ecx
xor edx,edx
cpuid
mov dword ptr [ebp-12],edx
mov dword ptr [ebp-16],eax
mov eax,dword ptr [ebp-4]
mov dword ptr [ebp-20],eax
mov eax,dword ptr [ebp-8]
mov dword ptr [ebp-24],eax
mov eax,dword ptr [ebp-12]
mov dword ptr [ebp-28],eax
mov eax,dword ptr [ebp-16]
mov dword ptr [ebp-32],eax
lea eax, dword ptr[ebp-20]
pop edi
pop esi
pop ebx
mov esp,ebp
pop ebp
ret
}
}
int add(int x, int y)
{
return x + y;
}
int call_ptr(int p, int x)
{
_asm
{
push dword ptr[ebp+12]
call dword ptr[ebp+8]
}
_asm
{
pop edi
pop esi
pop ebx
mov esp,ebp
pop ebp
ret
}
}
void main(int argc, char* argv[])
{
int retVal = call_ptr((int)&add, 1);
}
int r;
_m* c_m = new _m();
int m_p;
_asm
{
push 2
push 1
mov ecx,dword ptr [ebp-20]
call _m::_add
mov dword ptr [ebp-8],eax
}
_asm
{
mov eax,dword ptr [ebp-20]
mov dword ptr [ebp-32], eax
}
int i;
bool max;
_asm
{
mov dword ptr [ebp-8],0
cmp dword ptr [ebp-8],1
jle _loop_min
jmp _loop_max
_loop_min:
mov byte ptr [ebp-17],0
mov al,byte ptr [ebp-17]
_loop_max:
mov byte ptr [ebp-17],al
}
int i;
_asm
{
mov dword ptr [i],0
_loop_beige:
cmp dword ptr [i],64h
jge _loop_end
mov eax,dword ptr [i]
add eax,1
mov dword ptr [i],eax
jmp _loop_beige
_loop_end:
}
C++ CPUID(Intel x86 内联汇编)
最新推荐文章于 2023-09-11 17:50:14 发布