|
Packit |
47f805 |
;
|
|
Packit |
47f805 |
;
|
|
Packit |
47f805 |
; assembler routines to detect CPU-features
|
|
Packit |
47f805 |
;
|
|
Packit |
47f805 |
; MMX / 3DNow! / SSE / SSE2
|
|
Packit |
47f805 |
;
|
|
Packit |
47f805 |
; for the LAME project
|
|
Packit |
47f805 |
; Frank Klemm, Robert Hegemann 2000-10-12
|
|
Packit |
47f805 |
;
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
%include "nasm.h"
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
globaldef has_MMX_nasm
|
|
Packit |
47f805 |
globaldef has_3DNow_nasm
|
|
Packit |
47f805 |
globaldef has_SSE_nasm
|
|
Packit |
47f805 |
globaldef has_SSE2_nasm
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
segment_code
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
testCPUID:
|
|
Packit |
47f805 |
pushfd
|
|
Packit |
47f805 |
pop eax
|
|
Packit |
47f805 |
mov ecx,eax
|
|
Packit |
47f805 |
xor eax,0x200000
|
|
Packit |
47f805 |
push eax
|
|
Packit |
47f805 |
popfd
|
|
Packit |
47f805 |
pushfd
|
|
Packit |
47f805 |
pop eax
|
|
Packit |
47f805 |
cmp eax,ecx
|
|
Packit |
47f805 |
ret
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
;---------------------------------------
|
|
Packit |
47f805 |
; int has_MMX_nasm (void)
|
|
Packit |
47f805 |
;---------------------------------------
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
has_MMX_nasm:
|
|
Packit |
47f805 |
pushad
|
|
Packit |
47f805 |
call testCPUID
|
|
Packit |
47f805 |
jz return0 ; no CPUID command, so no MMX
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
mov eax,0x1
|
|
Packit |
47f805 |
CPUID
|
|
Packit |
47f805 |
test edx,0x800000
|
|
Packit |
47f805 |
jz return0 ; no MMX support
|
|
Packit |
47f805 |
jmp return1 ; MMX support
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
;---------------------------------------
|
|
Packit |
47f805 |
; int has_SSE_nasm (void)
|
|
Packit |
47f805 |
;---------------------------------------
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
has_SSE_nasm:
|
|
Packit |
47f805 |
pushad
|
|
Packit |
47f805 |
call testCPUID
|
|
Packit |
47f805 |
jz return0 ; no CPUID command, so no SSE
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
mov eax,0x1
|
|
Packit |
47f805 |
CPUID
|
|
Packit |
47f805 |
test edx,0x02000000
|
|
Packit |
47f805 |
jz return0 ; no SSE support
|
|
Packit |
47f805 |
jmp return1 ; SSE support
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
;---------------------------------------
|
|
Packit |
47f805 |
; int has_SSE2_nasm (void)
|
|
Packit |
47f805 |
;---------------------------------------
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
has_SSE2_nasm:
|
|
Packit |
47f805 |
pushad
|
|
Packit |
47f805 |
call testCPUID
|
|
Packit |
47f805 |
jz return0 ; no CPUID command, so no SSE2
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
mov eax,0x1
|
|
Packit |
47f805 |
CPUID
|
|
Packit |
47f805 |
test edx,0x04000000
|
|
Packit |
47f805 |
jz return0 ; no SSE2 support
|
|
Packit |
47f805 |
jmp return1 ; SSE2 support
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
;---------------------------------------
|
|
Packit |
47f805 |
; int has_3DNow_nasm (void)
|
|
Packit |
47f805 |
;---------------------------------------
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
has_3DNow_nasm:
|
|
Packit |
47f805 |
pushad
|
|
Packit |
47f805 |
call testCPUID
|
|
Packit |
47f805 |
jz return0 ; no CPUID command, so no 3DNow!
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
mov eax,0x80000000
|
|
Packit |
47f805 |
CPUID
|
|
Packit |
47f805 |
cmp eax,0x80000000
|
|
Packit |
47f805 |
jbe return0 ; no extended MSR(1), so no 3DNow!
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
mov eax,0x80000001
|
|
Packit |
47f805 |
CPUID
|
|
Packit |
47f805 |
test edx,0x80000000
|
|
Packit |
47f805 |
jz return0 ; no 3DNow! support
|
|
Packit |
47f805 |
; 3DNow! support
|
|
Packit |
47f805 |
return1:
|
|
Packit |
47f805 |
popad
|
|
Packit |
47f805 |
xor eax,eax
|
|
Packit |
47f805 |
inc eax
|
|
Packit |
47f805 |
ret
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
return0:
|
|
Packit |
47f805 |
popad
|
|
Packit |
47f805 |
xor eax,eax
|
|
Packit |
47f805 |
ret
|
|
Packit |
47f805 |
|
|
Packit |
47f805 |
end
|