VB Inlineasm实现:
Private Sub Command1_Click()
Dim myLong(2) As Long
Dim I As Long
Dim lngPointer1 As Long, lngPointer2 As Long, lngPointer3 As Long
Dim lngCPUFeatures(4) As Long, lngCacheInfo(4) As Long
lngPointer1 = VarPtr(myLong(0))
lngPointer2 = VarPtr(lngCPUFeatures(0))
lngPointer3 = VarPtr(lngCacheInfo(0))
Text1.Text = asmCPUID(lngPointer1, lngPointer2, lngPointer3)
End Sub
=================ASM Module================
Public Function asmCPUID(ByVal lngPointer1 As Long, ByVal lngPointer2 As Long, ByVal lngPointer3 As Long) As Long
'#ASM_START
'.686
' push ebp
' mov ebp, esp
' push ecx
' push edx
' push edi
' mov eax, 0
' CPUID
'
' mov edi, DWORD PTR [ebp+8]
' mov [edi], ebx
'
' mov edi, DWORD PTR [ebp+8]
' Add edi, 4
' mov [edi], edx
'
' mov edi, DWORD PTR [ebp+8]
' Add edi, 8
' mov [edi], ecx
' ;\
';-------------------------------------------------------------------------------------
' cmp eax, 0
' je ExitASM
'
';-------------------------------------------------------------------------------------
'
' mov eax, 1
' CPUID
'
' mov edi, [ebp+12] ;//Pointer to array2
' mov [edi], eax
'
' Add edi, 4
' mov [edi], ebx
'
' Add edi, 4
' mov [edi], ecx
'
' Add edi, 4
' mov [edi], edx
'
';----------------
' mov eax, 0
' CPUID
'
' cmp eax, 1
' jng ExitASM
' mov eax, 2
' CPUID
'
' mov edi, [ebp+16]
' mov [edi], eax
'
' Add edi, 4
' mov [edi], ebx
'
' Add edi, 4
' mov [edi], ecx
'
' Add edi, 4
' mov [edi], edx
';-----------------
'ExitASM:
' pop edi
' pop edx
' pop ecx
' mov esp, ebp
' pop ebp
' ret 12
'#ASM_END
End Function