initial commit: a mess of assembly code
[fmap.git] / x86_64_sse2_x87 / fasm / examples / x86 / include / ext / bmi2.inc
blobcb5930faad99df6f69618cafae0ba97a8859d193
1 \r
2 include 'bmi1.inc'\r
3 \r
4 iterate <instr,opcode>, bzhi,0F5h\r
5 \r
6         macro instr? dest*,src*,src2*\r
7                 x86.parse_operand @dest,dest\r
8                 x86.parse_operand @src,src\r
9                 x86.parse_operand @src2,src2\r
10                 if @dest.type = 'reg' & (@src.type = 'mem' | @src.type = 'reg') & @src2.type = 'reg'\r
11                         if @dest.size < 4\r
12                                 err 'invalid operand size'\r
13                         else if @src.size and not @dest.size | @src2.size <> @dest.size\r
14                                 err 'operand sizes do not match'\r
15                         end if\r
16                         if @dest.size = 8\r
17                                 if x86.mode < 64\r
18                                         err 'instruction requires long mode'\r
19                                 end if\r
20                                 AVX.store_instruction 16,VEX_0F38_W1,opcode,@src,@dest.rm,@src2.rm\r
21                         else\r
22                                 AVX.store_instruction 16,VEX_0F38_W0,opcode,@src,@dest.rm,@src2.rm\r
23                         end if\r
24                 else\r
25                         err 'invalid combination of operands'\r
26                 end if\r
27         end macro\r
29 end iterate\r
31 iterate <instr,vex_mp,opcode>, mulx,VEX_F2_0F38,0F6h, pdep,VEX_F2_0F38,0F5h, pext,VEX_F3_0F38,0F5h\r
33         macro instr? dest*,src*,src2*\r
34                 x86.parse_operand @dest,dest\r
35                 x86.parse_operand @src,src\r
36                 x86.parse_operand @src2,src2\r
37                 if @dest.type = 'reg' & @src.type = 'reg' & (@src2.type = 'mem' | @src2.type = 'reg')\r
38                         if @dest.size < 4\r
39                                 err 'invalid operand size'\r
40                         else if @src.size <> @dest.size | @src2.size and not @dest.size\r
41                                 err 'operand sizes do not match'\r
42                         end if\r
43                         if @dest.size = 8\r
44                                 if x86.mode < 64\r
45                                         err 'instruction requires long mode'\r
46                                 end if\r
47                                 AVX.store_instruction 16,vex_mp#_W1,opcode,@src2,@dest.rm,@src.rm\r
48                         else\r
49                                 AVX.store_instruction 16,vex_mp#_W0,opcode,@src2,@dest.rm,@src.rm\r
50                         end if\r
51                 else\r
52                         err 'invalid combination of operands'\r
53                 end if\r
54         end macro\r
56 end iterate\r
58 macro rorx? dest*,src*,src2*\r
59         x86.parse_operand @dest,dest\r
60         x86.parse_operand @src,src\r
61         x86.parse_operand @src2,src2\r
62         if @dest.type = 'reg' & (@src.type = 'mem' | @src.type = 'reg') & @src2.type = 'imm'\r
63                 if @dest.size < 4 | @src2.size and not 1\r
64                         err 'invalid operand size'\r
65                 else if @src.size and not @dest.size\r
66                         err 'operand sizes do not match'\r
67                 end if\r
68                 if @dest.size = 8\r
69                         if x86.mode < 64\r
70                                 err 'instruction requires long mode'\r
71                         end if\r
72                         AVX.store_instruction 16,VEX_F2_0F3A_W1,0F0h,@src,@dest.rm,,1,@src2.imm\r
73                 else\r
74                         AVX.store_instruction 16,VEX_F2_0F3A_W0,0F0h,@src,@dest.rm,,1,@src2.imm\r
75                 end if\r
76         else\r
77                 err 'invalid combination of operands'\r
78         end if\r
79 end macro\r
81 iterate <instr,vex_mp,opcode>, sarx,VEX_F3_0F38,0F7h, shlx,VEX_66_0F38,0F7h, shrx,VEX_F2_0F38,0F7h\r
83         macro instr? dest*,src*,src2*\r
84                 x86.parse_operand @dest,dest\r
85                 x86.parse_operand @src,src\r
86                 x86.parse_operand @src2,src2\r
87                 if @dest.type = 'reg' & (@src.type = 'mem' | @src.type = 'reg') & @src2.type = 'reg'\r
88                         if @dest.size < 4\r
89                                 err 'invalid operand size'\r
90                         else if @src.size and not @dest.size | @src2.size <> @dest.size\r
91                                 err 'operand sizes do not match'\r
92                         end if\r
93                         if @dest.size = 8\r
94                                 if x86.mode < 64\r
95                                         err 'instruction requires long mode'\r
96                                 end if\r
97                                 AVX.store_instruction 16,vex_mp#_W1,opcode,@src,@dest.rm,@src2.rm\r
98                         else\r
99                                 AVX.store_instruction 16,vex_mp#_W0,opcode,@src,@dest.rm,@src2.rm\r
100                         end if\r
101                 else\r
102                         err 'invalid combination of operands'\r
103                 end if\r
104         end macro\r
106 end iterate\r