1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
4 ; This program and the accompanying materials
5 ; are licensed and made available under the terms and conditions of the BSD License
6 ; which accompanies this distribution. The full text of the license may be found at
7 ; http://opensource.org/licenses/bsd-license.php.
9 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 ; Provide macro for register save/restore using SSE registers
16 ;------------------------------------------------------------------------------
19 ; Define SSE instruction set
23 ; Define SSE macros using SSE 4.1 instructions
24 ; args 1:XMM, 2:IDX, 3:REG
26 pinsrd %1, %3, (%2 & 3)
30 ;args 1:XMM, 2:REG, 3:IDX
33 pextrd %2, %1, (%3 & 3)
37 ; Define SSE macros using SSE 2 instructions
38 ; args 1:XMM, 2:IDX, 3:REG
40 pinsrw %1, %3, (%2 & 3) * 2
42 pinsrw %1, %3, (%2 & 3) * 2 + 1
47 ;args 1:XMM, 2:REG, 3:IDX
50 pshufd %1, %1, ((0E4E4E4h >> (%3 * 2)) & 0FFh)
52 pshufd %1, %1, ((0E4E4E4h >> (%3 * 2 + (%3 & 1) * 4)) & 0FFh)
57 ; XMM7 to save/restore EBP, EBX, ESI, EDI
76 ; XMM6 to save/restore EAX, EDX, ECX, ESP
110 ; XMM5 for calling stack
113 mov esi, %%ReturnAddress
115 %ifdef USE_SSE41_FLAG
135 ; Initialize floating point units
140 ; Float control word initial value:
141 ; all exceptions masked, double-precision, round-to-nearest
143 FpuControlWord DW 027Fh
145 ; Multimedia-extensions control word:
146 ; all exceptions masked, round-to-nearest, flush to zero for masked underflow
148 MmxControlWord DD 01F80h
151 ; Processor has to support SSE
156 fldcw [FpuControlWord]
159 ; Use CpuId instructuion (CPUID.01H:EDX.SSE[bit 25] = 1) to test
160 ; whether the processor supports SSE instruction.
167 %ifdef USE_SSE41_FLAG
176 ; Set OSFXSR bit (bit #9) & OSXMMEXCPT bit (bit #10)
183 ; The processor should support SSE instruction and we can use
184 ; ldmxcsr instruction
186 ldmxcsr [MmxControlWord]