1 //===- subzero/unittest/AssemblerX8664/LowLevel.cpp -----------------------===//
2 //
3 // The Subzero Code Generator
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 #include "AssemblerX8664/TestUtil.h"
10
11 namespace Ice {
12 namespace X8664 {
13 namespace Test {
14 namespace {
15
TEST_F(AssemblerX8664LowLevelTest,Ret)16 TEST_F(AssemblerX8664LowLevelTest, Ret) {
17 __ ret();
18
19 constexpr size_t ByteCount = 1;
20 ASSERT_EQ(ByteCount, codeBytesSize());
21
22 verifyBytes<ByteCount>(codeBytes(), 0xc3);
23 }
24
TEST_F(AssemblerX8664LowLevelTest,RetImm)25 TEST_F(AssemblerX8664LowLevelTest, RetImm) {
26 __ ret(Immediate(0x20));
27
28 constexpr size_t ByteCount = 3;
29 ASSERT_EQ(ByteCount, codeBytesSize());
30
31 verifyBytes<ByteCount>(codeBytes(), 0xC2, 0x20, 0x00);
32 }
33
TEST_F(AssemblerX8664LowLevelTest,CallImm4)34 TEST_F(AssemblerX8664LowLevelTest, CallImm4) {
35 __ call(Immediate(4));
36
37 constexpr size_t ByteCount = 5;
38 ASSERT_EQ(ByteCount, codeBytesSize());
39
40 verifyBytes<ByteCount>(codeBytes(), 0xe8, 0x00, 0x00, 0x00, 0x00);
41 }
42
TEST_F(AssemblerX8664LowLevelTest,PopRegs)43 TEST_F(AssemblerX8664LowLevelTest, PopRegs) {
44 __ popl(Encoded_GPR_eax());
45 __ popl(Encoded_GPR_ebx());
46 __ popl(Encoded_GPR_ecx());
47 __ popl(Encoded_GPR_edx());
48 __ popl(Encoded_GPR_edi());
49 __ popl(Encoded_GPR_esi());
50 __ popl(Encoded_GPR_ebp());
51 __ popl(Encoded_GPR_r8());
52 __ popl(Encoded_GPR_r9());
53 __ popl(Encoded_GPR_r10());
54 __ popl(Encoded_GPR_r11());
55 __ popl(Encoded_GPR_r12());
56 __ popl(Encoded_GPR_r13());
57 __ popl(Encoded_GPR_r14());
58 __ popl(Encoded_GPR_r15());
59
60 constexpr size_t ByteCount = 23;
61 ASSERT_EQ(ByteCount, codeBytesSize());
62
63 constexpr uint8_t Rex_B = 0x41;
64 constexpr uint8_t PopOpcode = 0x58;
65 verifyBytes<ByteCount>(
66 codeBytes(), PopOpcode | Encoded_GPR_eax(), PopOpcode | Encoded_GPR_ebx(),
67 PopOpcode | Encoded_GPR_ecx(), PopOpcode | Encoded_GPR_edx(),
68 PopOpcode | Encoded_GPR_edi(), PopOpcode | Encoded_GPR_esi(),
69 PopOpcode | Encoded_GPR_ebp(), Rex_B, PopOpcode | (Encoded_GPR_r8() & 7),
70 Rex_B, PopOpcode | (Encoded_GPR_r9() & 7), Rex_B,
71 PopOpcode | (Encoded_GPR_r10() & 7), Rex_B,
72 PopOpcode | (Encoded_GPR_r11() & 7), Rex_B,
73 PopOpcode | (Encoded_GPR_r12() & 7), Rex_B,
74 PopOpcode | (Encoded_GPR_r13() & 7), Rex_B,
75 PopOpcode | (Encoded_GPR_r14() & 7), Rex_B,
76 PopOpcode | (Encoded_GPR_r15() & 7));
77 }
78
TEST_F(AssemblerX8664LowLevelTest,PushRegs)79 TEST_F(AssemblerX8664LowLevelTest, PushRegs) {
80 __ pushl(Encoded_GPR_eax());
81 __ pushl(Encoded_GPR_ebx());
82 __ pushl(Encoded_GPR_ecx());
83 __ pushl(Encoded_GPR_edx());
84 __ pushl(Encoded_GPR_edi());
85 __ pushl(Encoded_GPR_esi());
86 __ pushl(Encoded_GPR_ebp());
87 __ pushl(Encoded_GPR_r8());
88 __ pushl(Encoded_GPR_r9());
89 __ pushl(Encoded_GPR_r10());
90 __ pushl(Encoded_GPR_r11());
91 __ pushl(Encoded_GPR_r12());
92 __ pushl(Encoded_GPR_r13());
93 __ pushl(Encoded_GPR_r14());
94 __ pushl(Encoded_GPR_r15());
95
96 constexpr size_t ByteCount = 23;
97 ASSERT_EQ(ByteCount, codeBytesSize());
98
99 constexpr uint8_t Rex_B = 0x41;
100 constexpr uint8_t PushOpcode = 0x50;
101 verifyBytes<ByteCount>(
102 codeBytes(), PushOpcode | Encoded_GPR_eax(),
103 PushOpcode | Encoded_GPR_ebx(), PushOpcode | Encoded_GPR_ecx(),
104 PushOpcode | Encoded_GPR_edx(), PushOpcode | Encoded_GPR_edi(),
105 PushOpcode | Encoded_GPR_esi(), PushOpcode | Encoded_GPR_ebp(), Rex_B,
106 PushOpcode | (Encoded_GPR_r8() & 7), Rex_B,
107 PushOpcode | (Encoded_GPR_r9() & 7), Rex_B,
108 PushOpcode | (Encoded_GPR_r10() & 7), Rex_B,
109 PushOpcode | (Encoded_GPR_r11() & 7), Rex_B,
110 PushOpcode | (Encoded_GPR_r12() & 7), Rex_B,
111 PushOpcode | (Encoded_GPR_r13() & 7), Rex_B,
112 PushOpcode | (Encoded_GPR_r14() & 7), Rex_B,
113 PushOpcode | (Encoded_GPR_r15() & 7));
114 }
115
TEST_F(AssemblerX8664LowLevelTest,MovRegisterZero)116 TEST_F(AssemblerX8664LowLevelTest, MovRegisterZero) {
117 __ mov(IceType_i32, Encoded_GPR_eax(), Immediate(0x00));
118 __ mov(IceType_i32, Encoded_GPR_ebx(), Immediate(0x00));
119 __ mov(IceType_i32, Encoded_GPR_ecx(), Immediate(0x00));
120 __ mov(IceType_i32, Encoded_GPR_edx(), Immediate(0x00));
121 __ mov(IceType_i32, Encoded_GPR_edi(), Immediate(0x00));
122 __ mov(IceType_i32, Encoded_GPR_esi(), Immediate(0x00));
123 __ mov(IceType_i32, Encoded_GPR_ebp(), Immediate(0x00));
124 __ mov(IceType_i32, Encoded_GPR_r8(), Immediate(0x00));
125 __ mov(IceType_i32, Encoded_GPR_r10(), Immediate(0x00));
126 __ mov(IceType_i32, Encoded_GPR_r11(), Immediate(0x00));
127 __ mov(IceType_i32, Encoded_GPR_r12(), Immediate(0x00));
128 __ mov(IceType_i32, Encoded_GPR_r13(), Immediate(0x00));
129 __ mov(IceType_i32, Encoded_GPR_r14(), Immediate(0x00));
130 __ mov(IceType_i32, Encoded_GPR_r15(), Immediate(0x00));
131
132 constexpr uint8_t Rex_B = 0x41;
133 constexpr size_t MovReg32BitImmBytes = 5;
134 constexpr size_t ByteCount = 14 * MovReg32BitImmBytes + 7 /*Rex_B*/;
135
136 ASSERT_EQ(ByteCount, codeBytesSize());
137
138 constexpr uint8_t MovOpcode = 0xb8;
139 verifyBytes<ByteCount>(
140 codeBytes(), MovOpcode | Encoded_GPR_eax(), 0x00, 0x00, 0x00, 0x00,
141 MovOpcode | Encoded_GPR_ebx(), 0x00, 0x00, 0x00, 0x00,
142 MovOpcode | Encoded_GPR_ecx(), 0x00, 0x00, 0x00, 0x00,
143 MovOpcode | Encoded_GPR_edx(), 0x00, 0x00, 0x00, 0x00,
144 MovOpcode | Encoded_GPR_edi(), 0x00, 0x00, 0x00, 0x00,
145 MovOpcode | Encoded_GPR_esi(), 0x00, 0x00, 0x00, 0x00,
146 MovOpcode | Encoded_GPR_ebp(), 0x00, 0x00, 0x00, 0x00, Rex_B,
147 MovOpcode | (Encoded_GPR_r8() & 7), 0x00, 0x00, 0x00, 0x00, Rex_B,
148 MovOpcode | (Encoded_GPR_r10() & 7), 0x00, 0x00, 0x00, 0x00, Rex_B,
149 MovOpcode | (Encoded_GPR_r11() & 7), 0x00, 0x00, 0x00, 0x00, Rex_B,
150 MovOpcode | (Encoded_GPR_r12() & 7), 0x00, 0x00, 0x00, 0x00, Rex_B,
151 MovOpcode | (Encoded_GPR_r13() & 7), 0x00, 0x00, 0x00, 0x00, Rex_B,
152 MovOpcode | (Encoded_GPR_r14() & 7), 0x00, 0x00, 0x00, 0x00, Rex_B,
153 MovOpcode | (Encoded_GPR_r15() & 7), 0x00, 0x00, 0x00, 0x00);
154 }
155
TEST_F(AssemblerX8664LowLevelTest,Cmp)156 TEST_F(AssemblerX8664LowLevelTest, Cmp) {
157 #define TestRegReg(Inst, Dst, Src, OpType, ByteCountUntyped, ...) \
158 do { \
159 static constexpr char TestString[] = \
160 "(" #Inst ", " #Dst ", " #Src ", " #OpType ", " #ByteCountUntyped \
161 ", " #__VA_ARGS__ ")"; \
162 static constexpr uint8_t ByteCount = ByteCountUntyped; \
163 __ Inst(IceType_##OpType, Encoded_GPR_##Dst(), Encoded_GPR_##Src()); \
164 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \
165 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \
166 << TestString; \
167 reset(); \
168 } while (0)
169
170 #define TestRegImm(Inst, Dst, Imm, OpType, ByteCountUntyped, ...) \
171 do { \
172 static constexpr char TestString[] = \
173 "(" #Inst ", " #Dst ", " #Imm ", " #OpType ", " #ByteCountUntyped \
174 ", " #__VA_ARGS__ ")"; \
175 static constexpr uint8_t ByteCount = ByteCountUntyped; \
176 __ Inst(IceType_##OpType, Encoded_GPR_##Dst(), Immediate(Imm)); \
177 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \
178 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \
179 << TestString; \
180 reset(); \
181 } while (0)
182
183 #define TestRegAbsoluteAddr(Inst, Dst, Disp, OpType, ByteCountUntyped, ...) \
184 do { \
185 static constexpr char TestString[] = \
186 "(" #Inst ", " #Dst ", " #Disp ", " #OpType ", " #ByteCountUntyped \
187 ", " #__VA_ARGS__ ")"; \
188 static constexpr uint8_t ByteCount = ByteCountUntyped; \
189 __ Inst(IceType_##OpType, Encoded_GPR_##Dst(), Address::Absolute(Disp)); \
190 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \
191 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \
192 << TestString; \
193 reset(); \
194 } while (0)
195
196 #define TestRegAddrBase(Inst, Dst, Base, Disp, OpType, ByteCountUntyped, ...) \
197 do { \
198 static constexpr char TestString[] = \
199 "(" #Inst ", " #Dst ", " #Base ", " #Disp ", " #OpType \
200 ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \
201 static constexpr uint8_t ByteCount = ByteCountUntyped; \
202 __ Inst(IceType_##OpType, Encoded_GPR_##Dst(), \
203 Address(Encoded_GPR_##Base(), Disp, AssemblerFixup::NoFixup)); \
204 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \
205 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \
206 << TestString; \
207 reset(); \
208 } while (0)
209
210 #define TestRegAddrScaledIndex(Inst, Dst, Index, Scale, Disp, OpType, \
211 ByteCountUntyped, ...) \
212 do { \
213 static constexpr char TestString[] = \
214 "(" #Inst ", " #Dst ", " #Index ", " #Scale ", " #Disp ", " #OpType \
215 ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \
216 static constexpr uint8_t ByteCount = ByteCountUntyped; \
217 __ Inst(IceType_##OpType, Encoded_GPR_##Dst(), \
218 Address(Encoded_GPR_##Index(), Traits::TIMES_##Scale, Disp, \
219 AssemblerFixup::NoFixup)); \
220 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \
221 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \
222 << TestString; \
223 reset(); \
224 } while (0)
225
226 #define TestRegAddrBaseScaledIndex(Inst, Dst, Base, Index, Scale, Disp, \
227 OpType, ByteCountUntyped, ...) \
228 do { \
229 static constexpr char TestString[] = \
230 "(" #Inst ", " #Dst ", " #Base ", " #Index ", " #Scale ", " #Disp \
231 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \
232 static constexpr uint8_t ByteCount = ByteCountUntyped; \
233 __ Inst(IceType_##OpType, Encoded_GPR_##Dst(), \
234 Address(Encoded_GPR_##Base(), Encoded_GPR_##Index(), \
235 Traits::TIMES_##Scale, Disp, AssemblerFixup::NoFixup)); \
236 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \
237 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \
238 << TestString; \
239 reset(); \
240 } while (0)
241
242 #define TestAddrBaseScaledIndexImm(Inst, Base, Index, Scale, Disp, Imm, \
243 OpType, ByteCountUntyped, ...) \
244 do { \
245 static constexpr char TestString[] = \
246 "(" #Inst ", " #Base ", " #Index ", " #Scale ", " #Disp ", " #Imm \
247 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \
248 static constexpr uint8_t ByteCount = ByteCountUntyped; \
249 __ Inst(IceType_##OpType, \
250 Address(Encoded_GPR_##Base(), Encoded_GPR_##Index(), \
251 Traits::TIMES_##Scale, Disp, AssemblerFixup::NoFixup), \
252 Immediate(Imm)); \
253 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \
254 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \
255 << TestString; \
256 reset(); \
257 } while (0)
258
259 #define TestAddrBaseScaledIndexReg(Inst, Base, Index, Scale, Disp, Src, \
260 OpType, ByteCountUntyped, ...) \
261 do { \
262 static constexpr char TestString[] = \
263 "(" #Inst ", " #Base ", " #Index ", " #Scale ", " #Disp ", " #Src \
264 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \
265 static constexpr uint8_t ByteCount = ByteCountUntyped; \
266 __ Inst(IceType_##OpType, \
267 Address(Encoded_GPR_##Base(), Encoded_GPR_##Index(), \
268 Traits::TIMES_##Scale, Disp, AssemblerFixup::NoFixup), \
269 Encoded_GPR_##Src()); \
270 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \
271 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \
272 << TestString; \
273 reset(); \
274 } while (0)
275
276 /* cmp GPR, GPR */
277 TestRegReg(cmp, eax, ecx, i32, 2, 0x3B, 0xC1);
278 TestRegReg(cmp, ecx, edx, i32, 2, 0x3B, 0xCA);
279 TestRegReg(cmp, edx, ebx, i32, 2, 0x3B, 0xD3);
280 TestRegReg(cmp, ebx, esp, i32, 2, 0x3B, 0xDC);
281 TestRegReg(cmp, esp, ebp, i32, 2, 0x3B, 0xE5);
282 TestRegReg(cmp, ebp, esi, i32, 2, 0x3B, 0xEE);
283 TestRegReg(cmp, esi, edi, i32, 2, 0x3B, 0xF7);
284 TestRegReg(cmp, edi, r8, i32, 3, 0x41, 0x3B, 0xF8);
285 TestRegReg(cmp, r8, r9, i32, 3, 0x45, 0x3B, 0xC1);
286 TestRegReg(cmp, r9, r10, i32, 3, 0x45, 0x3B, 0xCA);
287 TestRegReg(cmp, r10, r11, i32, 3, 0x45, 0x3B, 0xD3);
288 TestRegReg(cmp, r11, r12, i32, 3, 0x45, 0x3B, 0xDC);
289 TestRegReg(cmp, r12, r13, i32, 3, 0x45, 0x3B, 0xE5);
290 TestRegReg(cmp, r13, r14, i32, 3, 0x45, 0x3B, 0xEE);
291 TestRegReg(cmp, r14, r15, i32, 3, 0x45, 0x3B, 0xF7);
292 TestRegReg(cmp, r15, eax, i32, 3, 0x44, 0x3B, 0xF8);
293
294 TestRegReg(cmp, eax, ecx, i16, 3, 0x66, 0x3B, 0xC1);
295 TestRegReg(cmp, ecx, edx, i16, 3, 0x66, 0x3B, 0xCA);
296 TestRegReg(cmp, edx, ebx, i16, 3, 0x66, 0x3B, 0xD3);
297 TestRegReg(cmp, ebx, esp, i16, 3, 0x66, 0x3B, 0xDC);
298 TestRegReg(cmp, esp, ebp, i16, 3, 0x66, 0x3B, 0xE5);
299 TestRegReg(cmp, ebp, esi, i16, 3, 0x66, 0x3B, 0xEE);
300 TestRegReg(cmp, esi, edi, i16, 3, 0x66, 0x3B, 0xF7);
301 TestRegReg(cmp, edi, r8, i16, 4, 0x66, 0x41, 0x3B, 0xF8);
302 TestRegReg(cmp, r8, r9, i16, 4, 0x66, 0x45, 0x3B, 0xC1);
303 TestRegReg(cmp, r9, r10, i16, 4, 0x66, 0x45, 0x3B, 0xCA);
304 TestRegReg(cmp, r10, r11, i16, 4, 0x66, 0x45, 0x3B, 0xD3);
305 TestRegReg(cmp, r11, r12, i16, 4, 0x66, 0x45, 0x3B, 0xDC);
306 TestRegReg(cmp, r12, r13, i16, 4, 0x66, 0x45, 0x3B, 0xE5);
307 TestRegReg(cmp, r13, r14, i16, 4, 0x66, 0x45, 0x3B, 0xEE);
308 TestRegReg(cmp, r14, r15, i16, 4, 0x66, 0x45, 0x3B, 0xF7);
309 TestRegReg(cmp, r15, eax, i16, 4, 0x66, 0x44, 0x3B, 0xF8);
310
311 TestRegReg(cmp, eax, ecx, i8, 2, 0x3A, 0xC1);
312 TestRegReg(cmp, ecx, edx, i8, 2, 0x3A, 0xCA);
313 TestRegReg(cmp, edx, ebx, i8, 2, 0x3A, 0xD3);
314 TestRegReg(cmp, ebx, esp, i8, 2, 0x3A, 0xDC); // emit: cmp bl, ah
315 TestRegReg(cmp, esp, ebp, i8, 3, 0x40, 0x3A, 0xE5);
316 TestRegReg(cmp, ebp, esi, i8, 3, 0x40, 0x3A, 0xEE);
317 TestRegReg(cmp, esi, edi, i8, 3, 0x40, 0x3A, 0xF7);
318 TestRegReg(cmp, edi, r8, i8, 3, 0x41, 0x3A, 0xF8);
319 TestRegReg(cmp, r8, r9, i8, 3, 0x45, 0x3A, 0xC1);
320 TestRegReg(cmp, r9, r10, i8, 3, 0x45, 0x3A, 0xCA);
321 TestRegReg(cmp, r10, r11, i8, 3, 0x45, 0x3A, 0xD3);
322 TestRegReg(cmp, r11, r12, i8, 3, 0x45, 0x3A, 0xDC);
323 TestRegReg(cmp, r12, r13, i8, 3, 0x45, 0x3A, 0xE5);
324 TestRegReg(cmp, r13, r14, i8, 3, 0x45, 0x3A, 0xEE);
325 TestRegReg(cmp, r14, r15, i8, 3, 0x45, 0x3A, 0xF7);
326 TestRegReg(cmp, r15, eax, i8, 3, 0x44, 0x3A, 0xF8);
327
328 /* cmp GPR, Imm8 */
329 TestRegImm(cmp, eax, 5, i32, 3, 0x83, 0xF8, 0x05);
330 TestRegImm(cmp, ecx, 5, i32, 3, 0x83, 0xF9, 0x05);
331 TestRegImm(cmp, edx, 5, i32, 3, 0x83, 0xFA, 0x05);
332 TestRegImm(cmp, ebx, 5, i32, 3, 0x83, 0xFB, 0x05);
333 TestRegImm(cmp, esp, 5, i32, 3, 0x83, 0xFC, 0x05);
334 TestRegImm(cmp, ebp, 5, i32, 3, 0x83, 0xFD, 0x05);
335 TestRegImm(cmp, esi, 5, i32, 3, 0x83, 0xFE, 0x05);
336 TestRegImm(cmp, edi, 5, i32, 3, 0x83, 0xFF, 0x05);
337 TestRegImm(cmp, r8, 5, i32, 4, 0x41, 0x83, 0xF8, 0x05);
338 TestRegImm(cmp, r9, 5, i32, 4, 0x41, 0x83, 0xF9, 0x05);
339 TestRegImm(cmp, r10, 5, i32, 4, 0x41, 0x83, 0xFA, 0x05);
340 TestRegImm(cmp, r11, 5, i32, 4, 0x41, 0x83, 0xFB, 0x05);
341 TestRegImm(cmp, r12, 5, i32, 4, 0x41, 0x83, 0xFC, 0x05);
342 TestRegImm(cmp, r13, 5, i32, 4, 0x41, 0x83, 0xFD, 0x05);
343 TestRegImm(cmp, r14, 5, i32, 4, 0x41, 0x83, 0xFE, 0x05);
344 TestRegImm(cmp, r15, 5, i32, 4, 0x41, 0x83, 0xFF, 0x05);
345
346 TestRegImm(cmp, eax, 5, i16, 4, 0x66, 0x83, 0xF8, 0x05);
347 TestRegImm(cmp, ecx, 5, i16, 4, 0x66, 0x83, 0xF9, 0x05);
348 TestRegImm(cmp, edx, 5, i16, 4, 0x66, 0x83, 0xFA, 0x05);
349 TestRegImm(cmp, ebx, 5, i16, 4, 0x66, 0x83, 0xFB, 0x05);
350 TestRegImm(cmp, esp, 5, i16, 4, 0x66, 0x83, 0xFC, 0x05);
351 TestRegImm(cmp, ebp, 5, i16, 4, 0x66, 0x83, 0xFD, 0x05);
352 TestRegImm(cmp, esi, 5, i16, 4, 0x66, 0x83, 0xFE, 0x05);
353 TestRegImm(cmp, edi, 5, i16, 4, 0x66, 0x83, 0xFF, 0x05);
354 TestRegImm(cmp, r8, 5, i16, 5, 0x66, 0x41, 0x83, 0xF8, 0x05);
355 TestRegImm(cmp, r9, 5, i16, 5, 0x66, 0x41, 0x83, 0xF9, 0x05);
356 TestRegImm(cmp, r10, 5, i16, 5, 0x66, 0x41, 0x83, 0xFA, 0x05);
357 TestRegImm(cmp, r11, 5, i16, 5, 0x66, 0x41, 0x83, 0xFB, 0x05);
358 TestRegImm(cmp, r12, 5, i16, 5, 0x66, 0x41, 0x83, 0xFC, 0x05);
359 TestRegImm(cmp, r13, 5, i16, 5, 0x66, 0x41, 0x83, 0xFD, 0x05);
360 TestRegImm(cmp, r14, 5, i16, 5, 0x66, 0x41, 0x83, 0xFE, 0x05);
361 TestRegImm(cmp, r15, 5, i16, 5, 0x66, 0x41, 0x83, 0xFF, 0x05);
362
363 TestRegImm(cmp, eax, 5, i8, 2, 0x3C, 0x05);
364 TestRegImm(cmp, ecx, 5, i8, 3, 0x80, 0xF9, 0x05);
365 TestRegImm(cmp, edx, 5, i8, 3, 0x80, 0xFA, 0x05);
366 TestRegImm(cmp, ebx, 5, i8, 3, 0x80, 0xFB, 0x05);
367 TestRegImm(cmp, esp, 5, i8, 3, 0x80, 0xFC, 0x05); // emit: cmp ah, 5
368 TestRegImm(cmp, ebp, 5, i8, 4, 0x40, 0x80, 0xFD, 0x05);
369 TestRegImm(cmp, esi, 5, i8, 4, 0x40, 0x80, 0xFE, 0x05);
370 TestRegImm(cmp, edi, 5, i8, 4, 0x40, 0x80, 0xFF, 0x05);
371 TestRegImm(cmp, r8, 5, i8, 4, 0x41, 0x80, 0xF8, 0x05);
372 TestRegImm(cmp, r9, 5, i8, 4, 0x41, 0x80, 0xF9, 0x05);
373 TestRegImm(cmp, r10, 5, i8, 4, 0x41, 0x80, 0xFA, 0x05);
374 TestRegImm(cmp, r11, 5, i8, 4, 0x41, 0x80, 0xFB, 0x05);
375 TestRegImm(cmp, r12, 5, i8, 4, 0x41, 0x80, 0xFC, 0x05);
376 TestRegImm(cmp, r13, 5, i8, 4, 0x41, 0x80, 0xFD, 0x05);
377 TestRegImm(cmp, r14, 5, i8, 4, 0x41, 0x80, 0xFE, 0x05);
378 TestRegImm(cmp, r15, 5, i8, 4, 0x41, 0x80, 0xFF, 0x05);
379
380 /* cmp GPR, Imm16 */
381 TestRegImm(cmp, eax, 0x100, i32, 5, 0x3D, 0x00, 0x01, 0x00, 0x00);
382 TestRegImm(cmp, ecx, 0x100, i32, 6, 0x81, 0xF9, 0x00, 0x01, 0x00, 0x00);
383 TestRegImm(cmp, edx, 0x100, i32, 6, 0x81, 0xFA, 0x00, 0x01, 0x00, 0x00);
384 TestRegImm(cmp, ebx, 0x100, i32, 6, 0x81, 0xFB, 0x00, 0x01, 0x00, 0x00);
385 TestRegImm(cmp, esp, 0x100, i32, 6, 0x81, 0xFC, 0x00, 0x01, 0x00, 0x00);
386 TestRegImm(cmp, ebp, 0x100, i32, 6, 0x81, 0xFD, 0x00, 0x01, 0x00, 0x00);
387 TestRegImm(cmp, esi, 0x100, i32, 6, 0x81, 0xFE, 0x00, 0x01, 0x00, 0x00);
388 TestRegImm(cmp, edi, 0x100, i32, 6, 0x81, 0xFF, 0x00, 0x01, 0x00, 0x00);
389 TestRegImm(cmp, r8, 0x100, i32, 7, 0x41, 0x81, 0xF8, 0x00, 0x01, 0x00, 0x00);
390 TestRegImm(cmp, r9, 0x100, i32, 7, 0x41, 0x81, 0xF9, 0x00, 0x01, 0x00, 0x00);
391 TestRegImm(cmp, r10, 0x100, i32, 7, 0x41, 0x81, 0xFA, 0x00, 0x01, 0x00, 0x00);
392 TestRegImm(cmp, r11, 0x100, i32, 7, 0x41, 0x81, 0xFB, 0x00, 0x01, 0x00, 0x00);
393 TestRegImm(cmp, r12, 0x100, i32, 7, 0x41, 0x81, 0xFC, 0x00, 0x01, 0x00, 0x00);
394 TestRegImm(cmp, r13, 0x100, i32, 7, 0x41, 0x81, 0xFD, 0x00, 0x01, 0x00, 0x00);
395 TestRegImm(cmp, r14, 0x100, i32, 7, 0x41, 0x81, 0xFE, 0x00, 0x01, 0x00, 0x00);
396 TestRegImm(cmp, r15, 0x100, i32, 7, 0x41, 0x81, 0xFF, 0x00, 0x01, 0x00, 0x00);
397
398 TestRegImm(cmp, eax, 0x100, i16, 4, 0x66, 0x3D, 0x00, 0x01);
399 TestRegImm(cmp, ecx, 0x100, i16, 5, 0x66, 0x81, 0xF9, 0x00, 0x01);
400 TestRegImm(cmp, edx, 0x100, i16, 5, 0x66, 0x81, 0xFA, 0x00, 0x01);
401 TestRegImm(cmp, ebx, 0x100, i16, 5, 0x66, 0x81, 0xFB, 0x00, 0x01);
402 TestRegImm(cmp, esp, 0x100, i16, 5, 0x66, 0x81, 0xFC, 0x00, 0x01);
403 TestRegImm(cmp, ebp, 0x100, i16, 5, 0x66, 0x81, 0xFD, 0x00, 0x01);
404 TestRegImm(cmp, esi, 0x100, i16, 5, 0x66, 0x81, 0xFE, 0x00, 0x01);
405 TestRegImm(cmp, edi, 0x100, i16, 5, 0x66, 0x81, 0xFF, 0x00, 0x01);
406 TestRegImm(cmp, r8, 0x100, i16, 6, 0x66, 0x41, 0x81, 0xF8, 0x00, 0x01);
407 TestRegImm(cmp, r9, 0x100, i16, 6, 0x66, 0x41, 0x81, 0xF9, 0x00, 0x01);
408 TestRegImm(cmp, r10, 0x100, i16, 6, 0x66, 0x41, 0x81, 0xFA, 0x00, 0x01);
409 TestRegImm(cmp, r11, 0x100, i16, 6, 0x66, 0x41, 0x81, 0xFB, 0x00, 0x01);
410 TestRegImm(cmp, r12, 0x100, i16, 6, 0x66, 0x41, 0x81, 0xFC, 0x00, 0x01);
411 TestRegImm(cmp, r13, 0x100, i16, 6, 0x66, 0x41, 0x81, 0xFD, 0x00, 0x01);
412 TestRegImm(cmp, r14, 0x100, i16, 6, 0x66, 0x41, 0x81, 0xFE, 0x00, 0x01);
413 TestRegImm(cmp, r15, 0x100, i16, 6, 0x66, 0x41, 0x81, 0xFF, 0x00, 0x01);
414
415 /* cmp GPR, Absolute */
416 TestRegAbsoluteAddr(cmp, eax, 0xF00FBEEF, i32, 8, 0x67, 0x3B, 0x04, 0x25,
417 0xEF, 0xBE, 0x0F, 0xF0);
418 TestRegAbsoluteAddr(cmp, eax, 0xF00FBEEF, i16, 9, 0x66, 0x67, 0x3B, 0x04,
419 0x25, 0xEF, 0xBE, 0x0F, 0xF0);
420 TestRegAbsoluteAddr(cmp, eax, 0xF00FBEEF, i8, 8, 0x67, 0x3A, 0x04, 0x25, 0xEF,
421 0xBE, 0x0F, 0xF0);
422 TestRegAbsoluteAddr(cmp, r8, 0xF00FBEEF, i32, 9, 0x67, 0x44, 0x3B, 0x04, 0x25,
423 0xEF, 0xBE, 0x0F, 0xF0);
424 TestRegAbsoluteAddr(cmp, r8, 0xF00FBEEF, i16, 10, 0x66, 0x67, 0x44, 0x3B,
425 0x04, 0x25, 0xEF, 0xBE, 0x0F, 0xF0);
426 TestRegAbsoluteAddr(cmp, r8, 0xF00FBEEF, i8, 9, 0x67, 0x44, 0x3A, 0x04, 0x25,
427 0xEF, 0xBE, 0x0F, 0xF0);
428
429 /* cmp GPR, 0(Base) */
430 TestRegAddrBase(cmp, eax, ecx, 0, i32, 3, 0x67, 0x3B, 0x01);
431 TestRegAddrBase(cmp, ecx, edx, 0, i32, 3, 0x67, 0x3B, 0x0A);
432 TestRegAddrBase(cmp, edx, ebx, 0, i32, 3, 0x67, 0x3B, 0x13);
433 TestRegAddrBase(cmp, ebx, esp, 0, i32, 4, 0x67, 0x3B, 0x1C, 0x24);
434 TestRegAddrBase(cmp, esp, ebp, 0, i32, 4, 0x67, 0x3B, 0x65, 0x00);
435 TestRegAddrBase(cmp, ebp, esi, 0, i32, 3, 0x67, 0x3B, 0x2E);
436 TestRegAddrBase(cmp, esi, edi, 0, i32, 3, 0x67, 0x3B, 0x37);
437 TestRegAddrBase(cmp, edi, r8, 0, i32, 4, 0x67, 0x41, 0x3B, 0x38);
438 TestRegAddrBase(cmp, r8, r9, 0, i32, 4, 0x67, 0x45, 0x3B, 0x01);
439 TestRegAddrBase(cmp, r9, r10, 0, i32, 4, 0x67, 0x45, 0x3B, 0x0A);
440 TestRegAddrBase(cmp, r10, r11, 0, i32, 4, 0x67, 0x45, 0x3B, 0x13);
441 TestRegAddrBase(cmp, r11, r12, 0, i32, 5, 0x67, 0x45, 0x3B, 0x1C, 0x24);
442 TestRegAddrBase(cmp, r12, r13, 0, i32, 5, 0x67, 0x45, 0x3B, 0x65, 0x00);
443 TestRegAddrBase(cmp, r13, r14, 0, i32, 4, 0x67, 0x45, 0x3B, 0x2E);
444 TestRegAddrBase(cmp, r14, r15, 0, i32, 4, 0x67, 0x45, 0x3B, 0x37);
445 TestRegAddrBase(cmp, r15, eax, 0, i32, 4, 0x67, 0x44, 0x3B, 0x38);
446
447 TestRegAddrBase(cmp, eax, ecx, 0, i16, 4, 0x66, 0x67, 0x3B, 0x01);
448 TestRegAddrBase(cmp, ecx, edx, 0, i16, 4, 0x66, 0x67, 0x3B, 0x0A);
449 TestRegAddrBase(cmp, edx, ebx, 0, i16, 4, 0x66, 0x67, 0x3B, 0x13);
450 TestRegAddrBase(cmp, ebx, esp, 0, i16, 5, 0x66, 0x67, 0x3B, 0x1C, 0x24);
451 TestRegAddrBase(cmp, esp, ebp, 0, i16, 5, 0x66, 0x67, 0x3B, 0x65, 0x00);
452 TestRegAddrBase(cmp, ebp, esi, 0, i16, 4, 0x66, 0x67, 0x3B, 0x2E);
453 TestRegAddrBase(cmp, esi, edi, 0, i16, 4, 0x66, 0x67, 0x3B, 0x37);
454 TestRegAddrBase(cmp, edi, r8, 0, i16, 5, 0x66, 0x67, 0x41, 0x3B, 0x38);
455 TestRegAddrBase(cmp, r8, r9, 0, i16, 5, 0x66, 0x67, 0x45, 0x3B, 0x01);
456 TestRegAddrBase(cmp, r9, r10, 0, i16, 5, 0x66, 0x67, 0x45, 0x3B, 0x0A);
457 TestRegAddrBase(cmp, r10, r11, 0, i16, 5, 0x66, 0x67, 0x45, 0x3B, 0x13);
458 TestRegAddrBase(cmp, r11, r12, 0, i16, 6, 0x66, 0x67, 0x45, 0x3B, 0x1C, 0x24);
459 TestRegAddrBase(cmp, r12, r13, 0, i16, 6, 0x66, 0x67, 0x45, 0x3B, 0x65, 0x00);
460 TestRegAddrBase(cmp, r13, r14, 0, i16, 5, 0x66, 0x67, 0x45, 0x3B, 0x2E);
461 TestRegAddrBase(cmp, r14, r15, 0, i16, 5, 0x66, 0x67, 0x45, 0x3B, 0x37);
462 TestRegAddrBase(cmp, r15, eax, 0, i16, 5, 0x66, 0x67, 0x44, 0x3B, 0x38);
463
464 TestRegAddrBase(cmp, eax, ecx, 0, i8, 3, 0x67, 0x3A, 0x01);
465 TestRegAddrBase(cmp, ecx, edx, 0, i8, 3, 0x67, 0x3A, 0x0A);
466 TestRegAddrBase(cmp, edx, ebx, 0, i8, 3, 0x67, 0x3A, 0x13);
467 TestRegAddrBase(cmp, ebx, esp, 0, i8, 4, 0x67, 0x3A, 0x1C, 0x24);
468 TestRegAddrBase(cmp, esp, ebp, 0, i8, 4, 0x67, 0x3A, 0x65, 0x00);
469 TestRegAddrBase(cmp, ebp, esi, 0, i8, 4, 0x67, 0x40, 0x3A, 0x2E);
470 TestRegAddrBase(cmp, esi, edi, 0, i8, 4, 0x67, 0x40, 0x3A, 0x37);
471 TestRegAddrBase(cmp, edi, r8, 0, i8, 4, 0x67, 0x41, 0x3A, 0x38);
472 TestRegAddrBase(cmp, r8, r9, 0, i8, 4, 0x67, 0x45, 0x3A, 0x01);
473 TestRegAddrBase(cmp, r9, r10, 0, i8, 4, 0x67, 0x45, 0x3A, 0x0A);
474 TestRegAddrBase(cmp, r10, r11, 0, i8, 4, 0x67, 0x45, 0x3A, 0x13);
475 TestRegAddrBase(cmp, r11, r12, 0, i8, 5, 0x67, 0x45, 0x3A, 0x1C, 0x24);
476 TestRegAddrBase(cmp, r12, r13, 0, i8, 5, 0x67, 0x45, 0x3A, 0x65, 0x00);
477 TestRegAddrBase(cmp, r13, r14, 0, i8, 4, 0x67, 0x45, 0x3A, 0x2E);
478 TestRegAddrBase(cmp, r14, r15, 0, i8, 4, 0x67, 0x45, 0x3A, 0x37);
479 TestRegAddrBase(cmp, r15, eax, 0, i8, 4, 0x67, 0x44, 0x3A, 0x38);
480
481 /* cmp GPR, Imm8(Base) */
482 TestRegAddrBase(cmp, eax, ecx, 0x40, i32, 4, 0x67, 0x3B, 0x41, 0x40);
483 TestRegAddrBase(cmp, ecx, edx, 0x40, i32, 4, 0x67, 0x3B, 0x4A, 0x40);
484 TestRegAddrBase(cmp, edx, ebx, 0x40, i32, 4, 0x67, 0x3B, 0x53, 0x40);
485 TestRegAddrBase(cmp, ebx, esp, 0x40, i32, 5, 0x67, 0x3B, 0x5C, 0x24, 0x40);
486 TestRegAddrBase(cmp, esp, ebp, 0x40, i32, 4, 0x67, 0x3B, 0x65, 0x40);
487 TestRegAddrBase(cmp, ebp, esi, 0x40, i32, 4, 0x67, 0x3B, 0x6E, 0x40);
488 TestRegAddrBase(cmp, esi, edi, 0x40, i32, 4, 0x67, 0x3B, 0x77, 0x40);
489 TestRegAddrBase(cmp, edi, r8, 0x40, i32, 5, 0x67, 0x41, 0x3B, 0x78, 0x40);
490 TestRegAddrBase(cmp, r8, r9, 0x40, i32, 5, 0x67, 0x45, 0x3B, 0x41, 0x40);
491 TestRegAddrBase(cmp, r9, r10, 0x40, i32, 5, 0x67, 0x45, 0x3B, 0x4A, 0x40);
492 TestRegAddrBase(cmp, r10, r11, 0x40, i32, 5, 0x67, 0x45, 0x3B, 0x53, 0x40);
493 TestRegAddrBase(cmp, r11, r12, 0x40, i32, 6, 0x67, 0x45, 0x3B, 0x5C, 0x24,
494 0x40);
495 TestRegAddrBase(cmp, r12, r13, 0x40, i32, 5, 0x67, 0x45, 0x3B, 0x65, 0x40);
496 TestRegAddrBase(cmp, r13, r14, 0x40, i32, 5, 0x67, 0x45, 0x3B, 0x6E, 0x40);
497 TestRegAddrBase(cmp, r14, r15, 0x40, i32, 5, 0x67, 0x45, 0x3B, 0x77, 0x40);
498 TestRegAddrBase(cmp, r15, eax, 0x40, i32, 5, 0x67, 0x44, 0x3B, 0x78, 0x40);
499
500 TestRegAddrBase(cmp, eax, ecx, 0x40, i16, 5, 0x66, 0x67, 0x3B, 0x41, 0x40);
501 TestRegAddrBase(cmp, ecx, edx, 0x40, i16, 5, 0x66, 0x67, 0x3B, 0x4A, 0x40);
502 TestRegAddrBase(cmp, edx, ebx, 0x40, i16, 5, 0x66, 0x67, 0x3B, 0x53, 0x40);
503 TestRegAddrBase(cmp, ebx, esp, 0x40, i16, 6, 0x66, 0x67, 0x3B, 0x5C, 0x24,
504 0x40);
505 TestRegAddrBase(cmp, esp, ebp, 0x40, i16, 5, 0x66, 0x67, 0x3B, 0x65, 0x40);
506 TestRegAddrBase(cmp, ebp, esi, 0x40, i16, 5, 0x66, 0x67, 0x3B, 0x6E, 0x40);
507 TestRegAddrBase(cmp, esi, edi, 0x40, i16, 5, 0x66, 0x67, 0x3B, 0x77, 0x40);
508 TestRegAddrBase(cmp, edi, r8, 0x40, i16, 6, 0x66, 0x67, 0x41, 0x3B, 0x78,
509 0x40);
510 TestRegAddrBase(cmp, r8, r9, 0x40, i16, 6, 0x66, 0x67, 0x45, 0x3B, 0x41,
511 0x40);
512 TestRegAddrBase(cmp, r9, r10, 0x40, i16, 6, 0x66, 0x67, 0x45, 0x3B, 0x4A,
513 0x40);
514 TestRegAddrBase(cmp, r10, r11, 0x40, i16, 6, 0x66, 0x67, 0x45, 0x3B, 0x53,
515 0x40);
516 TestRegAddrBase(cmp, r11, r12, 0x40, i16, 7, 0x66, 0x67, 0x45, 0x3B, 0x5C,
517 0x24, 0x40);
518 TestRegAddrBase(cmp, r12, r13, 0x40, i16, 6, 0x66, 0x67, 0x45, 0x3B, 0x65,
519 0x40);
520 TestRegAddrBase(cmp, r13, r14, 0x40, i16, 6, 0x66, 0x67, 0x45, 0x3B, 0x6E,
521 0x40);
522 TestRegAddrBase(cmp, r14, r15, 0x40, i16, 6, 0x66, 0x67, 0x45, 0x3B, 0x77,
523 0x40);
524 TestRegAddrBase(cmp, r15, eax, 0x40, i16, 6, 0x66, 0x67, 0x44, 0x3B, 0x78,
525 0x40);
526
527 TestRegAddrBase(cmp, eax, ecx, 0x40, i8, 4, 0x67, 0x3A, 0x41, 0x40);
528 TestRegAddrBase(cmp, ecx, edx, 0x40, i8, 4, 0x67, 0x3A, 0x4A, 0x40);
529 TestRegAddrBase(cmp, edx, ebx, 0x40, i8, 4, 0x67, 0x3A, 0x53, 0x40);
530 TestRegAddrBase(cmp, ebx, esp, 0x40, i8, 5, 0x67, 0x3A, 0x5C, 0x24, 0x40);
531 TestRegAddrBase(cmp, esp, ebp, 0x40, i8, 4, 0x67, 0x3A, 0x65, 0x40);
532 TestRegAddrBase(cmp, ebp, esi, 0x40, i8, 5, 0x67, 0x40, 0x3A, 0x6E, 0x40);
533 TestRegAddrBase(cmp, esi, edi, 0x40, i8, 5, 0x67, 0x40, 0x3A, 0x77, 0x40);
534 TestRegAddrBase(cmp, edi, r8, 0x40, i8, 5, 0x67, 0x41, 0x3A, 0x78, 0x40);
535 TestRegAddrBase(cmp, r8, r9, 0x40, i8, 5, 0x67, 0x45, 0x3A, 0x41, 0x40);
536 TestRegAddrBase(cmp, r9, r10, 0x40, i8, 5, 0x67, 0x45, 0x3A, 0x4A, 0x40);
537 TestRegAddrBase(cmp, r10, r11, 0x40, i8, 5, 0x67, 0x45, 0x3A, 0x53, 0x40);
538 TestRegAddrBase(cmp, r11, r12, 0x40, i8, 6, 0x67, 0x45, 0x3A, 0x5C, 0x24,
539 0x40);
540 TestRegAddrBase(cmp, r12, r13, 0x40, i8, 5, 0x67, 0x45, 0x3A, 0x65, 0x40);
541 TestRegAddrBase(cmp, r13, r14, 0x40, i8, 5, 0x67, 0x45, 0x3A, 0x6E, 0x40);
542 TestRegAddrBase(cmp, r14, r15, 0x40, i8, 5, 0x67, 0x45, 0x3A, 0x77, 0x40);
543 TestRegAddrBase(cmp, r15, eax, 0x40, i8, 5, 0x67, 0x44, 0x3A, 0x78, 0x40);
544
545 /* cmp GPR, Imm32(Base) */
546 TestRegAddrBase(cmp, eax, ecx, 0xF0, i32, 7, 0x67, 0x3B, 0x81, 0xF0, 0x00,
547 0x00, 0x00);
548 TestRegAddrBase(cmp, ecx, edx, 0xF0, i32, 7, 0x67, 0x3B, 0x8A, 0xF0, 0x00,
549 0x00, 0x00);
550 TestRegAddrBase(cmp, edx, ebx, 0xF0, i32, 7, 0x67, 0x3B, 0x93, 0xF0, 0x00,
551 0x00, 0x00);
552 TestRegAddrBase(cmp, ebx, esp, 0xF0, i32, 8, 0x67, 0x3B, 0x9C, 0x24, 0xF0,
553 0x00, 0x00, 0x00);
554 TestRegAddrBase(cmp, esp, ebp, 0xF0, i32, 7, 0x67, 0x3B, 0xA5, 0xF0, 0x00,
555 0x00, 0x00);
556 TestRegAddrBase(cmp, ebp, esi, 0xF0, i32, 7, 0x67, 0x3B, 0xAE, 0xF0, 0x00,
557 0x00, 0x00);
558 TestRegAddrBase(cmp, esi, edi, 0xF0, i32, 7, 0x67, 0x3B, 0xB7, 0xF0, 0x00,
559 0x00, 0x00);
560 TestRegAddrBase(cmp, edi, r8, 0xF0, i32, 8, 0x67, 0x41, 0x3B, 0xB8, 0xF0,
561 0x00, 0x00, 0x00);
562 TestRegAddrBase(cmp, r8, r9, 0xF0, i32, 8, 0x67, 0x45, 0x3B, 0x81, 0xF0, 0x00,
563 0x00, 0x00);
564 TestRegAddrBase(cmp, r9, r10, 0xF0, i32, 8, 0x67, 0x45, 0x3B, 0x8A, 0xF0,
565 0x00, 0x00, 0x00);
566 TestRegAddrBase(cmp, r10, r11, 0xF0, i32, 8, 0x67, 0x45, 0x3B, 0x93, 0xF0,
567 0x00, 0x00, 0x00);
568 TestRegAddrBase(cmp, r11, r12, 0xF0, i32, 9, 0x67, 0x45, 0x3B, 0x9C, 0x24,
569 0xF0, 0x00, 0x00, 0x00);
570 TestRegAddrBase(cmp, r12, r13, 0xF0, i32, 8, 0x67, 0x45, 0x3B, 0xA5, 0xF0,
571 0x00, 0x00, 0x00);
572 TestRegAddrBase(cmp, r13, r14, 0xF0, i32, 8, 0x67, 0x45, 0x3B, 0xAE, 0xF0,
573 0x00, 0x00, 0x00);
574 TestRegAddrBase(cmp, r14, r15, 0xF0, i32, 8, 0x67, 0x45, 0x3B, 0xB7, 0xF0,
575 0x00, 0x00, 0x00);
576 TestRegAddrBase(cmp, r15, eax, 0xF0, i32, 8, 0x67, 0x44, 0x3B, 0xB8, 0xF0,
577 0x00, 0x00, 0x00);
578
579 TestRegAddrBase(cmp, eax, ecx, 0xF0, i16, 8, 0x66, 0x67, 0x3B, 0x81, 0xF0,
580 0x00, 0x00, 0x00);
581 TestRegAddrBase(cmp, ecx, edx, 0xF0, i16, 8, 0x66, 0x67, 0x3B, 0x8A, 0xF0,
582 0x00, 0x00, 0x00);
583 TestRegAddrBase(cmp, edx, ebx, 0xF0, i16, 8, 0x66, 0x67, 0x3B, 0x93, 0xF0,
584 0x00, 0x00, 0x00);
585 TestRegAddrBase(cmp, ebx, esp, 0xF0, i16, 9, 0x66, 0x67, 0x3B, 0x9C, 0x24,
586 0xF0, 0x00, 0x00, 0x00);
587 TestRegAddrBase(cmp, esp, ebp, 0xF0, i16, 8, 0x66, 0x67, 0x3B, 0xa5, 0xF0,
588 0x00, 0x00, 0x00);
589 TestRegAddrBase(cmp, ebp, esi, 0xF0, i16, 8, 0x66, 0x67, 0x3B, 0xaE, 0xF0,
590 0x00, 0x00, 0x00);
591 TestRegAddrBase(cmp, esi, edi, 0xF0, i16, 8, 0x66, 0x67, 0x3B, 0xb7, 0xF0,
592 0x00, 0x00, 0x00);
593 TestRegAddrBase(cmp, edi, r8, 0xF0, i16, 9, 0x66, 0x67, 0x41, 0x3B, 0xb8,
594 0xF0, 0x00, 0x00, 0x00);
595 TestRegAddrBase(cmp, r8, r9, 0xF0, i16, 9, 0x66, 0x67, 0x45, 0x3B, 0x81, 0xF0,
596 0x00, 0x00, 0x00);
597 TestRegAddrBase(cmp, r9, r10, 0xF0, i16, 9, 0x66, 0x67, 0x45, 0x3B, 0x8A,
598 0xF0, 0x00, 0x00, 0x00);
599 TestRegAddrBase(cmp, r10, r11, 0xF0, i16, 9, 0x66, 0x67, 0x45, 0x3B, 0x93,
600 0xF0, 0x00, 0x00, 0x00);
601 TestRegAddrBase(cmp, r11, r12, 0xF0, i16, 10, 0x66, 0x67, 0x45, 0x3B, 0x9C,
602 0x24, 0xF0, 0x00, 0x00, 0x00);
603 TestRegAddrBase(cmp, r12, r13, 0xF0, i16, 9, 0x66, 0x67, 0x45, 0x3B, 0xa5,
604 0xF0, 0x00, 0x00, 0x00);
605 TestRegAddrBase(cmp, r13, r14, 0xF0, i16, 9, 0x66, 0x67, 0x45, 0x3B, 0xaE,
606 0xF0, 0x00, 0x00, 0x00);
607 TestRegAddrBase(cmp, r14, r15, 0xF0, i16, 9, 0x66, 0x67, 0x45, 0x3B, 0xb7,
608 0xF0, 0x00, 0x00, 0x00);
609 TestRegAddrBase(cmp, r15, eax, 0xF0, i16, 9, 0x66, 0x67, 0x44, 0x3B, 0xb8,
610 0xF0, 0x00, 0x00, 0x00);
611
612 TestRegAddrBase(cmp, eax, ecx, 0xF0, i8, 7, 0x67, 0x3A, 0x81, 0xF0, 0x00,
613 0x00, 0x00);
614 TestRegAddrBase(cmp, ecx, edx, 0xF0, i8, 7, 0x67, 0x3A, 0x8A, 0xF0, 0x00,
615 0x00, 0x00);
616 TestRegAddrBase(cmp, edx, ebx, 0xF0, i8, 7, 0x67, 0x3A, 0x93, 0xF0, 0x00,
617 0x00, 0x00);
618 TestRegAddrBase(cmp, ebx, esp, 0xF0, i8, 8, 0x67, 0x3A, 0x9C, 0x24, 0xF0,
619 0x00, 0x00, 0x00);
620 TestRegAddrBase(cmp, esp, ebp, 0xF0, i8, 7, 0x67, 0x3A, 0xA5, 0xF0, 0x00,
621 0x00, 0x00);
622 TestRegAddrBase(cmp, ebp, esi, 0xF0, i8, 8, 0x67, 0x40, 0x3A, 0xAE, 0xF0,
623 0x00, 0x00, 0x00);
624 TestRegAddrBase(cmp, esi, edi, 0xF0, i8, 8, 0x67, 0x40, 0x3A, 0xB7, 0xF0,
625 0x00, 0x00, 0x00);
626 TestRegAddrBase(cmp, edi, r8, 0xF0, i8, 8, 0x67, 0x41, 0x3A, 0xB8, 0xF0, 0x00,
627 0x00, 0x00);
628 TestRegAddrBase(cmp, r8, r9, 0xF0, i8, 8, 0x67, 0x45, 0x3A, 0x81, 0xF0, 0x00,
629 0x00, 0x00);
630 TestRegAddrBase(cmp, r9, r10, 0xF0, i8, 8, 0x67, 0x45, 0x3A, 0x8A, 0xF0, 0x00,
631 0x00, 0x00);
632 TestRegAddrBase(cmp, r10, r11, 0xF0, i8, 8, 0x67, 0x45, 0x3A, 0x93, 0xF0,
633 0x00, 0x00, 0x00);
634 TestRegAddrBase(cmp, r11, r12, 0xF0, i8, 9, 0x67, 0x45, 0x3A, 0x9C, 0x24,
635 0xF0, 0x00, 0x00, 0x00);
636 TestRegAddrBase(cmp, r12, r13, 0xF0, i8, 8, 0x67, 0x45, 0x3A, 0xA5, 0xF0,
637 0x00, 0x00, 0x00);
638 TestRegAddrBase(cmp, r13, r14, 0xF0, i8, 8, 0x67, 0x45, 0x3A, 0xAE, 0xF0,
639 0x00, 0x00, 0x00);
640 TestRegAddrBase(cmp, r14, r15, 0xF0, i8, 8, 0x67, 0x45, 0x3A, 0xB7, 0xF0,
641 0x00, 0x00, 0x00);
642 TestRegAddrBase(cmp, r15, eax, 0xF0, i8, 8, 0x67, 0x44, 0x3A, 0xB8, 0xF0,
643 0x00, 0x00, 0x00);
644
645 /* cmp GPR, Imm(,Index,Scale) */
646 TestRegAddrScaledIndex(cmp, eax, ecx, 1, 0, i32, 8, 0x67, 0x3B, 0x04, 0x0D,
647 0x00, 0x00, 0x00, 0x00);
648 TestRegAddrScaledIndex(cmp, ecx, edx, 2, 0, i32, 8, 0x67, 0x3B, 0x0C, 0x55,
649 0x00, 0x00, 0x00, 0x00);
650 TestRegAddrScaledIndex(cmp, edx, ebx, 4, 0, i32, 8, 0x67, 0x3B, 0x14, 0x9D,
651 0x00, 0x00, 0x00, 0x00);
652 TestRegAddrScaledIndex(cmp, r8, r9, 1, 0, i32, 9, 0x67, 0x46, 0x3B, 0x04,
653 0x0D, 0x00, 0x00, 0x00, 0x00);
654 TestRegAddrScaledIndex(cmp, r9, r10, 2, 0, i32, 9, 0x67, 0x46, 0x3B, 0x0C,
655 0x55, 0x00, 0x00, 0x00, 0x00);
656 TestRegAddrScaledIndex(cmp, r10, r11, 4, 0, i32, 9, 0x67, 0x46, 0x3B, 0x14,
657 0x9D, 0x00, 0x00, 0x00, 0x00);
658 // esp cannot be an scaled index.
659 TestRegAddrScaledIndex(cmp, esp, ebp, 8, 0, i32, 8, 0x67, 0x3B, 0x24, 0xED,
660 0x00, 0x00, 0x00, 0x00);
661 TestRegAddrScaledIndex(cmp, ebp, esi, 1, 0, i32, 8, 0x67, 0x3B, 0x2C, 0x35,
662 0x00, 0x00, 0x00, 0x00);
663 TestRegAddrScaledIndex(cmp, esi, edi, 2, 0, i32, 8, 0x67, 0x3B, 0x34, 0x7D,
664 0x00, 0x00, 0x00, 0x00);
665 TestRegAddrScaledIndex(cmp, edi, eax, 4, 0, i32, 8, 0x67, 0x3B, 0x3C, 0x85,
666 0x00, 0x00, 0x00, 0x00);
667 TestRegAddrScaledIndex(cmp, ebx, ecx, 8, 0, i32, 8, 0x67, 0x3B, 0x1C, 0xCD,
668 0x00, 0x00, 0x00, 0x00);
669 TestRegAddrScaledIndex(cmp, r12, r13, 8, 0, i32, 9, 0x67, 0x46, 0x3B, 0x24,
670 0xED, 0x00, 0x00, 0x00, 0x00);
671 TestRegAddrScaledIndex(cmp, r13, r14, 1, 0, i32, 9, 0x67, 0x46, 0x3B, 0x2C,
672 0x35, 0x00, 0x00, 0x00, 0x00);
673 TestRegAddrScaledIndex(cmp, r14, r15, 2, 0, i32, 9, 0x67, 0x46, 0x3B, 0x34,
674 0x7D, 0x00, 0x00, 0x00, 0x00);
675 TestRegAddrScaledIndex(cmp, r15, r8, 4, 0, i32, 9, 0x67, 0x46, 0x3B, 0x3C,
676 0x85, 0x00, 0x00, 0x00, 0x00);
677 TestRegAddrScaledIndex(cmp, r11, r9, 8, 0, i32, 9, 0x67, 0x46, 0x3B, 0x1C,
678 0xCD, 0x00, 0x00, 0x00, 0x00);
679
680 TestRegAddrScaledIndex(cmp, eax, ecx, 8, 0, i16, 9, 0x66, 0x67, 0x3B, 0x04,
681 0xCD, 0x00, 0x00, 0x00, 0x00);
682 TestRegAddrScaledIndex(cmp, ecx, edx, 1, 0, i16, 9, 0x66, 0x67, 0x3B, 0x0C,
683 0x15, 0x00, 0x00, 0x00, 0x00);
684 TestRegAddrScaledIndex(cmp, edx, ebx, 2, 0, i16, 9, 0x66, 0x67, 0x3B, 0x14,
685 0x5D, 0x00, 0x00, 0x00, 0x00);
686 TestRegAddrScaledIndex(cmp, r8, r9, 8, 0, i16, 10, 0x66, 0x67, 0x46, 0x3B,
687 0x04, 0xCD, 0x00, 0x00, 0x00, 0x00);
688 TestRegAddrScaledIndex(cmp, r9, r10, 1, 0, i16, 10, 0x66, 0x67, 0x46, 0x3B,
689 0x0C, 0x15, 0x00, 0x00, 0x00, 0x00);
690 TestRegAddrScaledIndex(cmp, r10, r11, 2, 0, i16, 10, 0x66, 0x67, 0x46, 0x3B,
691 0x14, 0x5D, 0x00, 0x00, 0x00, 0x00);
692 // esp cannot be an scaled index.
693 TestRegAddrScaledIndex(cmp, esp, ebp, 4, 0, i16, 9, 0x66, 0x67, 0x3B, 0x24,
694 0xAD, 0x00, 0x00, 0x00, 0x00);
695 TestRegAddrScaledIndex(cmp, ebp, esi, 8, 0, i16, 9, 0x66, 0x67, 0x3B, 0x2C,
696 0xF5, 0x00, 0x00, 0x00, 0x00);
697 TestRegAddrScaledIndex(cmp, esi, edi, 1, 0, i16, 9, 0x66, 0x67, 0x3B, 0x34,
698 0x3D, 0x00, 0x00, 0x00, 0x00);
699 TestRegAddrScaledIndex(cmp, edi, eax, 2, 0, i16, 9, 0x66, 0x67, 0x3B, 0x3C,
700 0x45, 0x00, 0x00, 0x00, 0x00);
701 TestRegAddrScaledIndex(cmp, ebx, ecx, 8, 0, i16, 9, 0x66, 0x67, 0x3B, 0x1C,
702 0xCD, 0x00, 0x00, 0x00, 0x00);
703
704 TestRegAddrScaledIndex(cmp, eax, ecx, 4, 0, i8, 8, 0x67, 0x3A, 0x04, 0x8D,
705 0x00, 0x00, 0x00, 0x00);
706 TestRegAddrScaledIndex(cmp, ecx, edx, 8, 0, i8, 8, 0x67, 0x3A, 0x0C, 0xD5,
707 0x00, 0x00, 0x00, 0x00);
708 TestRegAddrScaledIndex(cmp, edx, ebx, 1, 0, i8, 8, 0x67, 0x3A, 0x14, 0x1D,
709 0x00, 0x00, 0x00, 0x00);
710 TestRegAddrScaledIndex(cmp, r8, r9, 4, 0, i8, 9, 0x67, 0x46, 0x3A, 0x04, 0x8D,
711 0x00, 0x00, 0x00, 0x00);
712 TestRegAddrScaledIndex(cmp, r9, r10, 8, 0, i8, 9, 0x67, 0x46, 0x3A, 0x0C,
713 0xD5, 0x00, 0x00, 0x00, 0x00);
714 TestRegAddrScaledIndex(cmp, r10, r11, 1, 0, i8, 9, 0x67, 0x46, 0x3A, 0x14,
715 0x1D, 0x00, 0x00, 0x00, 0x00);
716 // esp cannot be an scaled index.
717 TestRegAddrScaledIndex(cmp, esp, ebp, 2, 0, i8, 8, 0x67, 0x3A, 0x24, 0x6D,
718 0x00, 0x00, 0x00, 0x00);
719 TestRegAddrScaledIndex(cmp, ebp, esi, 4, 0, i8, 9, 0x67, 0x40, 0x3A, 0x2C,
720 0xB5, 0x00, 0x00, 0x00, 0x00);
721 TestRegAddrScaledIndex(cmp, esi, edi, 8, 0, i8, 9, 0x67, 0x40, 0x3A, 0x34,
722 0xFD, 0x00, 0x00, 0x00, 0x00);
723 TestRegAddrScaledIndex(cmp, edi, eax, 1, 0, i8, 9, 0x67, 0x40, 0x3A, 0x3C,
724 0x05, 0x00, 0x00, 0x00, 0x00);
725 TestRegAddrScaledIndex(cmp, ebx, ecx, 8, 0, i8, 8, 0x67, 0x3a, 0x1C, 0xCD,
726 0x00, 0x00, 0x00, 0x00);
727 TestRegAddrScaledIndex(cmp, r12, r13, 2, 0, i8, 9, 0x67, 0x46, 0x3A, 0x24,
728 0x6D, 0x00, 0x00, 0x00, 0x00);
729 TestRegAddrScaledIndex(cmp, r13, r14, 4, 0, i8, 9, 0x67, 0x46, 0x3A, 0x2C,
730 0xB5, 0x00, 0x00, 0x00, 0x00);
731 TestRegAddrScaledIndex(cmp, r14, r15, 8, 0, i8, 9, 0x67, 0x46, 0x3A, 0x34,
732 0xFD, 0x00, 0x00, 0x00, 0x00);
733 TestRegAddrScaledIndex(cmp, r15, r8, 1, 0, i8, 9, 0x67, 0x46, 0x3A, 0x3C,
734 0x05, 0x00, 0x00, 0x00, 0x00);
735 TestRegAddrScaledIndex(cmp, r11, r9, 8, 0, i8, 9, 0x67, 0x46, 0x3a, 0x1C,
736 0xCD, 0x00, 0x00, 0x00, 0x00);
737
738 /* cmp GPR, 0(Base,Index,Scale) */
739 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0, i32, 4, 0x67, 0x3B, 0x04,
740 0x11);
741 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0, i32, 4, 0x67, 0x3B, 0x0C,
742 0x5A);
743 TestRegAddrBaseScaledIndex(cmp, r8, r9, r10, 1, 0, i32, 5, 0x67, 0x47, 0x3B,
744 0x04, 0x11);
745 TestRegAddrBaseScaledIndex(cmp, r9, r10, r11, 2, 0, i32, 5, 0x67, 0x47, 0x3B,
746 0x0C, 0x5A);
747 // esp cannot be an scaled index.
748 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0, i32, 4, 0x67, 0x3B, 0x1C,
749 0xAC);
750 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0, i32, 5, 0x67, 0x3B, 0x64,
751 0xF5, 0x00);
752 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0, i32, 4, 0x67, 0x3B, 0x2C,
753 0x3E);
754 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0, i32, 4, 0x67, 0x3B, 0x34,
755 0x47);
756 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0, i32, 4, 0x67, 0x3B, 0x3C,
757 0x98);
758 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0, i32, 4, 0x67, 0x3B, 0x1C,
759 0xD1);
760 TestRegAddrBaseScaledIndex(cmp, r11, r12, r13, 4, 0, i32, 5, 0x67, 0x47, 0x3B,
761 0x1C, 0xAC);
762 TestRegAddrBaseScaledIndex(cmp, r12, r13, r14, 8, 0, i32, 6, 0x67, 0x47, 0x3B,
763 0x64, 0xF5, 0x00);
764 TestRegAddrBaseScaledIndex(cmp, r13, r14, r15, 1, 0, i32, 5, 0x67, 0x47, 0x3B,
765 0x2C, 0x3E);
766 TestRegAddrBaseScaledIndex(cmp, r14, r15, r8, 2, 0, i32, 5, 0x67, 0x47, 0x3B,
767 0x34, 0x47);
768 TestRegAddrBaseScaledIndex(cmp, r15, r8, r11, 4, 0, i32, 5, 0x67, 0x47, 0x3B,
769 0x3C, 0x98);
770 TestRegAddrBaseScaledIndex(cmp, r11, r9, r10, 8, 0, i32, 5, 0x67, 0x47, 0x3B,
771 0x1C, 0xD1);
772
773 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0, i16, 5, 0x66, 0x67, 0x3B,
774 0x04, 0x11);
775 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0, i16, 5, 0x66, 0x67, 0x3B,
776 0x0C, 0x5A);
777 TestRegAddrBaseScaledIndex(cmp, r8, r9, r10, 1, 0, i16, 6, 0x66, 0x67, 0x47,
778 0x3B, 0x04, 0x11);
779 TestRegAddrBaseScaledIndex(cmp, r9, r10, r11, 2, 0, i16, 6, 0x66, 0x67, 0x47,
780 0x3B, 0x0C, 0x5A);
781 // esp cannot be an scaled index.
782 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0, i16, 5, 0x66, 0x67, 0x3B,
783 0x1C, 0xAC);
784 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0, i16, 6, 0x66, 0x67, 0x3B,
785 0x64, 0xF5, 0x00);
786 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0, i16, 5, 0x66, 0x67, 0x3B,
787 0x2C, 0x3E);
788 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0, i16, 5, 0x66, 0x67, 0x3B,
789 0x34, 0x47);
790 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0, i16, 5, 0x66, 0x67, 0x3B,
791 0x3C, 0x98);
792 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0, i16, 5, 0x66, 0x67, 0x3B,
793 0x1C, 0xD1);
794 TestRegAddrBaseScaledIndex(cmp, r11, r12, r13, 4, 0, i16, 6, 0x66, 0x67, 0x47,
795 0x3B, 0x1C, 0xAC);
796 TestRegAddrBaseScaledIndex(cmp, r12, r13, r14, 8, 0, i16, 7, 0x66, 0x67, 0x47,
797 0x3B, 0x64, 0xF5, 0x00);
798 TestRegAddrBaseScaledIndex(cmp, r13, r14, r15, 1, 0, i16, 6, 0x66, 0x67, 0x47,
799 0x3B, 0x2C, 0x3E);
800 TestRegAddrBaseScaledIndex(cmp, r14, r15, r8, 2, 0, i16, 6, 0x66, 0x67, 0x47,
801 0x3B, 0x34, 0x47);
802 TestRegAddrBaseScaledIndex(cmp, r15, r8, r11, 4, 0, i16, 6, 0x66, 0x67, 0x47,
803 0x3B, 0x3C, 0x98);
804 TestRegAddrBaseScaledIndex(cmp, r11, r9, r10, 8, 0, i16, 6, 0x66, 0x67, 0x47,
805 0x3B, 0x1C, 0xD1);
806
807 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0, i8, 4, 0x67, 0x3A, 0x04,
808 0x11);
809 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0, i8, 4, 0x67, 0x3A, 0x0C,
810 0x5A);
811 TestRegAddrBaseScaledIndex(cmp, r8, r9, r10, 1, 0, i8, 5, 0x67, 0x47, 0x3A,
812 0x04, 0x11);
813 TestRegAddrBaseScaledIndex(cmp, r9, r10, r11, 2, 0, i8, 5, 0x67, 0x47, 0x3A,
814 0x0C, 0x5A);
815 // esp cannot be an scaled index.
816 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0, i8, 4, 0x67, 0x3A, 0x1C,
817 0xAC);
818 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0, i8, 5, 0x67, 0x3A, 0x64,
819 0xF5, 0x00);
820 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0, i8, 5, 0x67, 0x40, 0x3A,
821 0x2C, 0x3E);
822 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0, i8, 5, 0x67, 0x40, 0x3A,
823 0x34, 0x47);
824 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0, i8, 5, 0x67, 0x40, 0x3A,
825 0x3C, 0x98);
826 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0, i8, 4, 0x67, 0x3A, 0x1C,
827 0xD1);
828 TestRegAddrBaseScaledIndex(cmp, r11, r12, r13, 4, 0, i8, 5, 0x67, 0x47, 0x3A,
829 0x1C, 0xAC);
830 TestRegAddrBaseScaledIndex(cmp, r12, r13, r14, 8, 0, i8, 6, 0x67, 0x47, 0x3A,
831 0x64, 0xF5, 0x00);
832 TestRegAddrBaseScaledIndex(cmp, r13, r14, r15, 1, 0, i8, 5, 0x67, 0x47, 0x3A,
833 0x2C, 0x3E);
834 TestRegAddrBaseScaledIndex(cmp, r14, r15, r8, 2, 0, i8, 5, 0x67, 0x47, 0x3A,
835 0x34, 0x47);
836 TestRegAddrBaseScaledIndex(cmp, r15, r8, r11, 4, 0, i8, 5, 0x67, 0x47, 0x3A,
837 0x3C, 0x98);
838 TestRegAddrBaseScaledIndex(cmp, r11, r9, r10, 8, 0, i8, 5, 0x67, 0x47, 0x3A,
839 0x1C, 0xD1);
840
841 /* cmp GPR, Imm8(Base,Index,Scale) */
842 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0x40, i32, 5, 0x67, 0x3B,
843 0x44, 0x11, 0x40);
844 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0x40, i32, 5, 0x67, 0x3B,
845 0x4C, 0x5A, 0x40);
846 TestRegAddrBaseScaledIndex(cmp, r8, r9, r10, 1, 0x40, i32, 6, 0x67, 0x47,
847 0x3B, 0x44, 0x11, 0x40);
848 TestRegAddrBaseScaledIndex(cmp, r9, r10, r11, 2, 0x40, i32, 6, 0x67, 0x47,
849 0x3B, 0x4C, 0x5A, 0x40);
850 // esp cannot be an scaled index.
851 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0x40, i32, 5, 0x67, 0x3B,
852 0x5C, 0xAC, 0x40);
853 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0x40, i32, 5, 0x67, 0x3B,
854 0x64, 0xF5, 0x40);
855 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0x40, i32, 5, 0x67, 0x3B,
856 0x6C, 0x3E, 0x40);
857 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0x40, i32, 5, 0x67, 0x3B,
858 0x74, 0x47, 0x40);
859 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0x40, i32, 5, 0x67, 0x3B,
860 0x7C, 0x98, 0x40);
861 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0x40, i32, 5, 0x67, 0x3B,
862 0x5C, 0xD1, 0x40);
863 TestRegAddrBaseScaledIndex(cmp, r11, r12, r13, 4, 0x40, i32, 6, 0x67, 0x47,
864 0x3B, 0x5C, 0xAC, 0x40);
865 TestRegAddrBaseScaledIndex(cmp, r12, r13, r14, 8, 0x40, i32, 6, 0x67, 0x47,
866 0x3B, 0x64, 0xF5, 0x40);
867 TestRegAddrBaseScaledIndex(cmp, r13, r14, r15, 1, 0x40, i32, 6, 0x67, 0x47,
868 0x3B, 0x6C, 0x3E, 0x40);
869 TestRegAddrBaseScaledIndex(cmp, r14, r15, r8, 2, 0x40, i32, 6, 0x67, 0x47,
870 0x3B, 0x74, 0x47, 0x40);
871 TestRegAddrBaseScaledIndex(cmp, r15, r8, r11, 4, 0x40, i32, 6, 0x67, 0x47,
872 0x3B, 0x7C, 0x98, 0x40);
873 TestRegAddrBaseScaledIndex(cmp, r11, r9, r10, 8, 0x40, i32, 6, 0x67, 0x47,
874 0x3B, 0x5C, 0xD1, 0x40);
875
876 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0x40, i16, 6, 0x66, 0x67,
877 0x3B, 0x44, 0x11, 0x40);
878 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0x40, i16, 6, 0x66, 0x67,
879 0x3B, 0x4C, 0x5A, 0x40);
880 TestRegAddrBaseScaledIndex(cmp, r8, r9, r10, 1, 0x40, i16, 7, 0x66, 0x67,
881 0x47, 0x3B, 0x44, 0x11, 0x40);
882 TestRegAddrBaseScaledIndex(cmp, r9, r10, r11, 2, 0x40, i16, 7, 0x66, 0x67,
883 0x47, 0x3B, 0x4C, 0x5A, 0x40);
884 // esp cannot be an scaled index.
885 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0x40, i16, 6, 0x66, 0x67,
886 0x3B, 0x5C, 0xAC, 0x40);
887 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0x40, i16, 6, 0x66, 0x67,
888 0x3B, 0x64, 0xF5, 0x40);
889 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0x40, i16, 6, 0x66, 0x67,
890 0x3B, 0x6C, 0x3E, 0x40);
891 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0x40, i16, 6, 0x66, 0x67,
892 0x3B, 0x74, 0x47, 0x40);
893 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0x40, i16, 6, 0x66, 0x67,
894 0x3B, 0x7C, 0x98, 0x40);
895 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0x40, i16, 6, 0x66, 0x67,
896 0x3B, 0x5C, 0xD1, 0x40);
897 TestRegAddrBaseScaledIndex(cmp, r11, r12, r13, 4, 0x40, i16, 7, 0x66, 0x67,
898 0x47, 0x3B, 0x5C, 0xAC, 0x40);
899 TestRegAddrBaseScaledIndex(cmp, r12, r13, r14, 8, 0x40, i16, 7, 0x66, 0x67,
900 0x47, 0x3B, 0x64, 0xF5, 0x40);
901 TestRegAddrBaseScaledIndex(cmp, r13, r14, r15, 1, 0x40, i16, 7, 0x66, 0x67,
902 0x47, 0x3B, 0x6C, 0x3E, 0x40);
903 TestRegAddrBaseScaledIndex(cmp, r14, r15, r8, 2, 0x40, i16, 7, 0x66, 0x67,
904 0x47, 0x3B, 0x74, 0x47, 0x40);
905 TestRegAddrBaseScaledIndex(cmp, r15, r8, r11, 4, 0x40, i16, 7, 0x66, 0x67,
906 0x47, 0x3B, 0x7C, 0x98, 0x40);
907 TestRegAddrBaseScaledIndex(cmp, r11, r9, r10, 8, 0x40, i16, 7, 0x66, 0x67,
908 0x47, 0x3B, 0x5C, 0xD1, 0x40);
909
910 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0x40, i8, 5, 0x67, 0x3A,
911 0x44, 0x11, 0x40);
912 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0x40, i8, 5, 0x67, 0x3A,
913 0x4C, 0x5A, 0x40);
914 TestRegAddrBaseScaledIndex(cmp, r8, r9, r10, 1, 0x40, i8, 6, 0x67, 0x47, 0x3A,
915 0x44, 0x11, 0x40);
916 TestRegAddrBaseScaledIndex(cmp, r9, r10, r11, 2, 0x40, i8, 6, 0x67, 0x47,
917 0x3A, 0x4C, 0x5A, 0x40);
918 // esp cannot be an scaled index.
919 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0x40, i8, 5, 0x67, 0x3A,
920 0x5C, 0xAC, 0x40);
921 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0x40, i8, 5, 0x67, 0x3A,
922 0x64, 0xF5, 0x40);
923 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0x40, i8, 6, 0x67, 0x40,
924 0x3A, 0x6C, 0x3E, 0x40);
925 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0x40, i8, 6, 0x67, 0x40,
926 0x3A, 0x74, 0x47, 0x40);
927 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0x40, i8, 6, 0x67, 0x40,
928 0x3A, 0x7C, 0x98, 0x40);
929 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0x40, i8, 5, 0x67, 0x3A,
930 0x5C, 0xD1, 0x40);
931 TestRegAddrBaseScaledIndex(cmp, r11, r12, r13, 4, 0x40, i8, 6, 0x67, 0x47,
932 0x3A, 0x5C, 0xAC, 0x40);
933 TestRegAddrBaseScaledIndex(cmp, r12, r13, r14, 8, 0x40, i8, 6, 0x67, 0x47,
934 0x3A, 0x64, 0xF5, 0x40);
935 TestRegAddrBaseScaledIndex(cmp, r13, r14, r15, 1, 0x40, i8, 6, 0x67, 0x47,
936 0x3A, 0x6C, 0x3E, 0x40);
937 TestRegAddrBaseScaledIndex(cmp, r14, r15, r8, 2, 0x40, i8, 6, 0x67, 0x47,
938 0x3A, 0x74, 0x47, 0x40);
939 TestRegAddrBaseScaledIndex(cmp, r15, r8, r11, 4, 0x40, i8, 6, 0x67, 0x47,
940 0x3A, 0x7C, 0x98, 0x40);
941 TestRegAddrBaseScaledIndex(cmp, r11, r9, r10, 8, 0x40, i8, 6, 0x67, 0x47,
942 0x3A, 0x5C, 0xD1, 0x40);
943
944 /* cmp GPR, Imm32(Base,Index,Scale) */
945 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0xF0, i32, 8, 0x67, 0x3B,
946 0x84, 0x11, 0xF0, 0x00, 0x00, 0x00);
947 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0xF0, i32, 8, 0x67, 0x3B,
948 0x8C, 0x5A, 0xF0, 0x00, 0x00, 0x00);
949 TestRegAddrBaseScaledIndex(cmp, r8, r9, r10, 1, 0xF0, i32, 9, 0x67, 0x47,
950 0x3B, 0x84, 0x11, 0xF0, 0x00, 0x00, 0x00);
951 TestRegAddrBaseScaledIndex(cmp, r9, r10, r11, 2, 0xF0, i32, 9, 0x67, 0x47,
952 0x3B, 0x8C, 0x5A, 0xF0, 0x00, 0x00, 0x00);
953 // esp cannot be an scaled index.
954 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0xF0, i32, 8, 0x67, 0x3B,
955 0x9C, 0xAC, 0xF0, 0x00, 0x00, 0x00);
956 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0xF0, i32, 8, 0x67, 0x3B,
957 0xA4, 0xF5, 0xF0, 0x00, 0x00, 0x00);
958 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0xF0, i32, 8, 0x67, 0x3B,
959 0xAC, 0x3E, 0xF0, 0x00, 0x00, 0x00);
960 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0xF0, i32, 8, 0x67, 0x3B,
961 0xB4, 0x47, 0xF0, 0x00, 0x00, 0x00);
962 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0xF0, i32, 8, 0x67, 0x3B,
963 0xBC, 0x98, 0xF0, 0x00, 0x00, 0x00);
964 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0xF0, i32, 8, 0x67, 0x3B,
965 0x9C, 0xD1, 0xF0, 0x00, 0x00, 0x00);
966 TestRegAddrBaseScaledIndex(cmp, r11, r12, r13, 4, 0xF0, i32, 9, 0x67, 0x47,
967 0x3B, 0x9C, 0xAC, 0xF0, 0x00, 0x00, 0x00);
968 TestRegAddrBaseScaledIndex(cmp, r12, r13, r14, 8, 0xF0, i32, 9, 0x67, 0x47,
969 0x3B, 0xA4, 0xF5, 0xF0, 0x00, 0x00, 0x00);
970 TestRegAddrBaseScaledIndex(cmp, r13, r14, r15, 1, 0xF0, i32, 9, 0x67, 0x47,
971 0x3B, 0xAC, 0x3E, 0xF0, 0x00, 0x00, 0x00);
972 TestRegAddrBaseScaledIndex(cmp, r14, r15, r8, 2, 0xF0, i32, 9, 0x67, 0x47,
973 0x3B, 0xB4, 0x47, 0xF0, 0x00, 0x00, 0x00);
974 TestRegAddrBaseScaledIndex(cmp, r15, r8, r11, 4, 0xF0, i32, 9, 0x67, 0x47,
975 0x3B, 0xBC, 0x98, 0xF0, 0x00, 0x00, 0x00);
976 TestRegAddrBaseScaledIndex(cmp, r11, r9, r10, 8, 0xF0, i32, 9, 0x67, 0x47,
977 0x3B, 0x9C, 0xD1, 0xF0, 0x00, 0x00, 0x00);
978
979 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0xF0, i16, 9, 0x66, 0x67,
980 0x3B, 0x84, 0x11, 0xF0, 0x00, 0x00, 0x00);
981 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0xF0, i16, 9, 0x66, 0x67,
982 0x3B, 0x8C, 0x5A, 0xF0, 0x00, 0x00, 0x00);
983 TestRegAddrBaseScaledIndex(cmp, r8, r9, r10, 1, 0xF0, i16, 10, 0x66, 0x67,
984 0x47, 0x3B, 0x84, 0x11, 0xF0, 0x00, 0x00, 0x00);
985 TestRegAddrBaseScaledIndex(cmp, r9, r10, r11, 2, 0xF0, i16, 10, 0x66, 0x67,
986 0x47, 0x3B, 0x8C, 0x5A, 0xF0, 0x00, 0x00, 0x00);
987 // esp cannot be an scaled index.
988 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0xF0, i16, 9, 0x66, 0x67,
989 0x3B, 0x9C, 0xAC, 0xF0, 0x00, 0x00, 0x00);
990 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0xF0, i16, 9, 0x66, 0x67,
991 0x3B, 0xA4, 0xF5, 0xF0, 0x00, 0x00, 0x00);
992 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0xF0, i16, 9, 0x66, 0x67,
993 0x3B, 0xAC, 0x3E, 0xF0, 0x00, 0x00, 0x00);
994 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0xF0, i16, 9, 0x66, 0x67,
995 0x3B, 0xB4, 0x47, 0xF0, 0x00, 0x00, 0x00);
996 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0xF0, i16, 9, 0x66, 0x67,
997 0x3B, 0xBC, 0x98, 0xF0, 0x00, 0x00, 0x00);
998 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0xF0, i16, 9, 0x66, 0x67,
999 0x3B, 0x9C, 0xD1, 0xF0, 0x00, 0x00, 0x00);
1000 TestRegAddrBaseScaledIndex(cmp, r11, r12, r13, 4, 0xF0, i16, 10, 0x66, 0x67,
1001 0x47, 0x3B, 0x9C, 0xAC, 0xF0, 0x00, 0x00, 0x00);
1002 TestRegAddrBaseScaledIndex(cmp, r12, r13, r14, 8, 0xF0, i16, 10, 0x66, 0x67,
1003 0x47, 0x3B, 0xA4, 0xF5, 0xF0, 0x00, 0x00, 0x00);
1004 TestRegAddrBaseScaledIndex(cmp, r13, r14, r15, 1, 0xF0, i16, 10, 0x66, 0x67,
1005 0x47, 0x3B, 0xAC, 0x3E, 0xF0, 0x00, 0x00, 0x00);
1006 TestRegAddrBaseScaledIndex(cmp, r14, r15, r8, 2, 0xF0, i16, 10, 0x66, 0x67,
1007 0x47, 0x3B, 0xB4, 0x47, 0xF0, 0x00, 0x00, 0x00);
1008 TestRegAddrBaseScaledIndex(cmp, r15, r8, r11, 4, 0xF0, i16, 10, 0x66, 0x67,
1009 0x47, 0x3B, 0xBC, 0x98, 0xF0, 0x00, 0x00, 0x00);
1010 TestRegAddrBaseScaledIndex(cmp, r11, r9, r10, 8, 0xF0, i16, 10, 0x66, 0x67,
1011 0x47, 0x3B, 0x9C, 0xD1, 0xF0, 0x00, 0x00, 0x00);
1012
1013 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0xF0, i8, 8, 0x67, 0x3A,
1014 0x84, 0x11, 0xF0, 0x00, 0x00, 0x00);
1015 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0xF0, i8, 8, 0x67, 0x3A,
1016 0x8C, 0x5A, 0xF0, 0x00, 0x00, 0x00);
1017 TestRegAddrBaseScaledIndex(cmp, r8, r9, r10, 1, 0xF0, i8, 9, 0x67, 0x47, 0x3A,
1018 0x84, 0x11, 0xF0, 0x00, 0x00, 0x00);
1019 TestRegAddrBaseScaledIndex(cmp, r9, r10, r11, 2, 0xF0, i8, 9, 0x67, 0x47,
1020 0x3A, 0x8C, 0x5A, 0xF0, 0x00, 0x00, 0x00);
1021 // esp cannot be an scaled index.
1022 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0xF0, i8, 8, 0x67, 0x3A,
1023 0x9C, 0xAC, 0xF0, 0x00, 0x00, 0x00);
1024 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0xF0, i8, 8, 0x67, 0x3A,
1025 0xA4, 0xF5, 0xF0, 0x00, 0x00, 0x00);
1026 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0xF0, i8, 9, 0x67, 0x40,
1027 0x3A, 0xAC, 0x3E, 0xF0, 0x00, 0x00, 0x00);
1028 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0xF0, i8, 9, 0x67, 0x40,
1029 0x3A, 0xB4, 0x47, 0xF0, 0x00, 0x00, 0x00);
1030 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0xF0, i8, 9, 0x67, 0x40,
1031 0x3A, 0xBC, 0x98, 0xF0, 0x00, 0x00, 0x00);
1032 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0xF0, i8, 8, 0x67, 0x3A,
1033 0x9C, 0xD1, 0xF0, 0x00, 0x00, 0x00);
1034 TestRegAddrBaseScaledIndex(cmp, r11, r12, r13, 4, 0xF0, i8, 9, 0x67, 0x47,
1035 0x3A, 0x9C, 0xAC, 0xF0, 0x00, 0x00, 0x00);
1036 TestRegAddrBaseScaledIndex(cmp, r12, r13, r14, 8, 0xF0, i8, 9, 0x67, 0x47,
1037 0x3A, 0xA4, 0xF5, 0xF0, 0x00, 0x00, 0x00);
1038 TestRegAddrBaseScaledIndex(cmp, r13, r14, r15, 1, 0xF0, i8, 9, 0x67, 0x47,
1039 0x3A, 0xAC, 0x3E, 0xF0, 0x00, 0x00, 0x00);
1040 TestRegAddrBaseScaledIndex(cmp, r14, r15, r8, 2, 0xF0, i8, 9, 0x67, 0x47,
1041 0x3A, 0xB4, 0x47, 0xF0, 0x00, 0x00, 0x00);
1042 TestRegAddrBaseScaledIndex(cmp, r15, r8, r11, 4, 0xF0, i8, 9, 0x67, 0x47,
1043 0x3A, 0xBC, 0x98, 0xF0, 0x00, 0x00, 0x00);
1044 TestRegAddrBaseScaledIndex(cmp, r11, r9, r10, 8, 0xF0, i8, 9, 0x67, 0x47,
1045 0x3A, 0x9C, 0xD1, 0xF0, 0x00, 0x00, 0x00);
1046
1047 /* cmp Addr, Imm */
1048 // Note: at this point we trust the assembler knows how to encode addresses,
1049 // so no more exhaustive addressing mode testing.
1050 TestAddrBaseScaledIndexImm(cmp, eax, ecx, 1, 0xF0, 0x12, i32, 9, 0x67, 0x83,
1051 0xBC, 0x08, 0xF0, 0x00, 0x00, 0x00, 0x12);
1052 TestAddrBaseScaledIndexImm(cmp, ecx, edx, 1, 0xF0, 0xF0, i32, 12, 0x67, 0x81,
1053 0xBC, 0x11, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00,
1054 0x00, 0x00);
1055 TestAddrBaseScaledIndexImm(cmp, r8, r9, 1, 0xF0, 0x12, i32, 10, 0x67, 0x43,
1056 0x83, 0xBC, 0x08, 0xF0, 0x00, 0x00, 0x00, 0x12);
1057 TestAddrBaseScaledIndexImm(cmp, r9, r10, 1, 0xF0, 0xF0, i32, 13, 0x67, 0x43,
1058 0x81, 0xBC, 0x11, 0xF0, 0x00, 0x00, 0x00, 0xF0,
1059 0x00, 0x00, 0x00);
1060
1061 TestAddrBaseScaledIndexImm(cmp, eax, ecx, 1, 0xF0, 0x12, i16, 10, 0x66, 0x67,
1062 0x83, 0xBC, 0x08, 0xF0, 0x00, 0x00, 0x00, 0x12);
1063 TestAddrBaseScaledIndexImm(cmp, ecx, edx, 1, 0xF0, 0xF0, i16, 11, 0x66, 0x67,
1064 0x81, 0xBC, 0x11, 0xF0, 0x00, 0x00, 0x00, 0xF0,
1065 0x00);
1066 TestAddrBaseScaledIndexImm(cmp, r8, r9, 1, 0xF0, 0x12, i16, 11, 0x66, 0x67,
1067 0x43, 0x83, 0xBC, 0x08, 0xF0, 0x00, 0x00, 0x00,
1068 0x12);
1069 TestAddrBaseScaledIndexImm(cmp, r9, r10, 1, 0xF0, 0xF0, i16, 12, 0x66, 0x67,
1070 0x43, 0x81, 0xBC, 0x11, 0xF0, 0x00, 0x00, 0x00,
1071 0xF0, 0x00);
1072
1073 TestAddrBaseScaledIndexImm(cmp, eax, ecx, 1, 0xF0, 0x12, i8, 9, 0x67, 0x80,
1074 0xBC, 0x08, 0xF0, 0x00, 0x00, 0x00, 0x12);
1075 TestAddrBaseScaledIndexImm(cmp, r8, r9, 1, 0xF0, 0x12, i8, 10, 0x67, 0x43,
1076 0x80, 0xBC, 0x08, 0xF0, 0x00, 0x00, 0x00, 0x12);
1077
1078 /* cmp Addr, GPR */
1079 TestAddrBaseScaledIndexReg(cmp, eax, ecx, 1, 0xF0, edx, i32, 8, 0x67, 0x39,
1080 0x94, 0x08, 0xF0, 0x00, 0x00, 0x00);
1081 TestAddrBaseScaledIndexReg(cmp, r8, r9, 1, 0xF0, r10, i32, 9, 0x67, 0x47,
1082 0x39, 0x94, 0x08, 0xF0, 0x00, 0x00, 0x00);
1083
1084 TestAddrBaseScaledIndexReg(cmp, eax, ecx, 1, 0xF0, edx, i16, 9, 0x66, 0x67,
1085 0x39, 0x94, 0x08, 0xF0, 0x00, 0x00, 0x00);
1086 TestAddrBaseScaledIndexReg(cmp, r8, r9, 1, 0xF0, r10, i16, 10, 0x66, 0x67,
1087 0x47, 0x39, 0x94, 0x08, 0xF0, 0x00, 0x00, 0x00);
1088
1089 TestAddrBaseScaledIndexReg(cmp, eax, ecx, 1, 0xF0, edx, i8, 8, 0x67, 0x38,
1090 0x94, 0x08, 0xF0, 0x00, 0x00, 0x00);
1091 TestAddrBaseScaledIndexReg(cmp, r8, r9, 1, 0xF0, r10, i8, 9, 0x67, 0x47, 0x38,
1092 0x94, 0x08, 0xF0, 0x00, 0x00, 0x00);
1093
1094 #undef TestAddrBaseScaledIndexReg
1095 #undef TestAddrBaseScaledIndexImm
1096 #undef TestRegAddrBaseScaledIndex
1097 #undef TestRegAddrScaledIndex
1098 #undef TestRegAddrBase
1099 #undef TestRegAbsoluteAddr
1100 #undef TestRegImm
1101 #undef TestRegReg
1102 }
1103
TEST_F(AssemblerX8664Test,ScratchpadGettersAndSetters)1104 TEST_F(AssemblerX8664Test, ScratchpadGettersAndSetters) {
1105 const uint32_t S0 = allocateDword();
1106 const uint32_t S1 = allocateDword();
1107 const uint32_t S2 = allocateDword();
1108 const uint32_t S3 = allocateDword();
1109 AssembledTest test = assemble();
1110 test.setDwordTo(S0, 0xBEEF0000u);
1111 test.setDwordTo(S1, 0xDEADu);
1112 test.setDwordTo(S2, 0x20406080u);
1113 ASSERT_EQ(0xBEEF0000u, test.contentsOfDword(S0));
1114 ASSERT_EQ(0xDEADu, test.contentsOfDword(S1));
1115 ASSERT_EQ(0x20406080u, test.contentsOfDword(S2));
1116 ASSERT_EQ(0xDEADBEEF0000ull, test.contentsOfQword(S0));
1117 ASSERT_EQ(0x204060800000DEADull, test.contentsOfQword(S1));
1118
1119 test.setQwordTo(S1, 0x1234567890ABCDEFull);
1120 ASSERT_EQ(0x1234567890ABCDEFull, test.contentsOfQword(S1));
1121 test.setDwordTo(S0, 0xBEEF0000u);
1122 ASSERT_EQ(0x90ABCDEFull, test.contentsOfDword(S1));
1123 ASSERT_EQ(0x12345678ull, test.contentsOfDword(S2));
1124
1125 test.setDwordTo(S0, 1.0f);
1126 ASSERT_FLOAT_EQ(1.0f, test.contentsOfDword<float>(S0));
1127 test.setQwordTo(S0, 3.14);
1128 ASSERT_DOUBLE_EQ(3.14, test.contentsOfQword<double>(S0));
1129
1130 test.setDqwordTo(S0, Dqword(1.0f, 2.0f, 3.0f, 4.0f));
1131 ASSERT_EQ(Dqword(1.0f, 2.0f, 3.0f, 4.0f), test.contentsOfDqword(S0));
1132 EXPECT_FLOAT_EQ(1.0f, test.contentsOfDword<float>(S0));
1133 EXPECT_FLOAT_EQ(2.0f, test.contentsOfDword<float>(S1));
1134 EXPECT_FLOAT_EQ(3.0f, test.contentsOfDword<float>(S2));
1135 EXPECT_FLOAT_EQ(4.0f, test.contentsOfDword<float>(S3));
1136 }
1137
1138 } // end of anonymous namespace
1139 } // end of namespace Test
1140 } // end of namespace X8664
1141 } // end of namespace Ice
1142