2 ; jsimdcpu.asm - SIMD instruction support check
4 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
7 ; x86 SIMD extension for IJG JPEG library
8 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
9 ; For conditions of distribution and use, see copyright notice in jsimdext.inc
11 ; This file should be assembled with NASM (Netwide Assembler),
12 ; can *not* be assembled with Microsoft's MASM or any compatible
13 ; assembler (including Borland's Turbo Assembler).
14 ; NASM is available from http://nasm.sourceforge.net/ or
15 ; http://sourceforge.net/project/showfiles.php?group_id=6208
19 %include "jsimdext.inc"
21 ; --------------------------------------------------------------------------
25 ; Check if the CPU supports SIMD instructions
27 ; GLOBAL(unsigned int)
28 ; jpeg_simd_cpu_support (void)
32 global EXTN
(jpeg_simd_cpu_support
)
34 EXTN
(jpeg_simd_cpu_support
):
36 ; push ecx ; need not be preserved
37 ; push edx ; need not be preserved
41 xor edi,edi ; simd support flag
46 xor eax, 1<<21 ; flip ID bit in EFLAGS
52 jz short .return
; CPUID is not supported
54 ; Check for MMX instruction support
63 mov eax,edx ; eax = Standard feature flags
65 test eax, 1<<23 ; bit23:MMX
67 or edi, byte JSIMD_MMX
69 test eax, 1<<25 ; bit25:SSE
71 or edi, byte JSIMD_SSE
73 test eax, 1<<26 ; bit26:SSE2
75 or edi, byte JSIMD_SSE2
78 ; Check for 3DNow! instruction support
86 mov eax,edx ; eax = Extended feature flags
88 test eax, 1<<31 ; bit31:3DNow!(vendor independent)
90 or edi, byte JSIMD_3DNOW
98 ; pop edx ; need not be preserved
99 ; pop ecx ; need not be preserved
103 ; For some reason, the OS X linker does not honor the request to align the
104 ; segment unless we do this.