2 ; jsimdcpu.asm - SIMD instruction support check
4 ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
6 ; Based on the x86 SIMD extension for IJG JPEG library
7 ; Copyright (C) 1999-2006, MIYASAKA Masaru.
8 ; For conditions of distribution and use, see copyright notice in jsimdext.inc
10 ; This file should be assembled with NASM (Netwide Assembler),
11 ; can *not* be assembled with Microsoft's MASM or any compatible
12 ; assembler (including Borland's Turbo Assembler).
13 ; NASM is available from http://nasm.sourceforge.net/ or
14 ; http://sourceforge.net/project/showfiles.php?group_id=6208
18 %include "jsimdext.inc"
20 ; --------------------------------------------------------------------------
24 ; Check if the CPU supports SIMD instructions
26 ; GLOBAL(unsigned int)
27 ; jpeg_simd_cpu_support (void)
31 global EXTN(jpeg_simd_cpu_support)
33 EXTN(jpeg_simd_cpu_support):
35 ; push ecx ; need not be preserved
36 ; push edx ; need not be preserved
40 xor edi,edi ; simd support flag
45 xor eax, 1<<21 ; flip ID bit in EFLAGS
51 jz short .return ; CPUID is not supported
53 ; Check for MMX instruction support
62 mov eax,edx ; eax = Standard feature flags
64 test eax, 1<<23 ; bit23:MMX
66 or edi, byte JSIMD_MMX
68 test eax, 1<<25 ; bit25:SSE
70 or edi, byte JSIMD_SSE
72 test eax, 1<<26 ; bit26:SSE2
74 or edi, byte JSIMD_SSE2
77 ; Check for 3DNow! instruction support
85 mov eax,edx ; eax = Extended feature flags
87 test eax, 1<<31 ; bit31:3DNow!(vendor independent)
89 or edi, byte JSIMD_3DNOW
97 ; pop edx ; need not be preserved
98 ; pop ecx ; need not be preserved
102 ; For some reason, the OS X linker does not honor the request to align the
103 ; segment unless we do this.