1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2014 - 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
25 SXMMN MACRO XMM, IDX, REG
26 pinsrd XMM, REG, (IDX AND 3)
29 LXMMN MACRO XMM, REG, IDX
30 pextrd REG, XMM, (IDX AND 3)
34 ; Define SSE macros using SSE 2 instructions
36 SXMMN MACRO XMM, IDX, REG
37 pinsrw XMM, REG, (IDX AND 3) * 2
39 pinsrw XMM, REG, (IDX AND 3) * 2 + 1
43 LXMMN MACRO XMM, REG, IDX
44 pshufd XMM, XMM, (0E4E4E4h SHR (IDX * 2)) AND 0FFh
46 pshufd XMM, XMM, (0E4E4E4h SHR (IDX * 2 + (IDX AND 1) * 4)) AND 0FFh
51 ; XMM7 to save/restore EBP, EBX, ESI, EDI
70 ; XMM6 to save/restore EAX, EDX, ECX, ESP
105 ; XMM5 for calling stack
109 mov esi, offset ReturnAddress
131 ; Initialize floating point units
137 ; Float control word initial value:
138 ; all exceptions masked, double-precision, round-to-nearest
140 FpuControlWord DW 027Fh
142 ; Multimedia-extensions control word:
143 ; all exceptions masked, round-to-nearest, flush to zero for masked underflow
145 MmxControlWord DD 01F80h
148 ; Processor has to support SSE
156 ; Use CpuId instructuion (CPUID.01H:EDX.SSE[bit 25] = 1) to test
157 ; whether the processor supports SSE instruction.
173 ; Set OSFXSR bit (bit #9) & OSXMMEXCPT bit (bit #10)
180 ; The processor should support SSE instruction and we can use
181 ; ldmxcsr instruction
183 ldmxcsr MmxControlWord