VirtualBox

source: vbox/trunk/src/VBox/Disassembler/testcase/tstDisasm-1A.asm@ 103928

Last change on this file since 103928 was 103717, checked in by vboxsync, 8 months ago

DIS: cmpxchg8b/16b fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 13.6 KB
Line 
1; $Id: tstDisasm-1A.asm 103717 2024-03-06 21:36:59Z vboxsync $
2;; @file
3; VBox disassembler: Assembler test routines
4;
5
6;
7; Copyright (C) 2006-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; SPDX-License-Identifier: GPL-3.0-only
26;
27
28;*******************************************************************************
29;* Header Files *
30;*******************************************************************************
31%include "iprt/asmdefs.mac"
32;%include "VBox/vmm/vm.mac"
33;%include "VBox/err.mac"
34;%include "VBox/vmm/stam.mac"
35;%include "iprt/x86.mac"
36
37BITS 32
38
39%ifndef __YASM_VERSION_ID__
40 %define __YASM_VERSION_ID__ 001010000h ; v1.2.0.0 for OS/2
41%endif
42%if __YASM_VERSION_ID__ >= 001020001h ; v1.2.0.1 and greater, make sure to exclude v1.2.0.0.
43 %define pmulhrwa pmulhrw
44%endif
45
46
47BEGINCODE
48
49align 16
50BEGINPROC TestProc32
51 xor eax, eax
52 mov al, 4
53 lea edx, [4]
54 mov edx, 4
55 mov eax, 4
56 shl eax, 4
57 shl edx, 4
58 shr edx, 4
59 mov eax, edx
60 mov eax, ecx
61 mov edx, eax
62 mov ecx, eax
63 DB 0xF0, 0x0F, 0x22, 0xC0
64 DB 0xF0, 0x0F, 0x20, 0xC0
65 smsw word [edx+16]
66 ; invept eax, dqword [ecx]
67 DB 0x66, 0x0F, 0x38, 0x80, 0x1
68 ; invept eax, dqword [ecx]
69 DB 0x66, 0x0F, 0x38, 0x81, 0x1
70 mov eax, dword [ecx]
71 mov word [edi], 0123ah
72 movzx eax,byte [edx]
73 movzx eax,word [edx]
74 mov dword [es:ebx + 1234h], 0789h
75 mov word [fs:ebx + ecx], 0654h
76 mov byte [esi + eax*4], 054h
77 mov bl, byte [ds:ebp + 1234h]
78 mov al, [cs:1234h + ecx*8]
79 mov al, [cs:1234h]
80 mov ax, [cs:1234h]
81 mov eax, [cs:1234h]
82 lock cmpxchg [ecx], eax
83 lock cmpxchg [ecx], ax
84 lock cmpxchg [ecx], dl
85 movzx ESI,word [EAX]
86 in al, dx
87 in ax, dx
88 in eax, dx
89 mov ebx, [ecx + eax*4 + 17]
90 mov ebx, [ebp + eax*4 + 4]
91 mov ebx, [ebp + eax*4]
92 int 80h
93 in al, 60h
94 in ax, dx
95 out 64h, eax
96
97 movss xmm0, xmm1
98 movss xmm3, [eax]
99 movss [eax], xmm4
100 movsd xmm6, xmm1
101
102 pause
103 nop
104
105 ; 3Dnow!
106 pavgusb mm1, mm0
107 pf2id mm5, mm4
108 pf2iw mm6, mm3
109 pfacc mm7, mm2
110 pfadd mm5, mm4
111 pfcmpeq mm6, mm3
112 pfcmpge mm2, mm7
113 pfcmpgt mm4, mm5
114 pfmax mm3, mm6
115 pfmin mm1, mm0
116 pfmul mm5, mm4
117 pmulhrwa mm3, mm6
118 pfnacc mm4, mm5
119 pfpnacc mm3, mm6
120 pfrcp mm0, mm1
121 pfrcpit1 mm2, mm7
122 pfrcpit2 mm4, mm5
123 pfrsqrt mm7, mm2
124 pfrsqit1 mm1, mm0
125 pfsub mm6, mm3
126 pfsubr mm0, mm1
127 pi2fd mm7, mm2
128 pi2fw mm0, mm1
129 pswapd mm2, mm7
130
131 pavgusb mm1, qword [es:eax+000000010h]
132 pf2id mm5, qword [ds:esi+000101010h]
133 pf2iw mm6, qword [fs:esi+000101010h]
134 pfacc mm7, qword [gs:esi+000101010h]
135 pfadd mm5, qword [ esi+000101010h]
136 pfcmpeq mm6, qword [ edi*8+000101010h]
137 pfcmpge mm2, qword [es:esi+000100010h]
138 pfcmpgt mm4, qword [es:esi+000101010h]
139 pfmax mm3, qword [es:esi+000101010h]
140 pfmin mm1, qword [es:esi+000101010h]
141 pfmul mm5, qword [es:esi+000101000h]
142%ifndef RT_OS_OS2 ; nasm objects to this
143 pmulhrwa mm3, qword [es:eax+0ffffffffh]
144%endif
145 pfnacc mm4, qword [es:ebx+000101010h]
146 pfpnacc mm3, qword [es:edx+000102900h]
147 pfrcp mm0, qword [es:ecx+000101020h]
148 pfrcpit1 mm2, qword [es:ebp+000101510h]
149 pfrcpit2 mm4, qword [es:esp+000101310h]
150 pfrsqrt mm7, qword [es:esi+0f0106010h]
151 pfrsqit1 mm1, qword [es:edi+0001f1010h]
152 pfsub mm6, qword [es:esi*2]
153 pfsubr mm0, qword [es:esi*3]
154 pi2fd mm7, qword [es:esi*4]
155 pi2fw mm0, qword [es:esi*5]
156 pswapd mm2, qword [es:esi*8]
157
158 pmulhrwa mm0, qword [ds:ebp+edi*8+00f000001h]
159
160 ; MMX
161 psubusb mm1, mm3
162 cvtpi2pd xmm0, mm3
163 paddd mm1, mm3
164 paddd xmm1, xmm3
165
166 lds eax, [ebx]
167 les ebp, [esp]
168%if __YASM_VERSION_ID__ >= 001030000h ; Old yasm doesn't support the instructions below
169 adcx eax, ebx
170 adcx eax, [edi]
171
172 adox eax, ebx
173 adox eax, [edi]
174 adox eax, [edi + 1000h]
175
176 tzcnt ax, bx
177 tzcnt eax, ebx
178 tzcnt ax, [edi]
179 tzcnt eax, [edi]
180 tzcnt eax, [edi + 1000h]
181 vpmovsxbw ymm0, xmm1
182 vpmovzxbq ymm1, [100h]
183 vgatherqps xmm0,dword [eax+xmm0*2],xmm0
184 vgatherqpd xmm0,qword [eax+xmm0*2],xmm0
185 vpsrld ymm5, ymm1, 009h
186 vpslld ymm0, ymm7, 01ah
187%endif
188
189 movbe eax, [edi]
190 movbe ebx, [edi + 1000h]
191 movbe ax, [edi]
192 movbe [edi], eax
193
194 crc32 eax, bl
195 crc32 eax, bx
196 crc32 eax, ebx
197 crc32 eax, byte [edi]
198 crc32 eax, word [edi]
199 crc32 eax, dword [edi]
200
201 popcnt ax, bx
202 popcnt eax, ebx
203 popcnt ax, [edi]
204 popcnt eax, [edi]
205 popcnt eax, [edi + 1000h]
206
207 lzcnt ax, bx
208 lzcnt eax, ebx
209 lzcnt ax, [edi]
210 lzcnt eax, [edi]
211 lzcnt eax, [edi + 1000h]
212
213 vmread eax, ebx
214 vmwrite eax, ebx
215
216 movd mm0, [edi]
217 movq mm0, [edi]
218 movq mm0, mm1
219
220 vmovups xmm0, xmm1
221 vmovaps ymm0, ymm1
222 vunpcklps xmm0, xmm1, xmm2
223 vunpcklps ymm0, ymm1, ymm2
224
225 lddqu xmm1, [ds:ebp+edi*8+00f000001h]
226 vlddqu xmm1, [ds:ebp+edi*8+00f000001h]
227 vlddqu ymm1, [ds:ebp+edi*8+00f000001h]
228
229 vpmovsxbw xmm0,qword [0x100]
230 vbroadcastf128 ymm0,oword [0x100]
231
232 palignr mm0, mm1, 1
233 vpinsrb xmm0, xmm1, eax, 1
234 vpinsrb xmm0, xmm1, [100h], 1
235 vinsertps xmm0, xmm1, xmm2, 1
236 vinsertps xmm0, xmm1, [100h], 1
237
238 vblendvps xmm0, xmm1, xmm2, xmm3
239 vblendvps ymm0, ymm1, ymm2, ymm3
240
241 aesimc xmm0, xmm1
242
243 pmovzxbq xmm0, xmm1
244 pmovzxbq xmm1, [100h]
245
246 vfmaddsub132pd ymm1, ymm2, ymm3
247
248%ifndef RT_OS_OS2
249 blsr eax, ebx
250 blsi eax, [ebx]
251%endif
252 db 0c4h, 0e2h, 0f8h, 0f3h, 01bh ; blsi rax, dword [ebx] - but VEX.W=1 is ignored, so same as previous
253%ifndef RT_OS_OS2
254 blsmsk eax, [ebx+edi*2]
255 shlx eax, ebx, ecx
256%endif
257
258 pmovmskb eax, mm2
259 pmovmskb eax, xmm3
260 vpmovmskb eax, xmm3
261%ifndef RT_OS_OS2
262 vpmovmskb eax, ymm3
263%endif
264
265ENDPROC TestProc32
266
267
268%ifndef RT_OS_OS2
269BITS 64
270align 16
271BEGINPROC TestProc64
272 mov cr8, rax
273 mov cr8, rbx
274 mov [0xfffe0080], rax
275 mov [0xfffe0080], rbx
276 mov rax, cr8
277 mov rbx, cr8
278 mov rax, [0xfffe0080]
279 mov rbx, [0xfffe0080]
280 divsd xmm1, xmm0
281 ; invept rdi, dqword [rsi]
282 DB 0x66, 0x0F, 0x38, 0x80, 0x3E
283 ; invept rcx, dqword [rdx]
284 DB 0x66, 0x0F, 0x38, 0x80, 0xA
285 ;invvpid rdi, dqword [rsi]
286 DB 0x66, 0x0F, 0x38, 0x81, 0x3E
287 ; invvpid rcx, dqword [rdx]
288 DB 0x66, 0x0F, 0x38, 0x81, 0xA
289 mov rdi, [rsi]
290 mov rcx, [rdx]
291 db 48h
292 db 0c7h
293 db 42h
294 db 18h
295 db 20h
296 db 3eh
297 db 23h
298 db 80h
299 call qword [r8+10h]
300 ; test
301 db 48h
302 db 8bh
303 db 44h
304 db 0ah
305 db 0f8h
306 ;incorrectly assembled by yasm; REX.W should not be added!
307 ;test rax, dword 0cc90cc90h
308 db 8bh
309 db 04h
310 db 8dh
311 db 00h
312 db 00h
313 db 0feh
314 db 0ffh
315 mov qword [rcx+rdx], 0
316 mov dword [rcx+rdx], 0
317 and [r15], rax
318 movzx rcx, sil
319 and sil, 3
320 movzx ecx, ah
321 and ah, 3
322
323 sub rcx, 1234h
324 mov rax, qword [0cc90cc90h]
325 mov rax, qword [00c90cc90h]
326 mov rax, dword 0cc90cc90h
327 mov rax, qword 0ffffcc90cc90h
328
329 movzx rax,byte [edx]
330 movzx rax,word [edx]
331 movzx rax,byte [rdx]
332 lock cmpxchg [rcx], rax
333 lock cmpxchg [rcx], ax
334 lock cmpxchg [r15], dl
335 movzx RSI, word [R8]
336 in al, dx
337 in ax, dx
338 in eax, dx
339 mov rbx, [rcx + rax*4 + 17]
340 mov rbx, [rbp + rax*4 + 4]
341 mov rbx, [rbp + rax*4]
342 mov rbx, [ebp + eax*4]
343 int 80h
344 in al, 60h
345 in ax, dx
346 out 64h, eax
347
348 movss xmm0, xmm14
349 movsd xmm6, xmm1
350
351 movbe eax, [rdi]
352 movbe ax, [rdi]
353 movbe rax, [rdi]
354
355 crc32 eax, bl
356 crc32 eax, bx
357 crc32 eax, ebx
358 crc32 eax, byte [edi]
359 crc32 eax, word [edi]
360 crc32 eax, dword [edi]
361
362 crc32 rax, bl
363 crc32 rax, byte [rdi]
364 crc32 rax, qword [rdi]
365
366%if __YASM_VERSION_ID__ >= 001030000h ; Old yasm doesn't support the instructions below
367
368 adcx eax, ebx
369 adcx rax, rbx
370 adcx r8, r11
371 adcx r8d, edx
372
373 adox eax, ebx
374 adox eax, [edi]
375 adox eax, [edi + 1000h]
376
377 adox rax, rbx
378 adox rax, [rdi]
379 adox rax, [rdi + 1000h]
380 adox rax, [edi + 1000h]
381
382 tzcnt ax, bx
383 tzcnt eax, ebx
384 tzcnt rax, rbx
385 tzcnt ax, [edi]
386 tzcnt eax, [edi]
387 tzcnt eax, [edi + 1000h]
388
389 vpunpcklbw ymm1, ymm2, ymm3
390 vpmovsxbw ymm4,[0x100]
391 vgatherqpd xmm0,qword [rbx+xmm11*2],xmm2
392
393 vpsrld ymm5, ymm1, 009h
394 vpsrld ymm8, ymm12, 011h
395 vpslld ymm0, ymm7, 01ah
396%endif
397
398 popcnt ax, bx
399 popcnt eax, ebx
400 popcnt rax, rbx
401 popcnt ax, [edi]
402 popcnt eax, [edi]
403 popcnt eax, [edi + 1000h]
404 popcnt rax, [rdi + 1000h]
405
406 lzcnt ax, bx
407 lzcnt eax, ebx
408 lzcnt rax, rbx
409 lzcnt ax, [edi]
410 lzcnt eax, [edi]
411 lzcnt eax, [edi + 1000h]
412 lzcnt eax, [rdi]
413 lzcnt ax, [rdi]
414 lzcnt rax, [rdi]
415 lzcnt r8d, [rdi]
416
417 vmread rax, rbx
418 vmwrite rax, rbx
419
420 getsec
421
422 movd mm0, [rdi]
423 movq mm0, [edi]
424 movq mm0, mm1
425
426 vmovups xmm0, xmm1
427 vmovaps ymm0, ymm1
428 vunpcklps xmm0, xmm1, xmm2
429 vunpcklps ymm0, ymm1, ymm2
430 vunpcklps ymm0, ymm10, ymm2
431
432 vmovups xmm5, xmm9
433
434 vcmpps xmm1, xmm2, xmm3, 12
435
436 lddqu xmm1, [ebp+edi*8+00f000001h]
437 vlddqu xmm1, [rbp+rdi*8+00f000001h]
438 vlddqu ymm1, [rbp+rdi*8+00f000001h]
439
440 vbroadcastf128 ymm0,oword [0x100]
441 vmovlps xmm0, xmm1, [100h]
442 vmovlps xmm0, xmm1, [eax + ebx]
443 vmovlps xmm0, xmm1, [rax + rbx]
444 vmovlps xmm10, xmm1, [rax]
445
446 vblendvpd xmm0, xmm1, [100h], xmm3
447
448 dpps xmm0, xmm1, 1
449
450 extractps eax, xmm2, 3
451 vzeroupper
452 vzeroall
453
454 movlps xmm0, [100h]
455 movlps xmm0, [eax + ebx]
456 movlps xmm10, [rax + rbx]
457 movhlps xmm0, xmm1
458
459 blsr eax, ebx
460 blsr rax, rbx
461 blsi eax, [rbx]
462 blsi rax, [rbx]
463 db 0c4h, 0e2h, 0f8h | 4, 0f3h, 01bh ; blsi rax, [rbx] with VEX.L=1 - should be invalid
464 blsmsk eax, [rbx+rdi*2]
465 blsmsk rax, [rbx+rdi*2]
466 blsmsk r8, [rbx+rdi*2]
467
468 shlx eax, ebx, ecx
469 shlx r8, rax, r15
470
471 pmovmskb eax, mm2
472 pmovmskb r9, mm2
473 pmovmskb eax, xmm3
474 pmovmskb r10, xmm3
475 vpmovmskb eax, xmm3
476 vpmovmskb rax, xmm3
477 vpmovmskb r11, ymm9
478
479 sha1nexte xmm0, xmm1
480 sha1msg1 xmm0, xmm1
481 sha1msg2 xmm0, xmm1
482 sha1rnds4 xmm1, xmm2, 0
483 sha1rnds4 xmm1, xmm2, 1
484 sha256msg1 xmm0, xmm1
485 sha256msg2 xmm0, xmm1
486 sha256rnds2 xmm0, xmm1
487
488 vpsrldq xmm1, xmm2, 3
489 db 066h
490 vpsrldq xmm1, xmm2, 3
491 vpsllq xmm15, xmm8, 99
492
493 ; group 7 stuff.
494 vmcall
495 vmlaunch
496 vmresume
497 vmxoff
498 monitor
499 mwait
500 clac
501 stac
502 encls
503 xgetbv
504 xsetbv
505 vmfunc
506 xend
507 xtest
508 enclu
509 swpgs
510 rdtscp
511 rdfsbase rax
512 wrgsbase r15
513 rdrand rax
514 vmxon [rax]
515
516 cmpxchg8b [rdi]
517 lock cmpxchg8b [rdi]
518 cmpxchg16b [rdi]
519 lock cmpxchg16b [rdi]
520 vmptrst [rsi + 1]
521
522 ret
523ENDPROC TestProc64
524%endif ; !OS2
525
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette