1 | ; $Id: bs3-cpu-instr-2-template.mac 103738 2024-03-08 15:49:39Z vboxsync $
|
---|
2 | ;; @file
|
---|
3 | ; BS3Kit - bs3-cpu-instr-2 assembly template.
|
---|
4 | ;
|
---|
5 |
|
---|
6 | ;
|
---|
7 | ; Copyright (C) 2007-2023 Oracle and/or its affiliates.
|
---|
8 | ;
|
---|
9 | ; This file is part of VirtualBox base platform packages, as
|
---|
10 | ; available from https://www.virtualbox.org.
|
---|
11 | ;
|
---|
12 | ; This program is free software; you can redistribute it and/or
|
---|
13 | ; modify it under the terms of the GNU General Public License
|
---|
14 | ; as published by the Free Software Foundation, in version 3 of the
|
---|
15 | ; License.
|
---|
16 | ;
|
---|
17 | ; This program is distributed in the hope that it will be useful, but
|
---|
18 | ; WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | ; General Public License for more details.
|
---|
21 | ;
|
---|
22 | ; You should have received a copy of the GNU General Public License
|
---|
23 | ; along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | ;
|
---|
25 | ; The contents of this file may alternatively be used under the terms
|
---|
26 | ; of the Common Development and Distribution License Version 1.0
|
---|
27 | ; (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | ; in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | ; CDDL are applicable instead of those of the GPL.
|
---|
30 | ;
|
---|
31 | ; You may elect to license modified versions of this file under the
|
---|
32 | ; terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | ;
|
---|
34 | ; SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | ;
|
---|
36 |
|
---|
37 |
|
---|
38 | ;*********************************************************************************************************************************
|
---|
39 | ;* Header Files *
|
---|
40 | ;*********************************************************************************************************************************
|
---|
41 | %include "bs3kit-template-header.mac" ; setup environment
|
---|
42 |
|
---|
43 |
|
---|
44 | ;*********************************************************************************************************************************
|
---|
45 | ;* Defined Constants And Macros *
|
---|
46 | ;*********************************************************************************************************************************
|
---|
47 | ;;
|
---|
48 | ; Variant on BS3_PROC_BEGIN_CMN w/ BS3_PBC_NEAR that prefixes the function
|
---|
49 | ; with an instruction length byte.
|
---|
50 | ;
|
---|
51 | ; ASSUMES the length is between the start of the function and the .again label.
|
---|
52 | ;
|
---|
53 | %ifndef BS3CPUINSTR2_PROC_BEGIN_CMN_DEFINED
|
---|
54 | %define BS3CPUINSTR2_PROC_BEGIN_CMN_DEFINED
|
---|
55 | %macro BS3CPUINSTR2_PROC_BEGIN_CMN 1
|
---|
56 | align 8, db 0cch
|
---|
57 | db BS3_CMN_NM(%1).again - BS3_CMN_NM(%1)
|
---|
58 | BS3_PROC_BEGIN_CMN %1, BS3_PBC_NEAR
|
---|
59 | %endmacro
|
---|
60 | %endif
|
---|
61 |
|
---|
62 |
|
---|
63 | ;;
|
---|
64 | ; For defining simple instruction test.
|
---|
65 | %ifndef BS3CPUINSTR2_EMIT_INSTR_UD2_DEFINED
|
---|
66 | %define BS3CPUINSTR2_EMIT_INSTR_UD2_DEFINED
|
---|
67 | %macro BS3CPUINSTR2_EMIT_INSTR_UD2 2+
|
---|
68 | BS3CPUINSTR2_PROC_BEGIN_CMN %1
|
---|
69 | %2
|
---|
70 | .again:
|
---|
71 | ud2
|
---|
72 | jmp .again
|
---|
73 | BS3_PROC_END_CMN %1
|
---|
74 | %endmacro
|
---|
75 | %endif
|
---|
76 |
|
---|
77 | ;;
|
---|
78 | ; @param 1 The instruction menmonic.
|
---|
79 | ; @param 2 Whether there are both an 8-bit form and a 16/32-bit immediate form of the instruction (1) or not 0.
|
---|
80 | ; @param 3 Mask describing the immediate forms. Bit 0 = imm8; Bit 2 = immV.
|
---|
81 | ; @param 4 Whether there are alternative forms of the instruction.
|
---|
82 | ; @param
|
---|
83 | %ifndef BS3CPUINSTR2_BINARY_OP_DEFINED
|
---|
84 | %define BS3CPUINSTR2_BINARY_OP_DEFINED
|
---|
85 | %macro BS3CPUINSTR2_BINARY_OP 4
|
---|
86 | %if %2 != 0
|
---|
87 | ; 8-bit
|
---|
88 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _al %+ _dl, %1 al, dl
|
---|
89 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _ch %+ _bh, %1 ch, bh
|
---|
90 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _dl %+ _ah, %1 dl, ah
|
---|
91 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _DSxBX %+ _ah, %1 [xBX], ah
|
---|
92 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _DSxDI %+ _bl, %1 [xDI], bl
|
---|
93 | %if %3 & 3
|
---|
94 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _al %+ _Ib, %1 al, 0x7f
|
---|
95 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _cl %+ _Ib, %1 cl, 0x7f
|
---|
96 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _dh %+ _Ib, %1 dh, 0x7f
|
---|
97 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _DSxDI %+ _Ib, %1 byte [xDI], 0x7f
|
---|
98 | %endif
|
---|
99 | %if %4 != 0
|
---|
100 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _dl %+ _DSxBX, %1 dl, [xBX]
|
---|
101 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _ch %+ _DSxBX, %1 ch, [xBX]
|
---|
102 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_alt_ %+ %1 %+ _dh %+ _cl, ALT_INSTRUCTION8_ %+ %1 dh, cl
|
---|
103 | %endif
|
---|
104 | %ifdef TMPL_64BIT
|
---|
105 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _sil %+ _dil, %1 sil, dil
|
---|
106 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r9b %+ _r8b, %1 r9b, r8b
|
---|
107 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _al %+ _r13b, %1 al, r13b
|
---|
108 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _DSx14 %+ _r11b, %1 [r14], r11b
|
---|
109 | %if %3 & 3
|
---|
110 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r8b %+ _Ib, %1 r8b, 0x7e
|
---|
111 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r14b %+ _Ib, %1 r14b, 0x7e
|
---|
112 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _DSx13 %+ _Ib, %1 byte [r13], 0x7e
|
---|
113 | %endif
|
---|
114 | %if %4 != 0
|
---|
115 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r11b %+ _DSx12, %1 r11b, [r12]
|
---|
116 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_alt_ %+ %1 %+ _dl %+ _r14b, ALT_INSTRUCTION8_ %+ %1 dl, r14b
|
---|
117 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_alt_ %+ %1 %+ _r8b %+ _bl, ALT_INSTRUCTION8_ %+ %1 r8b, bl
|
---|
118 | %endif
|
---|
119 | %endif
|
---|
120 | %endif
|
---|
121 | ; 16-bit
|
---|
122 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _di %+ _si, %1 di, si
|
---|
123 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _cx %+ _bp, %1 cx, bp
|
---|
124 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _DSxDI %+ _si, %1 [xDI], si
|
---|
125 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _DSxBX %+ _ax, %1 [xBX], ax
|
---|
126 | %if %3 & 1
|
---|
127 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _ax %+ _Ib, %1 ax, strict byte 0x7f
|
---|
128 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _si %+ _Ib, %1 si, strict byte 0x7f
|
---|
129 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _wDSxDI %+ _Ib, %1 word [xDI], strict byte 0x7f
|
---|
130 | %endif
|
---|
131 | %if %3 & 2
|
---|
132 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _ax %+ _Iw, %1 ax, 0x7f01
|
---|
133 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _bx %+ _Iw, %1 bx, 0x7f01
|
---|
134 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _DSxBX %+ _Iw, %1 word [xBX], 0x7f01
|
---|
135 | %endif
|
---|
136 | %if %4 != 0
|
---|
137 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _si %+ _DSxDI, %1 si, [xDI]
|
---|
138 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _ax %+ _DSxBX, %1 ax, [xBX]
|
---|
139 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_alt_ %+ %1 %+ _bp %+ _bx, ALT_INSTRUCTION16_ %+ %1 bp, bx
|
---|
140 | %endif
|
---|
141 | %ifdef TMPL_64BIT
|
---|
142 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r8w %+ _cx, %1 r8w, cx
|
---|
143 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r15w %+ _r10w, %1 r15w, r10w
|
---|
144 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _DSx15 %+ _r12w, %1 [r15], r12w
|
---|
145 | %if %3 & 1
|
---|
146 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r8w %+ _Ib, %1 r8w, strict byte 0x77
|
---|
147 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r12w %+ _Ib, %1 r12w, strict byte 0x77
|
---|
148 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _wDSx14 %+ _Ib, %1 word [r14], strict byte 0x77
|
---|
149 | %endif
|
---|
150 | %if %3 & 2
|
---|
151 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r8w %+ _Iw, %1 r8w, 0x7788
|
---|
152 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r13w %+ _Iw, %1 r13w, 0x7788
|
---|
153 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _DSx11 %+ _Iw, %1 word [r11], 0x7788
|
---|
154 | %endif
|
---|
155 | %if %4 != 0
|
---|
156 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r9w %+ _DSx8, %1 r9w, [r8]
|
---|
157 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_alt_ %+ %1 %+ _r13w %+ _ax, ALT_INSTRUCTION16_ %+ %1 r13w, ax
|
---|
158 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_alt_ %+ %1 %+ _si %+ _r9w, ALT_INSTRUCTION16_ %+ %1 si, r9w
|
---|
159 | %endif
|
---|
160 | %endif
|
---|
161 | ; 32-bit
|
---|
162 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _eax %+ _ebx, %1 eax, ebx
|
---|
163 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _ecx %+ _ebp, %1 ecx, ebp
|
---|
164 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _edx %+ _edi, %1 edx, edi
|
---|
165 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _DSxDI %+ _esi, %1 [xDI], esi
|
---|
166 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _DSxBX %+ _eax, %1 [xBX], eax
|
---|
167 | %if %3 & 1
|
---|
168 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _eax %+ _Ib, %1 eax, strict byte 0x7f
|
---|
169 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _ecx %+ _Ib, %1 ecx, strict byte 0x7f
|
---|
170 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _dwDSxDI %+ _Ib, %1 dword [xDI], strict byte 0x7f
|
---|
171 | %endif
|
---|
172 | %if %3 & 2
|
---|
173 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _eax %+ _Id, %1 eax, 0x7f011234
|
---|
174 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _ebp %+ _Id, %1 ebp, 0x7f011234
|
---|
175 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _DSxSI %+ _Id, %1 dword [xSI], 0x7f011234
|
---|
176 | %endif
|
---|
177 | %if %4 != 0
|
---|
178 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _eax %+ _DSxBX, %1 eax, [xBX]
|
---|
179 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _ebp %+ _DSxDI, %1 ebp, [xDI]
|
---|
180 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_alt_ %+ %1 %+ _edi %+ _esi, ALT_INSTRUCTION32_ %+ %1 edi, esi
|
---|
181 | %endif
|
---|
182 | %ifdef TMPL_64BIT
|
---|
183 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _eax %+ _r8d, %1 eax, r8d
|
---|
184 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r9d %+ _ecx, %1 r9d, ecx
|
---|
185 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r13d %+ _r14d, %1 r13d, r14d
|
---|
186 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _DSx10 %+ _r11d, %1 [r10], r11d
|
---|
187 | %if %3 & 1
|
---|
188 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r8d %+ _Ib, %1 r8d, strict byte 0x77
|
---|
189 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r11d %+ _Ib, %1 r11d, strict byte 0x77
|
---|
190 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _dwDSx15 %+ _Ib, %1 dword [r15], strict byte 0x77
|
---|
191 | %endif
|
---|
192 | %if %3 & 2
|
---|
193 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r8d %+ _Id, %1 r8d, 0x778899aa
|
---|
194 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r14d %+ _Id, %1 r14d, 0x778899aa
|
---|
195 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _DSx12 %+ _Id, %1 dword [r12], 0x778899aa
|
---|
196 | %endif
|
---|
197 | %if %4 != 0
|
---|
198 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r14d %+ _DSx12, %1 r14d, [r12]
|
---|
199 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_alt_ %+ %1 %+ _r15d %+ _esi, ALT_INSTRUCTION32_ %+ %1 r15d, esi
|
---|
200 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_alt_ %+ %1 %+ _eax %+ _r10d, ALT_INSTRUCTION32_ %+ %1 eax, r10d
|
---|
201 | %endif
|
---|
202 | %endif
|
---|
203 | ; 64-bit
|
---|
204 | %ifdef TMPL_64BIT
|
---|
205 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _rax %+ _rbx, %1 rax, rbx
|
---|
206 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r8 %+ _rax, %1 r8, rax
|
---|
207 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _rdx %+ _r10, %1 rdx, r10
|
---|
208 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _DSxBX %+ _rax, %1 [rbx], rax
|
---|
209 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _DSx12 %+ _r8, %1 [r12], r8
|
---|
210 | %if %3 & 1
|
---|
211 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _rax %+ _Ib, %1 rax, strict byte 0x77
|
---|
212 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _rbp %+ _Ib, %1 rbp, strict byte 0x77
|
---|
213 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r8 %+ _Ib, %1 r8, strict byte 0x77
|
---|
214 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r11 %+ _Ib, %1 r11, strict byte 0x77
|
---|
215 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _qwDSxSI %+ _Ib, %1 qword [rsi], strict byte 0x77
|
---|
216 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _qwDSx8 %+ _Ib, %1 qword [r8], strict byte 0x77
|
---|
217 | %endif
|
---|
218 | %if %3 & 2
|
---|
219 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _rax %+ _Id, %1 rax, 0x778899aa
|
---|
220 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r8 %+ _Id, %1 r8, 0x778899aa
|
---|
221 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _rbx %+ _Id, %1 rbx, 0x778899aa
|
---|
222 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r14 %+ _Id, %1 r14, 0x778899aa
|
---|
223 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _qwDSx12 %+ _Id, %1 qword [r12], 0x778899aa
|
---|
224 | %endif
|
---|
225 | %if %4 != 0
|
---|
226 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _rax %+ _DSxBX, %1 rax, [rbx]
|
---|
227 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_ %+ %1 %+ _r8 %+ _DSx12, %1 r8, [r12]
|
---|
228 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_alt_ %+ %1 %+ _r15 %+ _rsi, ALT_INSTRUCTION64_ %+ %1 r15, rsi
|
---|
229 | BS3CPUINSTR2_EMIT_INSTR_UD2 bs3CpuInstr2_alt_ %+ %1 %+ _rbx %+ _r14, ALT_INSTRUCTION64_ %+ %1 rbx, r14
|
---|
230 | %endif
|
---|
231 | %endif
|
---|
232 | %endmacro
|
---|
233 | %endif
|
---|
234 |
|
---|
235 |
|
---|
236 | ;*********************************************************************************************************************************
|
---|
237 | ;* External Symbols *
|
---|
238 | ;*********************************************************************************************************************************
|
---|
239 | TMPL_BEGIN_TEXT
|
---|
240 |
|
---|
241 |
|
---|
242 | ;
|
---|
243 | ; Test code snippets containing code which differs between 16-bit, 32-bit
|
---|
244 | ; and 64-bit CPUs modes.
|
---|
245 | ;
|
---|
246 | %ifdef BS3_INSTANTIATING_CMN
|
---|
247 |
|
---|
248 | %ifndef ALT_INSTRUCTION_MACROS_DEFINED
|
---|
249 | %define ALT_INSTRUCTION_MACROS_DEFINED
|
---|
250 | %macro ALT_INSTRUCTION8_REG_RM 3+
|
---|
251 | X86_MKOP_REX8 %1, %2
|
---|
252 | db %3
|
---|
253 | X86_MKOP_MODRM8 X86_MOD_REG, %1, %2
|
---|
254 | %endmacro
|
---|
255 |
|
---|
256 | %macro ALT_INSTRUCTION16_REG_RM 3+
|
---|
257 | %if TMPL_BITS != 16
|
---|
258 | db X86_OP_PRF_SIZE_OP
|
---|
259 | %endif
|
---|
260 | X86_MKOP_REX16 %1, %2
|
---|
261 | db %3
|
---|
262 | X86_MKOP_MODRM16 X86_MOD_REG, %1, %2
|
---|
263 | %endmacro
|
---|
264 |
|
---|
265 | %macro ALT_INSTRUCTION32_REG_RM 3+
|
---|
266 | %if TMPL_BITS == 16
|
---|
267 | db X86_OP_PRF_SIZE_OP
|
---|
268 | %endif
|
---|
269 | X86_MKOP_REX32 %1, %2
|
---|
270 | db %3
|
---|
271 | X86_MKOP_MODRM32 X86_MOD_REG, %1, %2
|
---|
272 | %endmacro
|
---|
273 |
|
---|
274 | %macro ALT_INSTRUCTION64_REG_RM 3+
|
---|
275 | X86_MKOP_REX64 %1, %2
|
---|
276 | db %3
|
---|
277 | X86_MKOP_MODRM64 X86_MOD_REG, %1, %2
|
---|
278 | %endmacro
|
---|
279 |
|
---|
280 | ; nasm v2.16.02rc1 encodes the 20h and 21h variants (AND rm,reg)
|
---|
281 | %macro ALT_INSTRUCTION8_and 2
|
---|
282 | ALT_INSTRUCTION8_REG_RM %1, %2, 22h
|
---|
283 | %endmacro
|
---|
284 | %macro ALT_INSTRUCTION16_and 2
|
---|
285 | ALT_INSTRUCTION16_REG_RM %1, %2, 23h
|
---|
286 | %endmacro
|
---|
287 | %macro ALT_INSTRUCTION32_and 2
|
---|
288 | ALT_INSTRUCTION32_REG_RM %1, %2, 23h
|
---|
289 | %endmacro
|
---|
290 | %macro ALT_INSTRUCTION64_and 2
|
---|
291 | ALT_INSTRUCTION64_REG_RM %1, %2, 23h
|
---|
292 | %endmacro
|
---|
293 |
|
---|
294 | ; nasm v2.16.02rc1 encodes the 08h and 09h variants (OR rm,reg)
|
---|
295 | %macro ALT_INSTRUCTION8_or 2
|
---|
296 | ALT_INSTRUCTION8_REG_RM %1, %2, 0ah
|
---|
297 | %endmacro
|
---|
298 | %macro ALT_INSTRUCTION16_or 2
|
---|
299 | ALT_INSTRUCTION16_REG_RM %1, %2, 0bh
|
---|
300 | %endmacro
|
---|
301 | %macro ALT_INSTRUCTION32_or 2
|
---|
302 | ALT_INSTRUCTION32_REG_RM %1, %2, 0bh
|
---|
303 | %endmacro
|
---|
304 | %macro ALT_INSTRUCTION64_or 2
|
---|
305 | ALT_INSTRUCTION64_REG_RM %1, %2, 0bh
|
---|
306 | %endmacro
|
---|
307 |
|
---|
308 | ; nasm v2.16.02rc1 encodes the 30h and 31h variants (XOR rm,reg)
|
---|
309 | %macro ALT_INSTRUCTION8_xor 2
|
---|
310 | ALT_INSTRUCTION8_REG_RM %1, %2, 32h
|
---|
311 | %endmacro
|
---|
312 | %macro ALT_INSTRUCTION16_xor 2
|
---|
313 | ALT_INSTRUCTION16_REG_RM %1, %2, 33h
|
---|
314 | %endmacro
|
---|
315 | %macro ALT_INSTRUCTION32_xor 2
|
---|
316 | ALT_INSTRUCTION32_REG_RM %1, %2, 33h
|
---|
317 | %endmacro
|
---|
318 | %macro ALT_INSTRUCTION64_xor 2
|
---|
319 | ALT_INSTRUCTION64_REG_RM %1, %2, 33h
|
---|
320 | %endmacro
|
---|
321 |
|
---|
322 | ; nasm v2.16.02rc1 encodes the 00h and 01h variants (ADD rm,reg)
|
---|
323 | %macro ALT_INSTRUCTION8_add 2
|
---|
324 | ALT_INSTRUCTION8_REG_RM %1, %2, 02h
|
---|
325 | %endmacro
|
---|
326 | %macro ALT_INSTRUCTION16_add 2
|
---|
327 | ALT_INSTRUCTION16_REG_RM %1, %2, 03h
|
---|
328 | %endmacro
|
---|
329 | %macro ALT_INSTRUCTION32_add 2
|
---|
330 | ALT_INSTRUCTION32_REG_RM %1, %2, 03h
|
---|
331 | %endmacro
|
---|
332 | %macro ALT_INSTRUCTION64_add 2
|
---|
333 | ALT_INSTRUCTION64_REG_RM %1, %2, 03h
|
---|
334 | %endmacro
|
---|
335 |
|
---|
336 | ; nasm v2.16.02rc1 encodes the 10h and 11h variants (ADC rm,reg)
|
---|
337 | %macro ALT_INSTRUCTION8_adc 2
|
---|
338 | ALT_INSTRUCTION8_REG_RM %1, %2, 12h
|
---|
339 | %endmacro
|
---|
340 | %macro ALT_INSTRUCTION16_adc 2
|
---|
341 | ALT_INSTRUCTION16_REG_RM %1, %2, 13h
|
---|
342 | %endmacro
|
---|
343 | %macro ALT_INSTRUCTION32_adc 2
|
---|
344 | ALT_INSTRUCTION32_REG_RM %1, %2, 13h
|
---|
345 | %endmacro
|
---|
346 | %macro ALT_INSTRUCTION64_adc 2
|
---|
347 | ALT_INSTRUCTION64_REG_RM %1, %2, 13h
|
---|
348 | %endmacro
|
---|
349 |
|
---|
350 | ; nasm v2.16.02rc1 encodes the 28h and 29h variants (SUB rm,reg)
|
---|
351 | %macro ALT_INSTRUCTION8_sub 2
|
---|
352 | ALT_INSTRUCTION8_REG_RM %1, %2, 2ah
|
---|
353 | %endmacro
|
---|
354 | %macro ALT_INSTRUCTION16_sub 2
|
---|
355 | ALT_INSTRUCTION16_REG_RM %1, %2, 2bh
|
---|
356 | %endmacro
|
---|
357 | %macro ALT_INSTRUCTION32_sub 2
|
---|
358 | ALT_INSTRUCTION32_REG_RM %1, %2, 2bh
|
---|
359 | %endmacro
|
---|
360 | %macro ALT_INSTRUCTION64_sub 2
|
---|
361 | ALT_INSTRUCTION64_REG_RM %1, %2, 2bh
|
---|
362 | %endmacro
|
---|
363 |
|
---|
364 | ; nasm v2.16.02rc1 encodes the 18h and 19h variants (SBB rm,reg)
|
---|
365 | %macro ALT_INSTRUCTION8_sbb 2
|
---|
366 | ALT_INSTRUCTION8_REG_RM %1, %2, 1ah
|
---|
367 | %endmacro
|
---|
368 | %macro ALT_INSTRUCTION16_sbb 2
|
---|
369 | ALT_INSTRUCTION16_REG_RM %1, %2, 1bh
|
---|
370 | %endmacro
|
---|
371 | %macro ALT_INSTRUCTION32_sbb 2
|
---|
372 | ALT_INSTRUCTION32_REG_RM %1, %2, 1bh
|
---|
373 | %endmacro
|
---|
374 | %macro ALT_INSTRUCTION64_sbb 2
|
---|
375 | ALT_INSTRUCTION64_REG_RM %1, %2, 1bh
|
---|
376 | %endmacro
|
---|
377 |
|
---|
378 | ; nasm v2.16.02rc1 encodes the 38h and 39h variants (CMP rm,reg)
|
---|
379 | %macro ALT_INSTRUCTION8_cmp 2
|
---|
380 | ALT_INSTRUCTION8_REG_RM %1, %2, 3ah
|
---|
381 | %endmacro
|
---|
382 | %macro ALT_INSTRUCTION16_cmp 2
|
---|
383 | ALT_INSTRUCTION16_REG_RM %1, %2, 3bh
|
---|
384 | %endmacro
|
---|
385 | %macro ALT_INSTRUCTION32_cmp 2
|
---|
386 | ALT_INSTRUCTION32_REG_RM %1, %2, 3bh
|
---|
387 | %endmacro
|
---|
388 | %macro ALT_INSTRUCTION64_cmp 2
|
---|
389 | ALT_INSTRUCTION64_REG_RM %1, %2, 3bh
|
---|
390 | %endmacro
|
---|
391 |
|
---|
392 | %endif ; !ALT_INSTRUCTION_MACROS_DEFINED
|
---|
393 |
|
---|
394 | BS3CPUINSTR2_BINARY_OP and, 1, 3, 1
|
---|
395 | BS3CPUINSTR2_BINARY_OP or, 1, 3, 1
|
---|
396 | BS3CPUINSTR2_BINARY_OP xor, 1, 3, 1
|
---|
397 | BS3CPUINSTR2_BINARY_OP test, 1, 2, 0
|
---|
398 |
|
---|
399 | BS3CPUINSTR2_BINARY_OP add, 1, 3, 1
|
---|
400 | BS3CPUINSTR2_BINARY_OP adc, 1, 3, 1
|
---|
401 | BS3CPUINSTR2_BINARY_OP sub, 1, 3, 1
|
---|
402 | BS3CPUINSTR2_BINARY_OP sbb, 1, 3, 1
|
---|
403 | BS3CPUINSTR2_BINARY_OP cmp, 1, 3, 1
|
---|
404 |
|
---|
405 | BS3CPUINSTR2_BINARY_OP bt, 0, 1, 0
|
---|
406 | BS3CPUINSTR2_BINARY_OP btc, 0, 1, 0
|
---|
407 | BS3CPUINSTR2_BINARY_OP btr, 0, 1, 0
|
---|
408 | BS3CPUINSTR2_BINARY_OP bts, 0, 1, 0
|
---|
409 |
|
---|
410 |
|
---|
411 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_mul_xBX_ud2, BS3_PBC_NEAR
|
---|
412 | mul xBX
|
---|
413 | .again:
|
---|
414 | ud2
|
---|
415 | jmp .again
|
---|
416 | BS3_PROC_END_CMN bs3CpuInstr2_mul_xBX_ud2
|
---|
417 |
|
---|
418 |
|
---|
419 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_imul_xBX_ud2, BS3_PBC_NEAR
|
---|
420 | imul xBX
|
---|
421 | .again:
|
---|
422 | ud2
|
---|
423 | jmp .again
|
---|
424 | BS3_PROC_END_CMN bs3CpuInstr2_imul_xBX_ud2
|
---|
425 |
|
---|
426 |
|
---|
427 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_imul_xCX_xBX_ud2, BS3_PBC_NEAR
|
---|
428 | imul xCX, xBX
|
---|
429 | .again:
|
---|
430 | ud2
|
---|
431 | jmp .again
|
---|
432 | BS3_PROC_END_CMN bs3CpuInstr2_imul_xCX_xBX_ud2
|
---|
433 |
|
---|
434 |
|
---|
435 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_div_xBX_ud2, BS3_PBC_NEAR
|
---|
436 | div xBX
|
---|
437 | .again:
|
---|
438 | ud2
|
---|
439 | jmp .again
|
---|
440 | BS3_PROC_END_CMN bs3CpuInstr2_div_xBX_ud2
|
---|
441 |
|
---|
442 |
|
---|
443 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_idiv_xBX_ud2, BS3_PBC_NEAR
|
---|
444 | idiv xBX
|
---|
445 | .again:
|
---|
446 | ud2
|
---|
447 | jmp .again
|
---|
448 | BS3_PROC_END_CMN bs3CpuInstr2_idiv_xBX_ud2
|
---|
449 |
|
---|
450 |
|
---|
451 | ;
|
---|
452 | ; BSF / BSR / TZCNT / LZCNT
|
---|
453 | ;
|
---|
454 | %ifndef EMIT_BITSCAN_DEFINED
|
---|
455 | %define EMIT_BITSCAN_DEFINED
|
---|
456 | %macro EMIT_BITSCAN 3
|
---|
457 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %3 %+ _AX_BX_ud2, BS3_PBC_NEAR
|
---|
458 | %2
|
---|
459 | %1 ax, bx
|
---|
460 | .again:
|
---|
461 | ud2
|
---|
462 | jmp .again
|
---|
463 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %3 %+ _AX_BX_ud2
|
---|
464 |
|
---|
465 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %3 %+ _AX_FSxBX_ud2, BS3_PBC_NEAR
|
---|
466 | %2
|
---|
467 | %1 ax, [fs:xBX]
|
---|
468 | .again:
|
---|
469 | ud2
|
---|
470 | jmp .again
|
---|
471 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %3 %+ _AX_FSxBX_ud2
|
---|
472 |
|
---|
473 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %3 %+ _EAX_EBX_ud2, BS3_PBC_NEAR
|
---|
474 | %2
|
---|
475 | %1 eax, ebx
|
---|
476 | .again:
|
---|
477 | ud2
|
---|
478 | jmp .again
|
---|
479 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %3 %+ _EAX_EBX_ud2
|
---|
480 |
|
---|
481 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %3 %+ _EAX_FSxBX_ud2, BS3_PBC_NEAR
|
---|
482 | %2
|
---|
483 | %1 eax, [fs:xBX]
|
---|
484 | .again:
|
---|
485 | ud2
|
---|
486 | jmp .again
|
---|
487 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %3 %+ _EAX_FSxBX_ud2
|
---|
488 |
|
---|
489 | %if TMPL_BITS == 64
|
---|
490 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %3 %+ _RAX_RBX_ud2, BS3_PBC_NEAR
|
---|
491 | %2
|
---|
492 | %1 rax, rbx
|
---|
493 | .again:
|
---|
494 | ud2
|
---|
495 | jmp .again
|
---|
496 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %3 %+ _RAX_RBX_ud2
|
---|
497 |
|
---|
498 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %3 %+ _RAX_FSxBX_ud2, BS3_PBC_NEAR
|
---|
499 | %2
|
---|
500 | %1 rax, [fs:xBX]
|
---|
501 | .again:
|
---|
502 | ud2
|
---|
503 | jmp .again
|
---|
504 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %3 %+ _RAX_FSxBX_ud2
|
---|
505 | %endif
|
---|
506 | %endmacro
|
---|
507 | %endif
|
---|
508 |
|
---|
509 | EMIT_BITSCAN bsf, .ignored:, bsf
|
---|
510 | EMIT_BITSCAN bsr, .ignored:, bsr
|
---|
511 | EMIT_BITSCAN tzcnt, .ignored:, tzcnt
|
---|
512 | EMIT_BITSCAN lzcnt, .ignored:, lzcnt
|
---|
513 | EMIT_BITSCAN bsf, db 0f2h, f2_bsf
|
---|
514 | EMIT_BITSCAN bsr, db 0f2h, f2_bsr
|
---|
515 | EMIT_BITSCAN tzcnt, db 0f2h, f2_tzcnt
|
---|
516 | EMIT_BITSCAN lzcnt, db 0f2h, f2_lzcnt
|
---|
517 |
|
---|
518 |
|
---|
519 | ;
|
---|
520 | ; RORX - VEX instruction with a couple of questions about non-standard encodings.
|
---|
521 | ;
|
---|
522 | ;;%define icebp ud2
|
---|
523 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_rorx_EBX_EDX_2_icebp, BS3_PBC_NEAR
|
---|
524 | rorx ebx, edx, 2
|
---|
525 | .again:
|
---|
526 | icebp
|
---|
527 | jmp .again
|
---|
528 | BS3_PROC_END_CMN bs3CpuInstr2_rorx_EBX_EDX_2_icebp
|
---|
529 |
|
---|
530 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_rorx_RBX_RDX_2_icebp, BS3_PBC_NEAR
|
---|
531 | %if TMPL_BITS == 64
|
---|
532 | rorx rbx, rdx, 2
|
---|
533 | %else
|
---|
534 | db 0C4h,0E3h,0FBh,0F0h,0DAh,002h ; 32-bit ignores VEX.W=1 (10980xe)
|
---|
535 | %endif
|
---|
536 | .again:
|
---|
537 | icebp
|
---|
538 | jmp .again
|
---|
539 | BS3_PROC_END_CMN bs3CpuInstr2_rorx_RBX_RDX_2_icebp
|
---|
540 |
|
---|
541 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_rorx_EBX_EDX_2_icebp_L1, BS3_PBC_NEAR
|
---|
542 | db 0C4h, 0E3h, 07Bh | 4h, 0F0h, 0DAh, 002h ; VEX.L=1 should #UD according to the docs
|
---|
543 | .again:
|
---|
544 | icebp
|
---|
545 | jmp .again
|
---|
546 | BS3_PROC_END_CMN bs3CpuInstr2_rorx_EBX_EDX_2_icebp_L1
|
---|
547 |
|
---|
548 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_rorx_EBX_EDX_2_icebp_V1, BS3_PBC_NEAR
|
---|
549 | db 0C4h, 0E3h, 003h | ~(1 << 3), 0F0h, 0DAh, 002h ; VEX.VVVV=1 - behaviour is undocumented - 10980xe #UD
|
---|
550 | .again:
|
---|
551 | icebp
|
---|
552 | jmp .again
|
---|
553 | BS3_PROC_END_CMN bs3CpuInstr2_rorx_EBX_EDX_2_icebp_V1
|
---|
554 |
|
---|
555 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_rorx_EBX_EDX_2_icebp_V15, BS3_PBC_NEAR
|
---|
556 | db 0C4h, 0E3h, 003h | ~(15 << 3), 0F0h, 0DAh, 002h ; VEX.VVVV=15 - behaviour is not documented - 10980xe #UD
|
---|
557 | .again:
|
---|
558 | icebp
|
---|
559 | jmp .again
|
---|
560 | BS3_PROC_END_CMN bs3CpuInstr2_rorx_EBX_EDX_2_icebp_V15
|
---|
561 |
|
---|
562 | %if TMPL_BITS == 64
|
---|
563 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_rorx_EBX_EDX_2_icebp_X1, BS3_PBC_NEAR
|
---|
564 | db 0C4h, 0E3h & ~40h, 07Bh, 0F0h, 0DAh, 002h ; VEX.X=0 - behaviour is not documented - ignored by 10980xe
|
---|
565 | .again:
|
---|
566 | icebp
|
---|
567 | jmp .again
|
---|
568 | BS3_PROC_END_CMN bs3CpuInstr2_rorx_EBX_EDX_2_icebp_X1
|
---|
569 | %endif
|
---|
570 |
|
---|
571 | ; A couple of memory variants
|
---|
572 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_rorx_EBX_DSxDI_36_icebp, BS3_PBC_NEAR
|
---|
573 | rorx ebx, [xDI], 36
|
---|
574 | .again:
|
---|
575 | icebp
|
---|
576 | jmp .again
|
---|
577 | BS3_PROC_END_CMN bs3CpuInstr2_rorx_EBX_DSxDI_36_icebp
|
---|
578 |
|
---|
579 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_rorx_RBX_DSxDI_68_icebp, BS3_PBC_NEAR
|
---|
580 | %if TMPL_BITS == 64
|
---|
581 | rorx rbx, [xDI], 68
|
---|
582 | %elif TMPL_BITS == 32
|
---|
583 | db 0C4h,0E3h,07Bh,0F0h,01Fh,044h ; 16-bit ignores VEX.W=1 (10980xe)
|
---|
584 | %else
|
---|
585 | db 0C4h,0E3h,0FBh,0F0h,01Dh,044h ; 16-bit ignores VEX.W=1 (10980xe)
|
---|
586 | %endif
|
---|
587 | .again:
|
---|
588 | icebp
|
---|
589 | jmp .again
|
---|
590 | BS3_PROC_END_CMN bs3CpuInstr2_rorx_RBX_DSxDI_68_icebp
|
---|
591 |
|
---|
592 | ;
|
---|
593 | ; ANDN (BMI1)
|
---|
594 | ;
|
---|
595 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_andn_RAX_RCX_RBX_icebp, BS3_PBC_NEAR
|
---|
596 | %if TMPL_BITS == 64
|
---|
597 | andn rax, rcx, rbx
|
---|
598 | %else
|
---|
599 | db 0C4h,0E2h,0F0h,0F2h,0C3h ; 32-bit & 16-bit ignores VEX.W=1 (10980xe)
|
---|
600 | %endif
|
---|
601 | .again:
|
---|
602 | icebp
|
---|
603 | jmp .again
|
---|
604 | BS3_PROC_END_CMN bs3CpuInstr2_andn_RAX_RCX_RBX_icebp
|
---|
605 |
|
---|
606 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_andn_EAX_ECX_EBX_icebp, BS3_PBC_NEAR
|
---|
607 | andn eax, ecx, ebx
|
---|
608 | .again:
|
---|
609 | icebp
|
---|
610 | jmp .again
|
---|
611 | BS3_PROC_END_CMN bs3CpuInstr2_andn_EAX_ECX_EBX_icebp
|
---|
612 |
|
---|
613 |
|
---|
614 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_andn_RAX_RCX_FSxBX_icebp, BS3_PBC_NEAR
|
---|
615 | %if TMPL_BITS == 64
|
---|
616 | andn rax, rcx, [fs:rbx]
|
---|
617 | %elif TMPL_BITS == 32
|
---|
618 | db 064h,0C4h,0E2h,0F0h,0F2h,003h ; andn rax, rcx, [fs:ebx]
|
---|
619 | %else
|
---|
620 | db 064h,0C4h,0E2h,0F0h,0F2h,007h ; andn rax, rcx, [fs:bx]
|
---|
621 | %endif
|
---|
622 | .again:
|
---|
623 | icebp
|
---|
624 | jmp .again
|
---|
625 | BS3_PROC_END_CMN bs3CpuInstr2_andn_RAX_RCX_FSxBX_icebp
|
---|
626 |
|
---|
627 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_andn_EAX_ECX_FSxBX_icebp, BS3_PBC_NEAR
|
---|
628 | andn eax, ecx, [fs:xBX]
|
---|
629 | .again:
|
---|
630 | icebp
|
---|
631 | jmp .again
|
---|
632 | BS3_PROC_END_CMN bs3CpuInstr2_andn_EAX_ECX_FSxBX_icebp
|
---|
633 |
|
---|
634 |
|
---|
635 | ;
|
---|
636 | ; BEXTR / SHLX / SARX / SHRX - BMI1 (opcode f7h)
|
---|
637 | ; BZHI - BMI2 (opcode f5h)
|
---|
638 | ;
|
---|
639 | ; @param %1 instruction
|
---|
640 | ; @param %2 opcode
|
---|
641 | ; @param %3 prefix
|
---|
642 | ;
|
---|
643 | %ifndef SHLX_SARX_SHRX_DEFINED
|
---|
644 | %define SHLX_SARX_SHRX_DEFINED
|
---|
645 | %macro SHLX_SARX_SHRX 3
|
---|
646 |
|
---|
647 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %1 %+ _RAX_RBX_RCX_icebp, BS3_PBC_NEAR
|
---|
648 | %if TMPL_BITS == 64
|
---|
649 | %1 rax, rbx, rcx ; SHLX=C4E2F1F7C3
|
---|
650 | %else
|
---|
651 | db 0C4h,0E2h,0F0h|%3,%2,0C3h ; 32-bit & 16-bit ignores VEX.W=1 (10980xe)
|
---|
652 | %endif
|
---|
653 | .again:
|
---|
654 | icebp
|
---|
655 | jmp .again
|
---|
656 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %1 %+ _RAX_RBX_RCX_icebp
|
---|
657 |
|
---|
658 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %1 %+ _EAX_EBX_ECX_icebp, BS3_PBC_NEAR
|
---|
659 | %1 eax, ebx, ecx
|
---|
660 | .again:
|
---|
661 | icebp
|
---|
662 | jmp .again
|
---|
663 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %1 %+ _EAX_EBX_ECX_icebp
|
---|
664 |
|
---|
665 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %1 %+ _RAX_FSxBX_RCX_icebp, BS3_PBC_NEAR
|
---|
666 | %if TMPL_BITS == 64
|
---|
667 | %1 rax, [fs:rbx], rcx ; SHLX=64C4E2F1F703
|
---|
668 | %elif TMPL_BITS == 32
|
---|
669 | db 064h,0C4h,0E2h,0F0h|%3,%2,003h
|
---|
670 | %else
|
---|
671 | db 064h,0C4h,0E2h,0F0h|%3,%2,007h
|
---|
672 | %endif
|
---|
673 | .again:
|
---|
674 | icebp
|
---|
675 | jmp .again
|
---|
676 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %1 %+ _RAX_FSxBX_RCX_icebp
|
---|
677 |
|
---|
678 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %1 %+ _EAX_FSxBX_ECX_icebp, BS3_PBC_NEAR
|
---|
679 | %1 eax, [fs:xBX], ecx
|
---|
680 | .again:
|
---|
681 | icebp
|
---|
682 | jmp .again
|
---|
683 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %1 %+ _EAX_FSxBX_ECX_icebp
|
---|
684 |
|
---|
685 | %endmacro
|
---|
686 | %endif
|
---|
687 |
|
---|
688 | SHLX_SARX_SHRX bextr, 0f7h, 0 ; none
|
---|
689 | SHLX_SARX_SHRX shlx, 0f7h, 1 ; 66h
|
---|
690 | SHLX_SARX_SHRX sarx, 0f7h, 2 ; f3h
|
---|
691 | SHLX_SARX_SHRX shrx, 0f7h, 3 ; f2h
|
---|
692 | SHLX_SARX_SHRX bzhi, 0f5h, 0 ; none
|
---|
693 |
|
---|
694 | ;
|
---|
695 | ; PPEP / PEXT - BMI2 (opcode f5h)
|
---|
696 | ;
|
---|
697 | ; @param %1 instruction
|
---|
698 | ; @param %2 opcode
|
---|
699 | ; @param %3 prefix
|
---|
700 | ;
|
---|
701 | %ifndef PDEP_PEXT_DEFINED
|
---|
702 | %define PDEP_PEXT_DEFINED
|
---|
703 | %macro PDEP_PEXT_ 3
|
---|
704 |
|
---|
705 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %1 %+ _RAX_RCX_RBX_icebp, BS3_PBC_NEAR
|
---|
706 | %if TMPL_BITS == 64
|
---|
707 | %1 rax, rcx, rbx
|
---|
708 | %else
|
---|
709 | db 0C4h,0E2h,0F0h|%3,%2,0C3h ; 32-bit & 16-bit ignores VEX.W=1 (10980xe)
|
---|
710 | %endif
|
---|
711 | .again:
|
---|
712 | icebp
|
---|
713 | jmp .again
|
---|
714 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %1 %+ _RAX_RCX_RBX_icebp
|
---|
715 |
|
---|
716 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %1 %+ _EAX_ECX_EBX_icebp, BS3_PBC_NEAR
|
---|
717 | %1 eax, ecx, ebx
|
---|
718 | .again:
|
---|
719 | icebp
|
---|
720 | jmp .again
|
---|
721 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %1 %+ _EAX_ECX_EBX_icebp
|
---|
722 |
|
---|
723 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %1 %+ _RAX_RCX_FSxBX_icebp, BS3_PBC_NEAR
|
---|
724 | %if TMPL_BITS == 64
|
---|
725 | %1 rax, rcx, [fs:rbx]
|
---|
726 | %elif TMPL_BITS == 32
|
---|
727 | db 064h,0C4h,0E2h,0F0h|%3,%2,003h
|
---|
728 | %else
|
---|
729 | db 064h,0C4h,0E2h,0F0h|%3,%2,007h
|
---|
730 | %endif
|
---|
731 | .again:
|
---|
732 | icebp
|
---|
733 | jmp .again
|
---|
734 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %1 %+ _RAX_RCX_FSxBX_icebp
|
---|
735 |
|
---|
736 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %1 %+ _EAX_ECX_FSxBX_icebp, BS3_PBC_NEAR
|
---|
737 | %1 eax, ecx, [fs:xBX]
|
---|
738 | .again:
|
---|
739 | icebp
|
---|
740 | jmp .again
|
---|
741 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %1 %+ _EAX_ECX_FSxBX_icebp
|
---|
742 |
|
---|
743 | %endmacro
|
---|
744 | %endif
|
---|
745 |
|
---|
746 | PDEP_PEXT_ pext, 0f5h, 2 ; f3h
|
---|
747 | PDEP_PEXT_ pdep, 0f5h, 3 ; f2h
|
---|
748 |
|
---|
749 | ;
|
---|
750 | ; BLSR / BLSMSK / BLSI
|
---|
751 | ; These are encoded in the exact same way, only the /r differs (%2).
|
---|
752 | ;
|
---|
753 | %ifndef BLSR_BLSMSK_BLSI_DEFINED
|
---|
754 | %define BLSR_BLSMSK_BLSI_DEFINED
|
---|
755 | %macro BLSR_BLSMSK_BLSI 2
|
---|
756 |
|
---|
757 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %1 %+ _RAX_RBX_icebp, BS3_PBC_NEAR
|
---|
758 | %if TMPL_BITS == 64
|
---|
759 | %1 rax, rbx ; BLSR=C4E2F8F3CB
|
---|
760 | %else
|
---|
761 | db 0C4h,0E2h,0F8h,0F3h,0C3h | (%2 << 3) ; 32-bit & 16-bit ignores VEX.W=1 (10980xe)
|
---|
762 | %endif
|
---|
763 | .again:
|
---|
764 | icebp
|
---|
765 | jmp .again
|
---|
766 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %1 %+ _RAX_RBX_icebp
|
---|
767 |
|
---|
768 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %1 %+ _EAX_EBX_icebp, BS3_PBC_NEAR
|
---|
769 | %1 eax, ebx
|
---|
770 | .again:
|
---|
771 | icebp
|
---|
772 | jmp .again
|
---|
773 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %1 %+ _EAX_EBX_icebp
|
---|
774 |
|
---|
775 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %1 %+ _RAX_FSxBX_icebp, BS3_PBC_NEAR
|
---|
776 | %if TMPL_BITS == 64
|
---|
777 | %1 rax, [fs:rbx] ; BSLR=64C4E2F8F30B
|
---|
778 | %elif TMPL_BITS == 32
|
---|
779 | db 064h,0C4h,0E2h,0F8h,0F3h,003h | (%2 << 3)
|
---|
780 | %else
|
---|
781 | db 064h,0C4h,0E2h,0F8h,0F3h,007h | (%2 << 3)
|
---|
782 | %endif
|
---|
783 | .again:
|
---|
784 | icebp
|
---|
785 | jmp .again
|
---|
786 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %1 %+ _RAX_FSxBX_icebp
|
---|
787 |
|
---|
788 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_ %+ %1 %+ _EAX_FSxBX_icebp, BS3_PBC_NEAR
|
---|
789 | %1 eax, [fs:xBX]
|
---|
790 | .again:
|
---|
791 | icebp
|
---|
792 | jmp .again
|
---|
793 | BS3_PROC_END_CMN bs3CpuInstr2_ %+ %1 %+ _EAX_FSxBX_icebp
|
---|
794 |
|
---|
795 | %endmacro
|
---|
796 | %endif
|
---|
797 |
|
---|
798 | BLSR_BLSMSK_BLSI blsr, 1
|
---|
799 | BLSR_BLSMSK_BLSI blsmsk, 2
|
---|
800 | BLSR_BLSMSK_BLSI blsi, 3
|
---|
801 |
|
---|
802 | ;
|
---|
803 | ; MULX
|
---|
804 | ;
|
---|
805 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_mulx_RAX_RCX_RBX_RDX_icebp, BS3_PBC_NEAR
|
---|
806 | %if TMPL_BITS == 64
|
---|
807 | mulx rax, rcx, rbx ; C4E2F3F6C3
|
---|
808 | %else
|
---|
809 | db 0C4h,0E2h,0F3h,0F6h,0C3h ; 32-bit & 16-bit ignores VEX.W=1 (10980xe)
|
---|
810 | %endif
|
---|
811 | .again:
|
---|
812 | icebp
|
---|
813 | jmp .again
|
---|
814 | BS3_PROC_END_CMN bs3CpuInstr2_mulx_RAX_RCX_RBX_RDX_icebp
|
---|
815 |
|
---|
816 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_mulx_RCX_RCX_RBX_RDX_icebp, BS3_PBC_NEAR
|
---|
817 | %if TMPL_BITS == 64
|
---|
818 | mulx rcx, rcx, rbx ; C4E2F3F6CB
|
---|
819 | %else
|
---|
820 | db 0C4h,0E2h,0F3h,0F6h,0CBh ; 32-bit & 16-bit ignores VEX.W=1 (10980xe)
|
---|
821 | %endif
|
---|
822 | .again:
|
---|
823 | icebp
|
---|
824 | jmp .again
|
---|
825 | BS3_PROC_END_CMN bs3CpuInstr2_mulx_RCX_RCX_RBX_RDX_icebp
|
---|
826 |
|
---|
827 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_mulx_RAX_RCX_FSxBX_RDX_icebp, BS3_PBC_NEAR
|
---|
828 | %if TMPL_BITS == 64
|
---|
829 | mulx rax, rcx, [fs:rbx] ; 64C4E2F3F603
|
---|
830 | %elif TMPL_BITS == 32
|
---|
831 | db 064h,0C4h,0E2h,0F3h,0F6h,003h ; 32-bit & 16-bit ignores VEX.W=1 (10980xe)
|
---|
832 | %else
|
---|
833 | db 064h,0C4h,0E2h,0F3h,0F6h,007h ; 32-bit & 16-bit ignores VEX.W=1 (10980xe)
|
---|
834 | %endif
|
---|
835 | .again:
|
---|
836 | icebp
|
---|
837 | jmp .again
|
---|
838 | BS3_PROC_END_CMN bs3CpuInstr2_mulx_RAX_RCX_FSxBX_RDX_icebp
|
---|
839 |
|
---|
840 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_mulx_EAX_ECX_EBX_EDX_icebp, BS3_PBC_NEAR
|
---|
841 | mulx eax, ecx, ebx
|
---|
842 | .again:
|
---|
843 | icebp
|
---|
844 | jmp .again
|
---|
845 | BS3_PROC_END_CMN bs3CpuInstr2_mulx_EAX_ECX_EBX_EDX_icebp
|
---|
846 |
|
---|
847 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_mulx_ECX_ECX_EBX_EDX_icebp, BS3_PBC_NEAR
|
---|
848 | mulx ecx, ecx, ebx
|
---|
849 | .again:
|
---|
850 | icebp
|
---|
851 | jmp .again
|
---|
852 | BS3_PROC_END_CMN bs3CpuInstr2_mulx_ECX_ECX_EBX_EDX_icebp
|
---|
853 |
|
---|
854 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_mulx_EAX_ECX_FSxBX_EDX_icebp, BS3_PBC_NEAR
|
---|
855 | mulx eax, ecx, [fs:xBX]
|
---|
856 | .again:
|
---|
857 | icebp
|
---|
858 | jmp .again
|
---|
859 | BS3_PROC_END_CMN bs3CpuInstr2_mulx_EAX_ECX_FSxBX_EDX_icebp
|
---|
860 |
|
---|
861 |
|
---|
862 | ;
|
---|
863 | ; POPCNT
|
---|
864 | ;
|
---|
865 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_popcnt_AX_BX_icebp, BS3_PBC_NEAR
|
---|
866 | popcnt ax, bx
|
---|
867 | .again:
|
---|
868 | icebp
|
---|
869 | jmp .again
|
---|
870 | BS3_PROC_END_CMN bs3CpuInstr2_popcnt_AX_BX_icebp
|
---|
871 |
|
---|
872 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_popcnt_EAX_EBX_icebp, BS3_PBC_NEAR
|
---|
873 | popcnt eax, ebx
|
---|
874 | .again:
|
---|
875 | icebp
|
---|
876 | jmp .again
|
---|
877 | BS3_PROC_END_CMN bs3CpuInstr2_popcnt_EAX_EBX_icebp
|
---|
878 |
|
---|
879 | %if TMPL_BITS == 64
|
---|
880 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_popcnt_RAX_RBX_icebp, BS3_PBC_NEAR
|
---|
881 | popcnt rax, rbx
|
---|
882 | .again:
|
---|
883 | icebp
|
---|
884 | jmp .again
|
---|
885 | BS3_PROC_END_CMN bs3CpuInstr2_popcnt_RAX_RBX_icebp
|
---|
886 | %endif
|
---|
887 |
|
---|
888 |
|
---|
889 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_popcnt_AX_FSxBX_icebp, BS3_PBC_NEAR
|
---|
890 | popcnt ax, [fs:xBX]
|
---|
891 | .again:
|
---|
892 | icebp
|
---|
893 | jmp .again
|
---|
894 | BS3_PROC_END_CMN bs3CpuInstr2_popcnt_AX_FSxBX_icebp
|
---|
895 |
|
---|
896 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_popcnt_EAX_FSxBX_icebp, BS3_PBC_NEAR
|
---|
897 | popcnt eax, [fs:xBX]
|
---|
898 | .again:
|
---|
899 | icebp
|
---|
900 | jmp .again
|
---|
901 | BS3_PROC_END_CMN bs3CpuInstr2_popcnt_EAX_FSxBX_icebp
|
---|
902 |
|
---|
903 | %if TMPL_BITS == 64
|
---|
904 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_popcnt_RAX_FSxBX_icebp, BS3_PBC_NEAR
|
---|
905 | popcnt rax, [fs:xBX]
|
---|
906 | .again:
|
---|
907 | icebp
|
---|
908 | jmp .again
|
---|
909 | BS3_PROC_END_CMN bs3CpuInstr2_popcnt_RAX_FSxBX_icebp
|
---|
910 | %endif
|
---|
911 |
|
---|
912 |
|
---|
913 | ;
|
---|
914 | ; CRC32
|
---|
915 | ;
|
---|
916 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_crc32_EAX_BL_icebp
|
---|
917 | crc32 eax, bl
|
---|
918 | .again:
|
---|
919 | icebp
|
---|
920 | jmp .again
|
---|
921 | BS3_PROC_END_CMN bs3CpuInstr2_crc32_EAX_BL_icebp
|
---|
922 |
|
---|
923 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_crc32_EAX_BX_icebp
|
---|
924 | crc32 eax, bx
|
---|
925 | .again:
|
---|
926 | icebp
|
---|
927 | jmp .again
|
---|
928 | BS3_PROC_END_CMN bs3CpuInstr2_crc32_EAX_BX_icebp
|
---|
929 |
|
---|
930 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_crc32_EAX_EBX_icebp
|
---|
931 | crc32 eax, ebx
|
---|
932 | .again:
|
---|
933 | icebp
|
---|
934 | jmp .again
|
---|
935 | BS3_PROC_END_CMN bs3CpuInstr2_crc32_EAX_EBX_icebp
|
---|
936 |
|
---|
937 | %if TMPL_BITS == 64
|
---|
938 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_crc32_EAX_RBX_icebp
|
---|
939 | crc32 rax, rbx
|
---|
940 | .again:
|
---|
941 | icebp
|
---|
942 | jmp .again
|
---|
943 | BS3_PROC_END_CMN bs3CpuInstr2_crc32_EAX_RBX_icebp
|
---|
944 | %endif
|
---|
945 |
|
---|
946 |
|
---|
947 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_crc32_EAX_byte_FSxBX_icebp
|
---|
948 | crc32 eax, byte [fs:xBX]
|
---|
949 | .again:
|
---|
950 | icebp
|
---|
951 | jmp .again
|
---|
952 | BS3_PROC_END_CMN bs3CpuInstr2_crc32_EAX_byte_FSxBX_icebp
|
---|
953 |
|
---|
954 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_crc32_EAX_word_FSxBX_icebp
|
---|
955 | crc32 eax, word [fs:xBX]
|
---|
956 | .again:
|
---|
957 | icebp
|
---|
958 | jmp .again
|
---|
959 | BS3_PROC_END_CMN bs3CpuInstr2_crc32_EAX_word_FSxBX_icebp
|
---|
960 |
|
---|
961 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_crc32_EAX_dword_FSxBX_icebp
|
---|
962 | crc32 eax, dword [fs:xBX]
|
---|
963 | .again:
|
---|
964 | icebp
|
---|
965 | jmp .again
|
---|
966 | BS3_PROC_END_CMN bs3CpuInstr2_crc32_EAX_dword_FSxBX_icebp
|
---|
967 |
|
---|
968 | %if TMPL_BITS == 64
|
---|
969 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_crc32_EAX_qword_FSxBX_icebp
|
---|
970 | crc32 rax, qword [fs:xBX]
|
---|
971 | .again:
|
---|
972 | icebp
|
---|
973 | jmp .again
|
---|
974 | BS3_PROC_END_CMN bs3CpuInstr2_crc32_EAX_qword_FSxBX_icebp
|
---|
975 | %endif
|
---|
976 |
|
---|
977 |
|
---|
978 | ;
|
---|
979 | ; ADCX
|
---|
980 | ;
|
---|
981 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_adcx_EAX_EBX_icebp
|
---|
982 | adcx eax, ebx
|
---|
983 | .again:
|
---|
984 | icebp
|
---|
985 | jmp .again
|
---|
986 | BS3_PROC_END_CMN bs3CpuInstr2_adcx_EAX_EBX_icebp
|
---|
987 |
|
---|
988 | %if TMPL_BITS == 64
|
---|
989 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_adcx_RAX_RBX_icebp
|
---|
990 | adcx rax, rbx
|
---|
991 | .again:
|
---|
992 | icebp
|
---|
993 | jmp .again
|
---|
994 | BS3_PROC_END_CMN bs3CpuInstr2_adcx_RAX_RBX_icebp
|
---|
995 | %endif
|
---|
996 |
|
---|
997 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_adcx_EAX_dword_FSxBX_icebp
|
---|
998 | adcx eax, dword [fs:xBX]
|
---|
999 | .again:
|
---|
1000 | icebp
|
---|
1001 | jmp .again
|
---|
1002 | BS3_PROC_END_CMN bs3CpuInstr2_adcx_EAX_dword_FSxBX_icebp
|
---|
1003 |
|
---|
1004 | %if TMPL_BITS == 64
|
---|
1005 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_adcx_RAX_qword_FSxBX_icebp
|
---|
1006 | adcx rax, qword [fs:xBX]
|
---|
1007 | .again:
|
---|
1008 | icebp
|
---|
1009 | jmp .again
|
---|
1010 | BS3_PROC_END_CMN bs3CpuInstr2_adcx_RAX_qword_FSxBX_icebp
|
---|
1011 | %endif
|
---|
1012 |
|
---|
1013 |
|
---|
1014 | ;
|
---|
1015 | ; ADOX
|
---|
1016 | ;
|
---|
1017 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_adox_EAX_EBX_icebp
|
---|
1018 | adox eax, ebx
|
---|
1019 | .again:
|
---|
1020 | icebp
|
---|
1021 | jmp .again
|
---|
1022 | BS3_PROC_END_CMN bs3CpuInstr2_adox_EAX_EBX_icebp
|
---|
1023 |
|
---|
1024 | %if TMPL_BITS == 64
|
---|
1025 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_adox_RAX_RBX_icebp
|
---|
1026 | adox rax, rbx
|
---|
1027 | .again:
|
---|
1028 | icebp
|
---|
1029 | jmp .again
|
---|
1030 | BS3_PROC_END_CMN bs3CpuInstr2_adox_RAX_RBX_icebp
|
---|
1031 | %endif
|
---|
1032 |
|
---|
1033 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_adox_EAX_dword_FSxBX_icebp
|
---|
1034 | adox eax, dword [fs:xBX]
|
---|
1035 | .again:
|
---|
1036 | icebp
|
---|
1037 | jmp .again
|
---|
1038 | BS3_PROC_END_CMN bs3CpuInstr2_adox_EAX_dword_FSxBX_icebp
|
---|
1039 |
|
---|
1040 | %if TMPL_BITS == 64
|
---|
1041 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_adox_RAX_qword_FSxBX_icebp
|
---|
1042 | adox rax, qword [fs:xBX]
|
---|
1043 | .again:
|
---|
1044 | icebp
|
---|
1045 | jmp .again
|
---|
1046 | BS3_PROC_END_CMN bs3CpuInstr2_adox_RAX_qword_FSxBX_icebp
|
---|
1047 | %endif
|
---|
1048 |
|
---|
1049 |
|
---|
1050 | ;
|
---|
1051 | ; MOVBE
|
---|
1052 | ;
|
---|
1053 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_movbe_AX_word_FSxBX_icebp
|
---|
1054 | movbe ax, word [fs:xBX]
|
---|
1055 | .again:
|
---|
1056 | icebp
|
---|
1057 | jmp .again
|
---|
1058 | BS3_PROC_END_CMN bs3CpuInstr2_movbe_AX_word_FSxBX_icebp
|
---|
1059 |
|
---|
1060 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_movbe_word_FSxBX_AX_icebp
|
---|
1061 | movbe word [fs:xBX], ax
|
---|
1062 | .again:
|
---|
1063 | icebp
|
---|
1064 | jmp .again
|
---|
1065 | BS3_PROC_END_CMN bs3CpuInstr2_movbe_word_FSxBX_AX_icebp
|
---|
1066 |
|
---|
1067 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_movbe_EAX_dword_FSxBX_icebp
|
---|
1068 | movbe eax, dword [fs:xBX]
|
---|
1069 | .again:
|
---|
1070 | icebp
|
---|
1071 | jmp .again
|
---|
1072 | BS3_PROC_END_CMN bs3CpuInstr2_movbe_EAX_dword_FSxBX_icebp
|
---|
1073 |
|
---|
1074 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_movbe_dword_FSxBX_EAX_icebp
|
---|
1075 | movbe dword [fs:xBX], eax
|
---|
1076 | .again:
|
---|
1077 | icebp
|
---|
1078 | jmp .again
|
---|
1079 | BS3_PROC_END_CMN bs3CpuInstr2_movbe_dword_FSxBX_EAX_icebp
|
---|
1080 |
|
---|
1081 | %if TMPL_BITS == 64
|
---|
1082 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_movbe_RAX_qword_FSxBX_icebp
|
---|
1083 | movbe rax, qword [fs:xBX]
|
---|
1084 | .again:
|
---|
1085 | icebp
|
---|
1086 | jmp .again
|
---|
1087 | BS3_PROC_END_CMN bs3CpuInstr2_movbe_RAX_qword_FSxBX_icebp
|
---|
1088 |
|
---|
1089 | BS3CPUINSTR2_PROC_BEGIN_CMN bs3CpuInstr2_movbe_qword_FSxBX_RAX_icebp
|
---|
1090 | movbe qword [fs:xBX], rax
|
---|
1091 | .again:
|
---|
1092 | icebp
|
---|
1093 | jmp .again
|
---|
1094 | BS3_PROC_END_CMN bs3CpuInstr2_movbe_qword_FSxBX_RAX_icebp
|
---|
1095 | %endif
|
---|
1096 |
|
---|
1097 |
|
---|
1098 | ;
|
---|
1099 | ; CMPXCHG8B
|
---|
1100 | ;
|
---|
1101 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_cmpxchg8b_FSxDI_icebp, BS3_PBC_NEAR
|
---|
1102 | cmpxchg8b [fs:xDI]
|
---|
1103 | .again:
|
---|
1104 | icebp
|
---|
1105 | jmp .again
|
---|
1106 | BS3_PROC_END_CMN bs3CpuInstr2_cmpxchg8b_FSxDI_icebp
|
---|
1107 |
|
---|
1108 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_lock_cmpxchg8b_FSxDI_icebp, BS3_PBC_NEAR
|
---|
1109 | lock cmpxchg8b [fs:xDI]
|
---|
1110 | .again:
|
---|
1111 | icebp
|
---|
1112 | jmp .again
|
---|
1113 | BS3_PROC_END_CMN bs3CpuInstr2_lock_cmpxchg8b_FSxDI_icebp
|
---|
1114 |
|
---|
1115 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_o16_cmpxchg8b_FSxDI_icebp, BS3_PBC_NEAR
|
---|
1116 | o16 cmpxchg8b [fs:xDI]
|
---|
1117 | .again:
|
---|
1118 | icebp
|
---|
1119 | jmp .again
|
---|
1120 | BS3_PROC_END_CMN bs3CpuInstr2_o16_cmpxchg8b_FSxDI_icebp
|
---|
1121 |
|
---|
1122 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_lock_o16_cmpxchg8b_FSxDI_icebp, BS3_PBC_NEAR
|
---|
1123 | db 0f0h, 066h
|
---|
1124 | cmpxchg8b [fs:xDI]
|
---|
1125 | .again:
|
---|
1126 | icebp
|
---|
1127 | jmp .again
|
---|
1128 | BS3_PROC_END_CMN bs3CpuInstr2_lock_o16_cmpxchg8b_FSxDI_icebp
|
---|
1129 |
|
---|
1130 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_repz_cmpxchg8b_FSxDI_icebp, BS3_PBC_NEAR
|
---|
1131 | repz cmpxchg8b [fs:xDI]
|
---|
1132 | .again:
|
---|
1133 | icebp
|
---|
1134 | jmp .again
|
---|
1135 | BS3_PROC_END_CMN bs3CpuInstr2_repz_cmpxchg8b_FSxDI_icebp
|
---|
1136 |
|
---|
1137 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_lock_repz_cmpxchg8b_FSxDI_icebp, BS3_PBC_NEAR
|
---|
1138 | db 0f0h, 0f3h
|
---|
1139 | cmpxchg8b [fs:xDI]
|
---|
1140 | .again:
|
---|
1141 | icebp
|
---|
1142 | jmp .again
|
---|
1143 | BS3_PROC_END_CMN bs3CpuInstr2_lock_repz_cmpxchg8b_FSxDI_icebp
|
---|
1144 |
|
---|
1145 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_repnz_cmpxchg8b_FSxDI_icebp, BS3_PBC_NEAR
|
---|
1146 | repnz cmpxchg8b [fs:xDI]
|
---|
1147 | .again:
|
---|
1148 | icebp
|
---|
1149 | jmp .again
|
---|
1150 | BS3_PROC_END_CMN bs3CpuInstr2_repnz_cmpxchg8b_FSxDI_icebp
|
---|
1151 |
|
---|
1152 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_lock_repnz_cmpxchg8b_FSxDI_icebp, BS3_PBC_NEAR
|
---|
1153 | db 0f0h, 0f2h
|
---|
1154 | cmpxchg8b [fs:xDI]
|
---|
1155 | .again:
|
---|
1156 | icebp
|
---|
1157 | jmp .again
|
---|
1158 | BS3_PROC_END_CMN bs3CpuInstr2_lock_repnz_cmpxchg8b_FSxDI_icebp
|
---|
1159 |
|
---|
1160 |
|
---|
1161 | ;
|
---|
1162 | ; CMPXCHG16B
|
---|
1163 | ;
|
---|
1164 | %if TMPL_BITS == 64
|
---|
1165 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_cmpxchg16b_rdi_ud2, BS3_PBC_NEAR
|
---|
1166 | cmpxchg16b [rdi]
|
---|
1167 | .again:
|
---|
1168 | ud2
|
---|
1169 | jmp .again
|
---|
1170 | AssertCompile(.again - BS3_LAST_LABEL == 4)
|
---|
1171 | BS3_PROC_END_CMN bs3CpuInstr2_cmpxchg16b_rdi_ud2
|
---|
1172 |
|
---|
1173 |
|
---|
1174 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_lock_cmpxchg16b_rdi_ud2, BS3_PBC_NEAR
|
---|
1175 | lock cmpxchg16b [rdi]
|
---|
1176 | .again:
|
---|
1177 | ud2
|
---|
1178 | jmp .again
|
---|
1179 | AssertCompile(.again - BS3_LAST_LABEL == 5)
|
---|
1180 | BS3_PROC_END_CMN bs3CpuInstr2_lock_cmpxchg16b_rdi_ud2
|
---|
1181 |
|
---|
1182 |
|
---|
1183 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_o16_cmpxchg16b_rdi_ud2, BS3_PBC_NEAR
|
---|
1184 | o16 cmpxchg16b [rdi]
|
---|
1185 | .again:
|
---|
1186 | ud2
|
---|
1187 | jmp .again
|
---|
1188 | AssertCompile(.again - BS3_LAST_LABEL == 5)
|
---|
1189 | BS3_PROC_END_CMN bs3CpuInstr2_o16_cmpxchg16b_rdi_ud2
|
---|
1190 |
|
---|
1191 |
|
---|
1192 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_lock_o16_cmpxchg16b_rdi_ud2, BS3_PBC_NEAR
|
---|
1193 | db 0f0h, 066h
|
---|
1194 | cmpxchg16b [rdi]
|
---|
1195 | .again:
|
---|
1196 | ud2
|
---|
1197 | jmp .again
|
---|
1198 | AssertCompile(.again - BS3_LAST_LABEL == 6)
|
---|
1199 | BS3_PROC_END_CMN bs3CpuInstr2_lock_o16_cmpxchg16b_rdi_ud2
|
---|
1200 |
|
---|
1201 |
|
---|
1202 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_repz_cmpxchg16b_rdi_ud2, BS3_PBC_NEAR
|
---|
1203 | repz cmpxchg16b [rdi]
|
---|
1204 | .again:
|
---|
1205 | ud2
|
---|
1206 | jmp .again
|
---|
1207 | AssertCompile(.again - BS3_LAST_LABEL == 5)
|
---|
1208 | BS3_PROC_END_CMN bs3CpuInstr2_repz_cmpxchg16b_rdi_ud2
|
---|
1209 |
|
---|
1210 |
|
---|
1211 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_lock_repz_cmpxchg16b_rdi_ud2, BS3_PBC_NEAR
|
---|
1212 | db 0f0h, 0f3h
|
---|
1213 | cmpxchg16b [rdi]
|
---|
1214 | .again:
|
---|
1215 | ud2
|
---|
1216 | jmp .again
|
---|
1217 | AssertCompile(.again - BS3_LAST_LABEL == 6)
|
---|
1218 | BS3_PROC_END_CMN bs3CpuInstr2_lock_repz_cmpxchg16b_rdi_ud2
|
---|
1219 |
|
---|
1220 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_repnz_cmpxchg16b_rdi_ud2, BS3_PBC_NEAR
|
---|
1221 | repnz cmpxchg16b [rdi]
|
---|
1222 | .again:
|
---|
1223 | ud2
|
---|
1224 | jmp .again
|
---|
1225 | AssertCompile(.again - BS3_LAST_LABEL == 5)
|
---|
1226 | BS3_PROC_END_CMN bs3CpuInstr2_repnz_cmpxchg16b_rdi_ud2
|
---|
1227 |
|
---|
1228 |
|
---|
1229 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_lock_repnz_cmpxchg16b_rdi_ud2, BS3_PBC_NEAR
|
---|
1230 | db 0f0h, 0f2h
|
---|
1231 | cmpxchg16b [rdi]
|
---|
1232 | .again:
|
---|
1233 | ud2
|
---|
1234 | jmp .again
|
---|
1235 | AssertCompile(.again - BS3_LAST_LABEL == 6)
|
---|
1236 | BS3_PROC_END_CMN bs3CpuInstr2_lock_repnz_cmpxchg16b_rdi_ud2
|
---|
1237 |
|
---|
1238 |
|
---|
1239 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_wrfsbase_rbx_ud2, BS3_PBC_NEAR
|
---|
1240 | wrfsbase rbx
|
---|
1241 | .again:
|
---|
1242 | ud2
|
---|
1243 | jmp .again
|
---|
1244 | AssertCompile(.again - BS3_LAST_LABEL == 5)
|
---|
1245 | BS3_PROC_END_CMN bs3CpuInstr2_wrfsbase_rbx_ud2
|
---|
1246 |
|
---|
1247 |
|
---|
1248 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_wrfsbase_ebx_ud2, BS3_PBC_NEAR
|
---|
1249 | wrfsbase ebx
|
---|
1250 | .again:
|
---|
1251 | ud2
|
---|
1252 | jmp .again
|
---|
1253 | AssertCompile(.again - BS3_LAST_LABEL == 4)
|
---|
1254 | BS3_PROC_END_CMN bs3CpuInstr2_wrfsbase_ebx_ud2
|
---|
1255 |
|
---|
1256 |
|
---|
1257 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_wrgsbase_rbx_ud2, BS3_PBC_NEAR
|
---|
1258 | wrgsbase rbx
|
---|
1259 | .again:
|
---|
1260 | ud2
|
---|
1261 | jmp .again
|
---|
1262 | AssertCompile(.again - BS3_LAST_LABEL == 5)
|
---|
1263 | BS3_PROC_END_CMN bs3CpuInstr2_wrgsbase_rbx_ud2
|
---|
1264 |
|
---|
1265 |
|
---|
1266 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_wrgsbase_ebx_ud2, BS3_PBC_NEAR
|
---|
1267 | wrgsbase ebx
|
---|
1268 | .again:
|
---|
1269 | ud2
|
---|
1270 | jmp .again
|
---|
1271 | AssertCompile(.again - BS3_LAST_LABEL == 4)
|
---|
1272 | BS3_PROC_END_CMN bs3CpuInstr2_wrgsbase_ebx_ud2
|
---|
1273 |
|
---|
1274 |
|
---|
1275 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_wrfsbase_rbx_rdfsbase_rcx_ud2, BS3_PBC_NEAR
|
---|
1276 | wrfsbase rbx
|
---|
1277 | mov ebx, 0
|
---|
1278 | rdfsbase rcx
|
---|
1279 | .again:
|
---|
1280 | ud2
|
---|
1281 | jmp .again
|
---|
1282 | AssertCompile(.again - BS3_LAST_LABEL == 15)
|
---|
1283 | BS3_PROC_END_CMN bs3CpuInstr2_wrfsbase_rbx_rdfsbase_rcx_ud2
|
---|
1284 |
|
---|
1285 |
|
---|
1286 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_wrfsbase_ebx_rdfsbase_ecx_ud2, BS3_PBC_NEAR
|
---|
1287 | wrfsbase ebx
|
---|
1288 | mov ebx, 0
|
---|
1289 | rdfsbase ecx
|
---|
1290 | .again:
|
---|
1291 | ud2
|
---|
1292 | jmp .again
|
---|
1293 | AssertCompile(.again - BS3_LAST_LABEL == 13)
|
---|
1294 | BS3_PROC_END_CMN bs3CpuInstr2_wrfsbase_ebx_rdfsbase_ecx_ud2
|
---|
1295 |
|
---|
1296 |
|
---|
1297 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_wrgsbase_rbx_rdgsbase_rcx_ud2, BS3_PBC_NEAR
|
---|
1298 | wrgsbase rbx
|
---|
1299 | mov ebx, 0
|
---|
1300 | rdgsbase rcx
|
---|
1301 | .again:
|
---|
1302 | ud2
|
---|
1303 | jmp .again
|
---|
1304 | AssertCompile(.again - BS3_LAST_LABEL == 15)
|
---|
1305 | BS3_PROC_END_CMN bs3CpuInstr2_wrgsbase_rbx_rdgsbase_rcx_ud2
|
---|
1306 |
|
---|
1307 |
|
---|
1308 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_wrgsbase_ebx_rdgsbase_ecx_ud2, BS3_PBC_NEAR
|
---|
1309 | wrgsbase ebx
|
---|
1310 | mov ebx, 0
|
---|
1311 | rdgsbase ecx
|
---|
1312 | .again:
|
---|
1313 | ud2
|
---|
1314 | jmp .again
|
---|
1315 | AssertCompile(.again - BS3_LAST_LABEL == 13)
|
---|
1316 | BS3_PROC_END_CMN bs3CpuInstr2_wrfgbase_ebx_rdgsbase_ecx_ud2
|
---|
1317 |
|
---|
1318 |
|
---|
1319 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_rdfsbase_rbx_ud2, BS3_PBC_NEAR
|
---|
1320 | rdfsbase rbx
|
---|
1321 | .again:
|
---|
1322 | ud2
|
---|
1323 | jmp .again
|
---|
1324 | AssertCompile(.again - BS3_LAST_LABEL == 5)
|
---|
1325 | BS3_PROC_END_CMN bs3CpuInstr2_rdfsbase_rbx_ud2
|
---|
1326 |
|
---|
1327 |
|
---|
1328 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_rdfsbase_ebx_ud2, BS3_PBC_NEAR
|
---|
1329 | rdfsbase ebx
|
---|
1330 | .again:
|
---|
1331 | ud2
|
---|
1332 | jmp .again
|
---|
1333 | AssertCompile(.again - BS3_LAST_LABEL == 4)
|
---|
1334 | BS3_PROC_END_CMN bs3CpuInstr2_rdfsbase_ebx_ud2
|
---|
1335 |
|
---|
1336 |
|
---|
1337 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_rdgsbase_rbx_ud2, BS3_PBC_NEAR
|
---|
1338 | rdgsbase rbx
|
---|
1339 | .again:
|
---|
1340 | ud2
|
---|
1341 | jmp .again
|
---|
1342 | AssertCompile(.again - BS3_LAST_LABEL == 5)
|
---|
1343 | BS3_PROC_END_CMN bs3CpuInstr2_rdgsbase_rbx_ud2
|
---|
1344 |
|
---|
1345 |
|
---|
1346 | BS3_PROC_BEGIN_CMN bs3CpuInstr2_rdgsbase_ebx_ud2, BS3_PBC_NEAR
|
---|
1347 | rdgsbase ebx
|
---|
1348 | .again:
|
---|
1349 | ud2
|
---|
1350 | jmp .again
|
---|
1351 | AssertCompile(.again - BS3_LAST_LABEL == 4)
|
---|
1352 | BS3_PROC_END_CMN bs3CpuInstr2_rdgsbase_ebx_ud2
|
---|
1353 |
|
---|
1354 |
|
---|
1355 | ;; @todo figure out this fudge. sigh.
|
---|
1356 | times (348) db 0cch ; fudge to avoid 'rderr' during boot.
|
---|
1357 |
|
---|
1358 | %endif ; TMPL_BITS == 64
|
---|
1359 |
|
---|
1360 |
|
---|
1361 | %endif ; BS3_INSTANTIATING_CMN
|
---|
1362 |
|
---|
1363 | %include "bs3kit-template-footer.mac" ; reset environment
|
---|
1364 |
|
---|