aboutsummaryrefslogtreecommitdiffstats
path: root/test/k_test.asm
blob: d5f346bf8f9474ed1a5327b8cfca369dfc2f1cf3 (plain)
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
	bits 64
	default rel

%use altreg

	section .text

bar	equ 0xcc

	;; Each instruction group separated by blank should encode identially

	;; k_mov kreg size_suffix size_name gpr big_gpr
%macro k_mov 5
	kmov%2 %1,[foo]
	kmov %1,%3 [foo]
	kmov %3 [foo],%1

	kmov%2 [foo],%1
	kmov  %3 [foo],%1
	kmov  [foo],%3 %1
	kmov  %3 [foo],%1

	kmov%2 %1,%1
	kmov   %3 %1,%1
	kmov   %1,%3 %1

	kmov%2 %1,%4
	kmov%2 %1,%5
	kmov   %1,%4
	kmov   %3 %1,%4
	kmov   %3 %1,%5
	kmov   %1,%3 %4
    %ifidni %4,%5
	kmov   %1,%5
    %endif

	kmov%2 %5,%1
    %ifidni %4,%5
	kmov   %5,%1
    %endif
	kmov   %5,%3 %1

%endmacro

%pragma list options +bempf

	;; k_rr op kreg size_suffix size_name
%macro k_rr 4
	%1%3 %2,%2
	%1  %4 %2,%2
	%1  %2,%4 %2

%endmacro

	;; k_rri op kreg size_suffix size_name
%macro k_rrr 4
	%1%3 %2,%2,%2
	%1  %4 %2,%2,%2
	%1  %2,%4 %2,%2
	%1  %2,%2,%4 %2

%endmacro

	;; k_rri op kreg size_suffix size_name
%macro k_rri 4
	%1%3 %2,%2,bar
	%1  %4 %2,%2,bar
	%1  %2,%4 %2,bar

%endmacro

%define size_b byte
%define size_w word
%define size_d dword
%define size_q qword

%define gpr_b  b
%define gpr_w  w
%define gpr_d  d
%define gpr_q

%define bgpr_b d
%define bgpr_w d
%define bgpr_d d
%define bgpr_q

	;; k_test size_suffix regno
%macro k_test 2
	k_mov k%2,%1,size_%1,%[r %+ %2 %+ gpr_%1],%[r %+ %2 %+ bgpr_%1]
	k_rrr kadd,k%2,%1,size_%1
	k_rrr kand,k%2,%1,size_%1
	k_rrr kandn,k%2,%1,size_%1
	k_rrr kand,k%2,%1,size_%1
	k_rr knot,k%2,%1,size_%1
	k_rrr kor,k%2,%1,size_%1
	k_rr kortest,k%2,%1,size_%1
	k_rri kshiftl,k%2,%1,size_%1
	k_rri kshiftr,k%2,%1,size_%1
	k_rr ktest,k%2,%1,size_%1
	k_rrr kxnor,k%2,%1,size_%1
	k_rrr kxor,k%2,%1,size_%1
%endmacro

%assign nreg 0
%define kreg k %+ nreg
%rep 8

	k_test b,nreg
	k_test w,nreg
	k_test d,nreg
	k_test q,nreg

	kunpckbw kreg,kreg,kreg
	kunpck   word kreg,kreg,kreg
	kunpck   kreg,byte kreg,kreg
	kunpck   kreg,kreg,byte kreg
	kunpck   word kreg,byte kreg,kreg
	kunpck   word kreg,kreg,byte kreg

	kunpckwd kreg,kreg,kreg
	kunpck   dword kreg,kreg,kreg
	kunpck   kreg,word kreg,kreg
	kunpck   kreg,kreg,word kreg
	kunpck   dword kreg,word kreg,kreg
	kunpck   dword kreg,kreg,word kreg

	kunpckdq kreg,kreg,kreg
	kunpck   qword kreg,kreg,kreg
	kunpck   kreg,dword kreg,kreg
	kunpck   kreg,kreg,dword kreg
	kunpck   qword kreg,dword kreg,kreg
	kunpck   qword kreg,kreg,dword kreg

	%assign nreg nreg+1
%endrep

	section .bss

foo	resq 1