1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
4 ; SPDX-License-Identifier: BSD-2-Clause-Patent
8 ; Provide macro for register save/restore using SSE registers
10 ;------------------------------------------------------------------------------
13 ; Define SSE instruction set
17 ; Define SSE macros using SSE 4.1 instructions
18 ; args 1:XMM, 2:IDX, 3:REG
20 pinsrd %1, %3, (%2 & 3)
24 ;args 1:XMM, 2:REG, 3:IDX
27 pextrd %2, %1, (%3 & 3)
31 ; Define SSE macros using SSE 2 instructions
32 ; args 1:XMM, 2:IDX, 3:REG
34 pinsrw %1, %3, (%2 & 3) * 2
36 pinsrw %1, %3, (%2 & 3) * 2 + 1
41 ;args 1:XMM, 2:REG, 3:IDX
44 pshufd %1, %1, ((0E4E4E4h >> (%3 * 2)) & 0FFh)
46 pshufd %1, %1, ((0E4E4E4h >> (%3 * 2 + (%3 & 1) * 4)) & 0FFh)
51 ; XMM7 to save/restore EBP, EBX, ESI, EDI
70 ; XMM6 to save/restore EAX, EDX, ECX, ESP
104 ; XMM5 for calling stack
107 mov esi, %%ReturnAddress
109 %ifdef USE_SSE41_FLAG
129 ; Initialize floating point units
134 ; Float control word initial value:
135 ; all exceptions masked, double-precision, round-to-nearest
137 FpuControlWord DW 027Fh
139 ; Multimedia-extensions control word:
140 ; all exceptions masked, round-to-nearest, flush to zero for masked underflow
142 MmxControlWord DD 01F80h
145 ; Processor has to support SSE
150 fldcw [FpuControlWord]
153 ; Use CpuId instructuion (CPUID.01H:EDX.SSE[bit 25] = 1) to test
154 ; whether the processor supports SSE instruction.
161 %ifdef USE_SSE41_FLAG
170 ; Set OSFXSR bit (bit #9) & OSXMMEXCPT bit (bit #10)
177 ; The processor should support SSE instruction and we can use
178 ; ldmxcsr instruction
180 ldmxcsr [MmxControlWord]