| Line | |
|---|
| 1 | ; $Id: cpuhlp.asm,v 1.1 1999-11-23 19:31:35 sandervl Exp $
|
|---|
| 2 |
|
|---|
| 3 | ;/*
|
|---|
| 4 | ; * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 5 | ; * CPU detection functions
|
|---|
| 6 | ; *
|
|---|
| 7 | ; * Copyright 1999 Sander van Leeuwen
|
|---|
| 8 | ; *
|
|---|
| 9 | ; */
|
|---|
| 10 | .586
|
|---|
| 11 | NAME except
|
|---|
| 12 |
|
|---|
| 13 | CODE32 SEGMENT DWORD PUBLIC USE32 'CODE'
|
|---|
| 14 |
|
|---|
| 15 | public SupportsCPUID
|
|---|
| 16 |
|
|---|
| 17 | SupportsCPUID proc near
|
|---|
| 18 | pushfd
|
|---|
| 19 | push ecx
|
|---|
| 20 |
|
|---|
| 21 | pushfd
|
|---|
| 22 | pop eax
|
|---|
| 23 | mov ecx, eax
|
|---|
| 24 | xor eax, 200000h ;flip bit 21
|
|---|
| 25 | push eax
|
|---|
| 26 | popfd
|
|---|
| 27 | pushfd
|
|---|
| 28 | pop eax
|
|---|
| 29 | cmp eax, ecx ;bit 21 changed -> has cpuid support
|
|---|
| 30 | jnz @supportscpuid
|
|---|
| 31 | xor eax, eax
|
|---|
| 32 | jmp short @end
|
|---|
| 33 |
|
|---|
| 34 | @supportscpuid:
|
|---|
| 35 | mov eax, 1
|
|---|
| 36 | @end:
|
|---|
| 37 | pop ecx
|
|---|
| 38 | popfd
|
|---|
| 39 | ret
|
|---|
| 40 | SupportsCPUID endp
|
|---|
| 41 |
|
|---|
| 42 | public GetCPUVendorString
|
|---|
| 43 |
|
|---|
| 44 | GetCPUVendorString proc near
|
|---|
| 45 | push ebp
|
|---|
| 46 | mov ebp, esp
|
|---|
| 47 | push ebx
|
|---|
| 48 | push ecx
|
|---|
| 49 | push edx
|
|---|
| 50 | push esi
|
|---|
| 51 |
|
|---|
| 52 | mov esi, [ebp+8] ;ptr to string
|
|---|
| 53 | mov eax, 0
|
|---|
| 54 | cpuid
|
|---|
| 55 |
|
|---|
| 56 | mov [esi], ebx
|
|---|
| 57 | mov [esi+4], edx
|
|---|
| 58 | mov [esi+8], ecx
|
|---|
| 59 |
|
|---|
| 60 | pop esi
|
|---|
| 61 | pop edx
|
|---|
| 62 | pop ecx
|
|---|
| 63 | pop ebx
|
|---|
| 64 | pop ebp
|
|---|
| 65 | ret
|
|---|
| 66 | GetCPUVendorString endp
|
|---|
| 67 |
|
|---|
| 68 | public GetCPUFeatures
|
|---|
| 69 | GetCPUFeatures proc near
|
|---|
| 70 | push ebx
|
|---|
| 71 | push ecx
|
|---|
| 72 | push edx
|
|---|
| 73 |
|
|---|
| 74 | mov eax, 1
|
|---|
| 75 | cpuid
|
|---|
| 76 |
|
|---|
| 77 | mov eax, edx
|
|---|
| 78 |
|
|---|
| 79 | pop edx
|
|---|
| 80 | pop ecx
|
|---|
| 81 | pop ebx
|
|---|
| 82 | ret
|
|---|
| 83 | GetCPUFeatures endp
|
|---|
| 84 |
|
|---|
| 85 | public GetCPUSignature
|
|---|
| 86 | GetCPUSignature proc near
|
|---|
| 87 | push ebx
|
|---|
| 88 | push ecx
|
|---|
| 89 | push edx
|
|---|
| 90 |
|
|---|
| 91 | mov eax, 1
|
|---|
| 92 | cpuid
|
|---|
| 93 |
|
|---|
| 94 | pop edx
|
|---|
| 95 | pop ecx
|
|---|
| 96 | pop ebx
|
|---|
| 97 | ret
|
|---|
| 98 | GetCPUSignature endp
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 | CODE32 ENDS
|
|---|
| 102 |
|
|---|
| 103 | END
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.