-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathP06P1_Asm_x64.asm
515 lines (435 loc) · 8.54 KB
/
P06P1_Asm_x64.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
data SEGMENT PAGE
data ENDS
INST_REPEAT EQU 1000
.code
_BZHI macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
bzhi rax, rax, rcx ; P1
ENDM
ENDM
_BEXTR macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
bextr rax, rax, rcx ; P1
ENDM
ENDM
_BT macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
bt rax, rcx ; P1
adc eax, 0
ENDM
ENDM
_BTC macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
btc rax, rcx ; P1
ENDM
ENDM
_BTS macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
bts rax, rcx ; P1
ENDM
ENDM
_BTR macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
btr rax, rcx ; P1
ENDM
ENDM
_SHLX macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
shlx rax, rax, rcx ; P06
;shlx rbx, rbx, rcx ; P06
;shlx r8, r8, rcx ; P06
ENDM
ENDM
_SHL_CL macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
shl rax, cl ; 2*P06
;shl rbx, cl ; 2*P06
;shl r8, cl ; P06
ENDM
ENDM
_SHL_IMM8 macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
shl rax, 2 ; P06
ENDM
ENDM
_SHL_IMPL1 macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
shl rax, 1 ; 2*P06
ENDM
ENDM
_SHRX macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
shrx rax, rax, rcx ; P06
;shrx rbx, rbx, rcx ; P06
;shrx r8, r8, rcx ; P06
ENDM
ENDM
_SHR_CL macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
shr rax, cl ; 2*P06
;shr rbx, cl ; 2*P06
;shr r8, cl ; 2*P06
ENDM
ENDM
_SHR_IMM8 macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
shr rax, 2 ; P06
ENDM
ENDM
_SHR_IMPL1 macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
shr rax, 1 ; 2*P06
ENDM
ENDM
_SARX macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
sarx rax, rax, rcx ; P06
;sarx rbx, rbx, rcx ; P06
;sarx r8, r8, rcx ; P06
ENDM
ENDM
_SAR_CL macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
sar rax, cl ; 2*P06
;sar rbx, cl ; 2*P06
;sar r8, cl ; 2*P06
ENDM
ENDM
_SAR_IMM8 macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
sar rax, 2 ; P06
ENDM
ENDM
_SAR_IMPL1 macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
sar rax, 1 ; 2*P06
ENDM
ENDM
_RORX macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
rorx rcx, rcx, 59 ; P06
ENDM
ENDM
_ROR_CL macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
ror rax, cl ; 2*P06
;ror rbx, cl ; 2*P06
;ror r8, cl ; 2*P06
ENDM
ENDM
_ROR_IMM8 macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
ror rax, 2 ; P06
ENDM
ENDM
_ROR_IMPL1 macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
ror rax, 1 ; 2*P06
ENDM
ENDM
_RCR_CL macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
rcr rax, cl ; 2*P06
ENDM
ENDM
_RCR_IMM8 macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
rcr rax, 2 ; P06
ENDM
ENDM
_RCR_IMPL1 macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
rcr rax, 1 ; 2*P06
ENDM
ENDM
_ROL_CL macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
rol rax, cl ; 2*P06
;rol rbx, cl ; 2*P06
;rol r8, cl ; 2*P06
ENDM
ENDM
_ROL_IMM8 macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
rol rax, 2 ; P06
ENDM
ENDM
_ROL_IMPL1 macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
rol rax, 1 ; 2*P06
ENDM
ENDM
_RCL_CL macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
rcl rax, cl ; 2*P06
ENDM
ENDM
_RCL_IMM8 macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
rcl rax, 2 ; P06
ENDM
ENDM
_RCL_IMPL1 macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
rcl rax, 1 ; 2*P06
ENDM
ENDM
_ADC_IMM8 macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
adc rax, 1 ; P06
ENDM
ENDM
_SBB_IMM8 macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
sbb rax, 1 ; P06
ENDM
ENDM
_ADOX macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
adox rax, rcx ; P06
ENDM
ENDM
_ADCX macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
adcx rax, rcx ; P06
ENDM
ENDM
_CMOVBE macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
cmovbe rax, rcx ; P06
ENDM
ENDM
_CMOVNBE macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
cmovnbe rax, rcx ; P06
ENDM
ENDM
_CMOVZ macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
cmovz rax, rcx ; P06
ENDM
ENDM
_CMOVNZ macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
cmovnz rax, rcx ; P06
ENDM
ENDM
_BSWAP macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
bswap rax ; P1+P06
ENDM
ENDM
_POPCNT macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
popcnt rcx, rcx ; P1
ENDM
ENDM
_LZCNT macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
lzcnt rcx, rcx ; P1
ENDM
ENDM
_TZCNT macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
tzcnt rcx, rcx ; P1
ENDM
ENDM
_BSR macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
bsr rcx, rcx ; P1
ENDM
ENDM
_BSF macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
bsf rcx, rcx ; P1
ENDM
ENDM
_CRC32 macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
crc32 rcx, rcx ; P1
ENDM
ENDM
_PDEP macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
pdep rax, rax, rcx ; P1
ENDM
ENDM
_PEXT macro I1, I2
mov I1, I2
REPEAT INST_REPEAT
pext rax, rax, rcx ; P1
ENDM
ENDM
TIMED2 macro PNAME, CORE, I1, I2
PNAME proc
push r15
push r14
push rbx
push rdi
push rsi
mfence
rdtscp
lfence
shl rdx, 20h
or rax, rdx
mov r15, rax
mov rdx, INST_REPEAT
xor eax, eax
xor ebx, eax
xor ecx, ecx
LOOPLABEL:
CORE I1, I2
dec rdx
jnz LOOPLABEL
mfence
rdtscp
lfence
shl rdx, 20h
or rax, rdx
sub rax, r15
pop rsi
pop rdi
pop rbx
pop r14
pop r15
ret
PNAME endp
endm
wrap macro INST, MCRO, INITREG
TIMED2 _&INST&_MOV_R&INITREG&_M1025_TIME, MCRO, R&INITREG&, -1025
TIMED2 _&INST&_MOV_E&INITREG&_M1025_TIME, MCRO, E&INITREG&, -1025
TIMED2 _&INST&_MOV_R&INITREG&_M1024_TIME, MCRO, R&INITREG&, -1024
TIMED2 _&INST&_MOV_E&INITREG&_M1024_TIME, MCRO, E&INITREG&, -1024
TIMED2 _&INST&_MOV_R&INITREG&_M513_TIME, MCRO, R&INITREG&, -513
TIMED2 _&INST&_MOV_E&INITREG&_M513_TIME, MCRO, E&INITREG&, -513
TIMED2 _&INST&_MOV_R&INITREG&_M512_TIME, MCRO, R&INITREG&, -512
TIMED2 _&INST&_MOV_E&INITREG&_M512_TIME, MCRO, E&INITREG&, -512
TIMED2 _&INST&_MOV_R&INITREG&_511_TIME, MCRO, R&INITREG&, 511
TIMED2 _&INST&_MOV_E&INITREG&_511_TIME, MCRO, E&INITREG&, 511
TIMED2 _&INST&_MOV_R&INITREG&_512_TIME, MCRO, R&INITREG&, 512
TIMED2 _&INST&_MOV_E&INITREG&_512_TIME, MCRO, E&INITREG&, 512
TIMED2 _&INST&_MOV_R&INITREG&_1023_TIME, MCRO, R&INITREG&, 1023
TIMED2 _&INST&_MOV_E&INITREG&_1023_TIME, MCRO, E&INITREG&, 1023
TIMED2 _&INST&_MOV_R&INITREG&_1024_TIME, MCRO, R&INITREG&, 1024
TIMED2 _&INST&_MOV_E&INITREG&_1024_TIME, MCRO, E&INITREG&, 1024
endm
wrap BT_RAX_RCX, _BT, CX
wrap BT_RAX_RCX, _BT, AX
wrap BTC_RAX_RCX, _BTC, CX
wrap BTC_RAX_RCX, _BTC, AX
wrap BTR_RAX_RCX, _BTR, CX
wrap BTR_RAX_RCX, _BTR, AX
wrap BTS_RAX_RCX, _BTS, CX
wrap BTS_RAX_RCX, _BTS, AX
wrap BZHI_RAX_RAX_RCX, _BZHI, CX
wrap BZHI_RAX_RAX_RCX, _BZHI, AX
wrap BEXTR_RAX_RAX_RCX, _BEXTR, CX
wrap BEXTR_RAX_RAX_RCX, _BEXTR, AX
wrap SHLX_RAX_RAX_RCX, _SHLX, CX
wrap SHLX_RAX_RAX_RCX, _SHLX, AX
wrap SHL_RAX_CL, _SHL_CL, CX
wrap SHL_RAX_CL, _SHL_CL, AX
wrap SHL_RAX_IMM8, _SHL_IMM8, AX
wrap SHL_RAX_IMPL1, _SHL_IMPL1, AX
wrap SHRX_RAX_RAX_RCX, _SHRX, CX
wrap SHRX_RAX_RAX_RCX, _SHRX, AX
wrap SHR_RAX_CL, _SHR_CL, CX
wrap SHR_RAX_CL, _SHR_CL, AX
wrap SHR_RAX_IMM8, _SHR_IMM8, AX
wrap SHR_RAX_IMPL1, _SHR_IMPL1, AX
wrap SARX_RAX_RAX_RCX, _SARX, CX
wrap SARX_RAX_RAX_RCX, _SARX, AX
wrap SAR_RAX_CL, _SAR_CL, CX
wrap SAR_RAX_CL, _SAR_CL, AX
wrap SAR_RAX_IMM8, _SAR_IMM8, AX
wrap SAR_RAX_IMPL1, _SAR_IMPL1, AX
wrap RORX_RCX_RCX_IMM8, _RORX, CX
wrap ROR_RAX_CL, _ROR_CL, CX
wrap ROR_RAX_CL, _ROR_CL, AX
wrap ROR_RAX_IMM8, _ROR_IMM8, AX
wrap ROR_RAX_IMPL1, _ROR_IMPL1, AX
wrap RCR_RAX_CL, _RCR_CL, CX
wrap RCR_RAX_CL, _RCR_CL, AX
wrap RCR_RAX_IMM8, _RCR_IMM8, AX
wrap RCR_RAX_IMPL1, _RCR_IMPL1, AX
wrap ROL_RAX_CL, _ROL_CL, CX
wrap ROL_RAX_CL, _ROL_CL, AX
wrap ROL_RAX_IMM8, _ROL_IMM8, AX
wrap ROL_RAX_IMPL1, _ROL_IMPL1, AX
wrap RCL_RAX_CL, _RCL_CL, CX
wrap RCL_RAX_CL, _RCL_CL, AX
wrap RCL_RAX_IMM8, _RCL_IMM8, AX
wrap RCL_RAX_IMPL1, _RCL_IMPL1, AX
wrap ADC_RAX_IMM8, _ADC_IMM8, AX
wrap SBB_RAX_IMM8, _SBB_IMM8, AX
wrap ADCX_RAX_RCX, _ADCX, CX
wrap ADCX_RAX_RCX, _ADCX, AX
wrap ADOX_RAX_RCX, _ADOX, CX
wrap ADOX_RAX_RCX, _ADOX, AX
wrap CMOVBE_RAX_RCX, _CMOVBE, CX
wrap CMOVNBE_RAX_RCX, _CMOVNBE, CX
wrap CMOVZ_RAX_RCX, _CMOVZ, CX
wrap CMOVNZ_RAX_RCX, _CMOVNZ, CX
wrap CMOVBE_RAX_RCX, _CMOVBE, AX
wrap CMOVNBE_RAX_RCX, _CMOVNBE, AX
wrap CMOVZ_RAX_RCX, _CMOVZ, AX
wrap CMOVNZ_RAX_RCX, _CMOVNZ, AX
wrap BSWAP_RAX, _BSWAP, AX
wrap POPCNT_RCX_RCX, _POPCNT, CX
wrap LZCNT_RCX_RCX, _LZCNT, CX
wrap TZCNT_RCX_RCX, _TZCNT, CX
wrap BSR_RCX_RCX, _BSR, CX
wrap BSF_RCX_RCX, _BSF, CX
wrap CRC32_RCX_RCX, _CRC32, CX
wrap PDEP_RAX_RAX_RCX, _PDEP, CX
wrap PDEP_RAX_RAX_RCX, _PDEP, AX
wrap PEXT_RAX_RAX_RCX, _PEXT, CX
wrap PEXT_RAX_RAX_RCX, _PEXT, AX
END