1 //===- subzero/unittest/AssemblerX8632/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 "AssemblerX8632/TestUtil.h" 10 11 namespace Ice { 12 namespace X8632 { 13 namespace Test { 14 namespace { 15 16 TEST_F(AssemblerX8632LowLevelTest, Ret) { 17 __ ret(); 18 19 constexpr size_t ByteCount = 1; 20 ASSERT_EQ(ByteCount, codeBytesSize()); 21 22 verifyBytes<ByteCount>(codeBytes(), 0xc3); 23 } 24 25 TEST_F(AssemblerX8632LowLevelTest, 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 34 TEST_F(AssemblerX8632LowLevelTest, 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 43 TEST_F(AssemblerX8632LowLevelTest, PopRegs) { 44 __ popl(GPRRegister::Encoded_Reg_eax); 45 __ popl(GPRRegister::Encoded_Reg_ebx); 46 __ popl(GPRRegister::Encoded_Reg_ecx); 47 __ popl(GPRRegister::Encoded_Reg_edx); 48 __ popl(GPRRegister::Encoded_Reg_edi); 49 __ popl(GPRRegister::Encoded_Reg_esi); 50 __ popl(GPRRegister::Encoded_Reg_ebp); 51 52 constexpr size_t ByteCount = 7; 53 ASSERT_EQ(ByteCount, codeBytesSize()); 54 55 constexpr uint8_t PopOpcode = 0x58; 56 verifyBytes<ByteCount>(codeBytes(), PopOpcode | GPRRegister::Encoded_Reg_eax, 57 PopOpcode | GPRRegister::Encoded_Reg_ebx, 58 PopOpcode | GPRRegister::Encoded_Reg_ecx, 59 PopOpcode | GPRRegister::Encoded_Reg_edx, 60 PopOpcode | GPRRegister::Encoded_Reg_edi, 61 PopOpcode | GPRRegister::Encoded_Reg_esi, 62 PopOpcode | GPRRegister::Encoded_Reg_ebp); 63 } 64 65 TEST_F(AssemblerX8632LowLevelTest, PushRegs) { 66 __ pushl(GPRRegister::Encoded_Reg_eax); 67 __ pushl(GPRRegister::Encoded_Reg_ebx); 68 __ pushl(GPRRegister::Encoded_Reg_ecx); 69 __ pushl(GPRRegister::Encoded_Reg_edx); 70 __ pushl(GPRRegister::Encoded_Reg_edi); 71 __ pushl(GPRRegister::Encoded_Reg_esi); 72 __ pushl(GPRRegister::Encoded_Reg_ebp); 73 74 constexpr size_t ByteCount = 7; 75 ASSERT_EQ(ByteCount, codeBytesSize()); 76 77 constexpr uint8_t PushOpcode = 0x50; 78 verifyBytes<ByteCount>(codeBytes(), PushOpcode | GPRRegister::Encoded_Reg_eax, 79 PushOpcode | GPRRegister::Encoded_Reg_ebx, 80 PushOpcode | GPRRegister::Encoded_Reg_ecx, 81 PushOpcode | GPRRegister::Encoded_Reg_edx, 82 PushOpcode | GPRRegister::Encoded_Reg_edi, 83 PushOpcode | GPRRegister::Encoded_Reg_esi, 84 PushOpcode | GPRRegister::Encoded_Reg_ebp); 85 } 86 87 TEST_F(AssemblerX8632LowLevelTest, MovRegisterZero) { 88 __ mov(IceType_i32, GPRRegister::Encoded_Reg_eax, Immediate(0x00)); 89 __ mov(IceType_i32, GPRRegister::Encoded_Reg_ebx, Immediate(0x00)); 90 __ mov(IceType_i32, GPRRegister::Encoded_Reg_ecx, Immediate(0x00)); 91 __ mov(IceType_i32, GPRRegister::Encoded_Reg_edx, Immediate(0x00)); 92 __ mov(IceType_i32, GPRRegister::Encoded_Reg_edi, Immediate(0x00)); 93 __ mov(IceType_i32, GPRRegister::Encoded_Reg_esi, Immediate(0x00)); 94 95 constexpr size_t MovReg32BitImmBytes = 5; 96 constexpr size_t ByteCount = 6 * MovReg32BitImmBytes; 97 ASSERT_EQ(ByteCount, codeBytesSize()); 98 99 constexpr uint8_t MovOpcode = 0xb8; 100 verifyBytes<ByteCount>( 101 codeBytes(), MovOpcode | GPRRegister::Encoded_Reg_eax, 0x00, 0x00, 0x00, 102 0x00, MovOpcode | GPRRegister::Encoded_Reg_ebx, 0x00, 0x00, 0x00, 0x00, 103 MovOpcode | GPRRegister::Encoded_Reg_ecx, 0x00, 0x00, 0x00, 0x00, 104 MovOpcode | GPRRegister::Encoded_Reg_edx, 0x00, 0x00, 0x00, 0x00, 105 MovOpcode | GPRRegister::Encoded_Reg_edi, 0x00, 0x00, 0x00, 0x00, 106 MovOpcode | GPRRegister::Encoded_Reg_esi, 0x00, 0x00, 0x00, 0x00); 107 } 108 109 TEST_F(AssemblerX8632LowLevelTest, Cmp) { 110 #define TestRegReg(Inst, Dst, Src, OpType, ByteCountUntyped, ...) \ 111 do { \ 112 static constexpr char TestString[] = \ 113 "(" #Inst ", " #Dst ", " #Src ", " #OpType ", " #ByteCountUntyped \ 114 ", " #__VA_ARGS__ ")"; \ 115 static constexpr uint8_t ByteCount = ByteCountUntyped; \ 116 __ Inst(IceType_##OpType, GPRRegister::Encoded_Reg_##Dst, \ 117 GPRRegister::Encoded_Reg_##Src); \ 118 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ 119 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ 120 << TestString; \ 121 reset(); \ 122 } while (0) 123 124 #define TestRegImm(Inst, Dst, Imm, OpType, ByteCountUntyped, ...) \ 125 do { \ 126 static constexpr char TestString[] = \ 127 "(" #Inst ", " #Dst ", " #Imm ", " #OpType ", " #ByteCountUntyped \ 128 ", " #__VA_ARGS__ ")"; \ 129 static constexpr uint8_t ByteCount = ByteCountUntyped; \ 130 __ Inst(IceType_##OpType, GPRRegister::Encoded_Reg_##Dst, Immediate(Imm)); \ 131 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ 132 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ 133 << TestString; \ 134 reset(); \ 135 } while (0) 136 137 #define TestRegAbsoluteAddr(Inst, Dst, Disp, OpType, ByteCountUntyped, ...) \ 138 do { \ 139 static constexpr char TestString[] = \ 140 "(" #Inst ", " #Dst ", " #Disp ", " #OpType ", " #ByteCountUntyped \ 141 ", " #__VA_ARGS__ ")"; \ 142 static constexpr uint8_t ByteCount = ByteCountUntyped; \ 143 __ Inst(IceType_##OpType, GPRRegister::Encoded_Reg_##Dst, \ 144 Address(Disp, AssemblerFixup::NoFixup)); \ 145 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ 146 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ 147 << TestString; \ 148 reset(); \ 149 } while (0) 150 151 #define TestRegAddrBase(Inst, Dst, Base, Disp, OpType, ByteCountUntyped, ...) \ 152 do { \ 153 static constexpr char TestString[] = \ 154 "(" #Inst ", " #Dst ", " #Base ", " #Disp ", " #OpType \ 155 ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ 156 static constexpr uint8_t ByteCount = ByteCountUntyped; \ 157 __ Inst(IceType_##OpType, GPRRegister::Encoded_Reg_##Dst, \ 158 Address(GPRRegister::Encoded_Reg_##Base, Disp, \ 159 AssemblerFixup::NoFixup)); \ 160 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ 161 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ 162 << TestString; \ 163 reset(); \ 164 } while (0) 165 166 #define TestRegAddrScaledIndex(Inst, Dst, Index, Scale, Disp, OpType, \ 167 ByteCountUntyped, ...) \ 168 do { \ 169 static constexpr char TestString[] = \ 170 "(" #Inst ", " #Dst ", " #Index ", " #Scale ", " #Disp ", " #OpType \ 171 ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ 172 static constexpr uint8_t ByteCount = ByteCountUntyped; \ 173 __ Inst(IceType_##OpType, GPRRegister::Encoded_Reg_##Dst, \ 174 Address(GPRRegister::Encoded_Reg_##Index, Traits::TIMES_##Scale, \ 175 Disp, AssemblerFixup::NoFixup)); \ 176 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ 177 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ 178 << TestString; \ 179 reset(); \ 180 } while (0) 181 182 #define TestRegAddrBaseScaledIndex(Inst, Dst, Base, Index, Scale, Disp, \ 183 OpType, ByteCountUntyped, ...) \ 184 do { \ 185 static constexpr char TestString[] = \ 186 "(" #Inst ", " #Dst ", " #Base ", " #Index ", " #Scale ", " #Disp \ 187 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ 188 static constexpr uint8_t ByteCount = ByteCountUntyped; \ 189 __ Inst(IceType_##OpType, GPRRegister::Encoded_Reg_##Dst, \ 190 Address(GPRRegister::Encoded_Reg_##Base, \ 191 GPRRegister::Encoded_Reg_##Index, Traits::TIMES_##Scale, \ 192 Disp, AssemblerFixup::NoFixup)); \ 193 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ 194 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ 195 << TestString; \ 196 reset(); \ 197 } while (0) 198 199 #define TestAddrBaseScaledIndexImm(Inst, Base, Index, Scale, Disp, Imm, \ 200 OpType, ByteCountUntyped, ...) \ 201 do { \ 202 static constexpr char TestString[] = \ 203 "(" #Inst ", " #Base ", " #Index ", " #Scale ", " #Disp ", " #Imm \ 204 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ 205 static constexpr uint8_t ByteCount = ByteCountUntyped; \ 206 __ Inst(IceType_##OpType, \ 207 Address(GPRRegister::Encoded_Reg_##Base, \ 208 GPRRegister::Encoded_Reg_##Index, Traits::TIMES_##Scale, \ 209 Disp, AssemblerFixup::NoFixup), \ 210 Immediate(Imm)); \ 211 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ 212 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ 213 << TestString; \ 214 reset(); \ 215 } while (0) 216 217 #define TestAddrBaseScaledIndexReg(Inst, Base, Index, Scale, Disp, Src, \ 218 OpType, ByteCountUntyped, ...) \ 219 do { \ 220 static constexpr char TestString[] = \ 221 "(" #Inst ", " #Base ", " #Index ", " #Scale ", " #Disp ", " #Src \ 222 ", " #OpType ", " #ByteCountUntyped ", " #__VA_ARGS__ ")"; \ 223 static constexpr uint8_t ByteCount = ByteCountUntyped; \ 224 __ Inst(IceType_##OpType, \ 225 Address(GPRRegister::Encoded_Reg_##Base, \ 226 GPRRegister::Encoded_Reg_##Index, Traits::TIMES_##Scale, \ 227 Disp, AssemblerFixup::NoFixup), \ 228 GPRRegister::Encoded_Reg_##Src); \ 229 ASSERT_EQ(ByteCount, codeBytesSize()) << TestString; \ 230 ASSERT_TRUE(verifyBytes<ByteCount>(codeBytes(), __VA_ARGS__)) \ 231 << TestString; \ 232 reset(); \ 233 } while (0) 234 235 /* cmp GPR, GPR */ 236 TestRegReg(cmp, eax, ecx, i32, 2, 0x3B, 0xC1); 237 TestRegReg(cmp, ecx, edx, i32, 2, 0x3B, 0xCA); 238 TestRegReg(cmp, edx, ebx, i32, 2, 0x3B, 0xD3); 239 TestRegReg(cmp, ebx, esp, i32, 2, 0x3B, 0xDC); 240 TestRegReg(cmp, esp, ebp, i32, 2, 0x3B, 0xE5); 241 TestRegReg(cmp, ebp, esi, i32, 2, 0x3B, 0xEE); 242 TestRegReg(cmp, esi, edi, i32, 2, 0x3B, 0xF7); 243 TestRegReg(cmp, edi, eax, i32, 2, 0x3B, 0xF8); 244 245 TestRegReg(cmp, eax, ecx, i16, 3, 0x66, 0x3B, 0xC1); 246 TestRegReg(cmp, ecx, edx, i16, 3, 0x66, 0x3B, 0xCA); 247 TestRegReg(cmp, edx, ebx, i16, 3, 0x66, 0x3B, 0xD3); 248 TestRegReg(cmp, ebx, esp, i16, 3, 0x66, 0x3B, 0xDC); 249 TestRegReg(cmp, esp, ebp, i16, 3, 0x66, 0x3B, 0xE5); 250 TestRegReg(cmp, ebp, esi, i16, 3, 0x66, 0x3B, 0xEE); 251 TestRegReg(cmp, esi, edi, i16, 3, 0x66, 0x3B, 0xF7); 252 TestRegReg(cmp, edi, eax, i16, 3, 0x66, 0x3B, 0xF8); 253 254 TestRegReg(cmp, eax, ecx, i8, 2, 0x3A, 0xC1); 255 TestRegReg(cmp, ecx, edx, i8, 2, 0x3A, 0xCA); 256 TestRegReg(cmp, edx, ebx, i8, 2, 0x3A, 0xD3); 257 TestRegReg(cmp, ebx, esp, i8, 2, 0x3A, 0xDC); 258 TestRegReg(cmp, esp, ebp, i8, 2, 0x3A, 0xE5); 259 TestRegReg(cmp, ebp, esi, i8, 2, 0x3A, 0xEE); 260 TestRegReg(cmp, esi, edi, i8, 2, 0x3A, 0xF7); 261 TestRegReg(cmp, edi, eax, i8, 2, 0x3A, 0xF8); 262 263 /* cmp GPR, Imm8 */ 264 TestRegImm(cmp, eax, 5, i32, 3, 0x83, 0xF8, 0x05); 265 TestRegImm(cmp, ecx, 5, i32, 3, 0x83, 0xF9, 0x05); 266 TestRegImm(cmp, edx, 5, i32, 3, 0x83, 0xFA, 0x05); 267 TestRegImm(cmp, ebx, 5, i32, 3, 0x83, 0xFB, 0x05); 268 TestRegImm(cmp, esp, 5, i32, 3, 0x83, 0xFC, 0x05); 269 TestRegImm(cmp, ebp, 5, i32, 3, 0x83, 0xFD, 0x05); 270 TestRegImm(cmp, esi, 5, i32, 3, 0x83, 0xFE, 0x05); 271 TestRegImm(cmp, edi, 5, i32, 3, 0x83, 0xFF, 0x05); 272 273 TestRegImm(cmp, eax, 5, i16, 4, 0x66, 0x83, 0xF8, 0x05); 274 TestRegImm(cmp, ecx, 5, i16, 4, 0x66, 0x83, 0xF9, 0x05); 275 TestRegImm(cmp, edx, 5, i16, 4, 0x66, 0x83, 0xFA, 0x05); 276 TestRegImm(cmp, ebx, 5, i16, 4, 0x66, 0x83, 0xFB, 0x05); 277 TestRegImm(cmp, esp, 5, i16, 4, 0x66, 0x83, 0xFC, 0x05); 278 TestRegImm(cmp, ebp, 5, i16, 4, 0x66, 0x83, 0xFD, 0x05); 279 TestRegImm(cmp, esi, 5, i16, 4, 0x66, 0x83, 0xFE, 0x05); 280 TestRegImm(cmp, edi, 5, i16, 4, 0x66, 0x83, 0xFF, 0x05); 281 282 TestRegImm(cmp, eax, 5, i8, 2, 0x3C, 0x05); 283 TestRegImm(cmp, ecx, 5, i8, 3, 0x80, 0xF9, 0x05); 284 TestRegImm(cmp, edx, 5, i8, 3, 0x80, 0xFA, 0x05); 285 TestRegImm(cmp, ebx, 5, i8, 3, 0x80, 0xFB, 0x05); 286 TestRegImm(cmp, esp, 5, i8, 3, 0x80, 0xFC, 0x05); 287 TestRegImm(cmp, ebp, 5, i8, 3, 0x80, 0xFD, 0x05); 288 TestRegImm(cmp, esi, 5, i8, 3, 0x80, 0xFE, 0x05); 289 TestRegImm(cmp, edi, 5, i8, 3, 0x80, 0xFF, 0x05); 290 291 /* cmp GPR, Imm16 */ 292 TestRegImm(cmp, eax, 0x100, i32, 5, 0x3D, 0x00, 0x01, 0x00, 0x00); 293 TestRegImm(cmp, ecx, 0x100, i32, 6, 0x81, 0xF9, 0x00, 0x01, 0x00, 0x00); 294 TestRegImm(cmp, edx, 0x100, i32, 6, 0x81, 0xFA, 0x00, 0x01, 0x00, 0x00); 295 TestRegImm(cmp, ebx, 0x100, i32, 6, 0x81, 0xFB, 0x00, 0x01, 0x00, 0x00); 296 TestRegImm(cmp, esp, 0x100, i32, 6, 0x81, 0xFC, 0x00, 0x01, 0x00, 0x00); 297 TestRegImm(cmp, ebp, 0x100, i32, 6, 0x81, 0xFD, 0x00, 0x01, 0x00, 0x00); 298 TestRegImm(cmp, esi, 0x100, i32, 6, 0x81, 0xFE, 0x00, 0x01, 0x00, 0x00); 299 TestRegImm(cmp, edi, 0x100, i32, 6, 0x81, 0xFF, 0x00, 0x01, 0x00, 0x00); 300 301 TestRegImm(cmp, eax, 0x100, i16, 4, 0x66, 0x3D, 0x00, 0x01); 302 TestRegImm(cmp, ecx, 0x100, i16, 5, 0x66, 0x81, 0xF9, 0x00, 0x01); 303 TestRegImm(cmp, edx, 0x100, i16, 5, 0x66, 0x81, 0xFA, 0x00, 0x01); 304 TestRegImm(cmp, ebx, 0x100, i16, 5, 0x66, 0x81, 0xFB, 0x00, 0x01); 305 TestRegImm(cmp, esp, 0x100, i16, 5, 0x66, 0x81, 0xFC, 0x00, 0x01); 306 TestRegImm(cmp, ebp, 0x100, i16, 5, 0x66, 0x81, 0xFD, 0x00, 0x01); 307 TestRegImm(cmp, esi, 0x100, i16, 5, 0x66, 0x81, 0xFE, 0x00, 0x01); 308 TestRegImm(cmp, edi, 0x100, i16, 5, 0x66, 0x81, 0xFF, 0x00, 0x01); 309 310 /* cmp GPR, Absolute */ 311 TestRegAbsoluteAddr(cmp, eax, 0xF00FBEEF, i32, 6, 0x3B, 0x05, 0xEF, 0xBE, 312 0x0F, 0xF0); 313 TestRegAbsoluteAddr(cmp, eax, 0xF00FBEEF, i16, 7, 0x66, 0x3B, 0x05, 0xEF, 314 0xBE, 0x0F, 0xF0); 315 TestRegAbsoluteAddr(cmp, eax, 0xF00FBEEF, i8, 6, 0x3A, 0x05, 0xEF, 0xBE, 0x0F, 316 0xF0); 317 318 /* cmp GPR, 0(Base) */ 319 TestRegAddrBase(cmp, eax, ecx, 0, i32, 2, 0x3B, 0x01); 320 TestRegAddrBase(cmp, ecx, edx, 0, i32, 2, 0x3B, 0x0A); 321 TestRegAddrBase(cmp, edx, ebx, 0, i32, 2, 0x3B, 0x13); 322 TestRegAddrBase(cmp, ebx, esp, 0, i32, 3, 0x3B, 0x1C, 0x24); 323 TestRegAddrBase(cmp, esp, ebp, 0, i32, 3, 0x3B, 0x65, 0x00); 324 TestRegAddrBase(cmp, ebp, esi, 0, i32, 2, 0x3B, 0x2E); 325 TestRegAddrBase(cmp, esi, edi, 0, i32, 2, 0x3B, 0x37); 326 TestRegAddrBase(cmp, edi, eax, 0, i32, 2, 0x3B, 0x38); 327 328 TestRegAddrBase(cmp, eax, ecx, 0, i16, 3, 0x66, 0x3B, 0x01); 329 TestRegAddrBase(cmp, ecx, edx, 0, i16, 3, 0x66, 0x3B, 0x0A); 330 TestRegAddrBase(cmp, edx, ebx, 0, i16, 3, 0x66, 0x3B, 0x13); 331 TestRegAddrBase(cmp, ebx, esp, 0, i16, 4, 0x66, 0x3B, 0x1C, 0x24); 332 TestRegAddrBase(cmp, esp, ebp, 0, i16, 4, 0x66, 0x3B, 0x65, 0x00); 333 TestRegAddrBase(cmp, ebp, esi, 0, i16, 3, 0x66, 0x3B, 0x2E); 334 TestRegAddrBase(cmp, esi, edi, 0, i16, 3, 0x66, 0x3B, 0x37); 335 TestRegAddrBase(cmp, edi, eax, 0, i16, 3, 0x66, 0x3B, 0x38); 336 337 TestRegAddrBase(cmp, eax, ecx, 0, i8, 2, 0x3A, 0x01); 338 TestRegAddrBase(cmp, ecx, edx, 0, i8, 2, 0x3A, 0x0A); 339 TestRegAddrBase(cmp, edx, ebx, 0, i8, 2, 0x3A, 0x13); 340 TestRegAddrBase(cmp, ebx, esp, 0, i8, 3, 0x3A, 0x1C, 0x24); 341 TestRegAddrBase(cmp, esp, ebp, 0, i8, 3, 0x3A, 0x65, 0x00); 342 TestRegAddrBase(cmp, ebp, esi, 0, i8, 2, 0x3A, 0x2E); 343 TestRegAddrBase(cmp, esi, edi, 0, i8, 2, 0x3A, 0x37); 344 TestRegAddrBase(cmp, edi, eax, 0, i8, 2, 0x3A, 0x38); 345 346 /* cmp GPR, Imm8(Base) */ 347 TestRegAddrBase(cmp, eax, ecx, 0x40, i32, 3, 0x3B, 0x41, 0x40); 348 TestRegAddrBase(cmp, ecx, edx, 0x40, i32, 3, 0x3B, 0x4A, 0x40); 349 TestRegAddrBase(cmp, edx, ebx, 0x40, i32, 3, 0x3B, 0x53, 0x40); 350 TestRegAddrBase(cmp, ebx, esp, 0x40, i32, 4, 0x3B, 0x5C, 0x24, 0x40); 351 TestRegAddrBase(cmp, esp, ebp, 0x40, i32, 3, 0x3B, 0x65, 0x40); 352 TestRegAddrBase(cmp, ebp, esi, 0x40, i32, 3, 0x3B, 0x6E, 0x40); 353 TestRegAddrBase(cmp, esi, edi, 0x40, i32, 3, 0x3B, 0x77, 0x40); 354 TestRegAddrBase(cmp, edi, eax, 0x40, i32, 3, 0x3B, 0x78, 0x40); 355 356 TestRegAddrBase(cmp, eax, ecx, 0x40, i16, 4, 0x66, 0x3B, 0x41, 0x40); 357 TestRegAddrBase(cmp, ecx, edx, 0x40, i16, 4, 0x66, 0x3B, 0x4A, 0x40); 358 TestRegAddrBase(cmp, edx, ebx, 0x40, i16, 4, 0x66, 0x3B, 0x53, 0x40); 359 TestRegAddrBase(cmp, ebx, esp, 0x40, i16, 5, 0x66, 0x3B, 0x5C, 0x24, 0x40); 360 TestRegAddrBase(cmp, esp, ebp, 0x40, i16, 4, 0x66, 0x3B, 0x65, 0x40); 361 TestRegAddrBase(cmp, ebp, esi, 0x40, i16, 4, 0x66, 0x3B, 0x6E, 0x40); 362 TestRegAddrBase(cmp, esi, edi, 0x40, i16, 4, 0x66, 0x3B, 0x77, 0x40); 363 TestRegAddrBase(cmp, edi, eax, 0x40, i16, 4, 0x66, 0x3B, 0x78, 0x40); 364 365 TestRegAddrBase(cmp, eax, ecx, 0x40, i8, 3, 0x3A, 0x41, 0x40); 366 TestRegAddrBase(cmp, ecx, edx, 0x40, i8, 3, 0x3A, 0x4A, 0x40); 367 TestRegAddrBase(cmp, edx, ebx, 0x40, i8, 3, 0x3A, 0x53, 0x40); 368 TestRegAddrBase(cmp, ebx, esp, 0x40, i8, 4, 0x3A, 0x5C, 0x24, 0x40); 369 TestRegAddrBase(cmp, esp, ebp, 0x40, i8, 3, 0x3A, 0x65, 0x40); 370 TestRegAddrBase(cmp, ebp, esi, 0x40, i8, 3, 0x3A, 0x6E, 0x40); 371 TestRegAddrBase(cmp, esi, edi, 0x40, i8, 3, 0x3A, 0x77, 0x40); 372 TestRegAddrBase(cmp, edi, eax, 0x40, i8, 3, 0x3A, 0x78, 0x40); 373 374 /* cmp GPR, Imm32(Base) */ 375 TestRegAddrBase(cmp, eax, ecx, 0xF0, i32, 6, 0x3B, 0x81, 0xF0, 0x00, 0x00, 376 0x00); 377 TestRegAddrBase(cmp, ecx, edx, 0xF0, i32, 6, 0x3B, 0x8A, 0xF0, 0x00, 0x00, 378 0x00); 379 TestRegAddrBase(cmp, edx, ebx, 0xF0, i32, 6, 0x3B, 0x93, 0xF0, 0x00, 0x00, 380 0x00); 381 TestRegAddrBase(cmp, ebx, esp, 0xF0, i32, 7, 0x3B, 0x9C, 0x24, 0xF0, 0x00, 382 0x00, 0x00); 383 TestRegAddrBase(cmp, esp, ebp, 0xF0, i32, 6, 0x3B, 0xA5, 0xF0, 0x00, 0x00, 384 0x00); 385 TestRegAddrBase(cmp, ebp, esi, 0xF0, i32, 6, 0x3B, 0xAE, 0xF0, 0x00, 0x00, 386 0x00); 387 TestRegAddrBase(cmp, esi, edi, 0xF0, i32, 6, 0x3B, 0xB7, 0xF0, 0x00, 0x00, 388 0x00); 389 TestRegAddrBase(cmp, edi, eax, 0xF0, i32, 6, 0x3B, 0xB8, 0xF0, 0x00, 0x00, 390 0x00); 391 392 TestRegAddrBase(cmp, eax, ecx, 0xF0, i16, 7, 0x66, 0x3B, 0x81, 0xF0, 0x00, 393 0x00, 0x00); 394 TestRegAddrBase(cmp, ecx, edx, 0xF0, i16, 7, 0x66, 0x3B, 0x8A, 0xF0, 0x00, 395 0x00, 0x00); 396 TestRegAddrBase(cmp, edx, ebx, 0xF0, i16, 7, 0x66, 0x3B, 0x93, 0xF0, 0x00, 397 0x00, 0x00); 398 TestRegAddrBase(cmp, ebx, esp, 0xF0, i16, 8, 0x66, 0x3B, 0x9C, 0x24, 0xF0, 399 0x00, 0x00, 0x00); 400 TestRegAddrBase(cmp, esp, ebp, 0xF0, i16, 7, 0x66, 0x3B, 0xa5, 0xF0, 0x00, 401 0x00, 0x00); 402 TestRegAddrBase(cmp, ebp, esi, 0xF0, i16, 7, 0x66, 0x3B, 0xaE, 0xF0, 0x00, 403 0x00, 0x00); 404 TestRegAddrBase(cmp, esi, edi, 0xF0, i16, 7, 0x66, 0x3B, 0xb7, 0xF0, 0x00, 405 0x00, 0x00); 406 TestRegAddrBase(cmp, edi, eax, 0xF0, i16, 7, 0x66, 0x3B, 0xb8, 0xF0, 0x00, 407 0x00, 0x00); 408 409 TestRegAddrBase(cmp, eax, ecx, 0xF0, i8, 6, 0x3A, 0x81, 0xF0, 0x00, 0x00, 410 0x00); 411 TestRegAddrBase(cmp, ecx, edx, 0xF0, i8, 6, 0x3A, 0x8A, 0xF0, 0x00, 0x00, 412 0x00); 413 TestRegAddrBase(cmp, edx, ebx, 0xF0, i8, 6, 0x3A, 0x93, 0xF0, 0x00, 0x00, 414 0x00); 415 TestRegAddrBase(cmp, ebx, esp, 0xF0, i8, 7, 0x3A, 0x9C, 0x24, 0xF0, 0x00, 416 0x00, 0x00); 417 TestRegAddrBase(cmp, esp, ebp, 0xF0, i8, 6, 0x3A, 0xA5, 0xF0, 0x00, 0x00, 418 0x00); 419 TestRegAddrBase(cmp, ebp, esi, 0xF0, i8, 6, 0x3A, 0xAE, 0xF0, 0x00, 0x00, 420 0x00); 421 TestRegAddrBase(cmp, esi, edi, 0xF0, i8, 6, 0x3A, 0xB7, 0xF0, 0x00, 0x00, 422 0x00); 423 TestRegAddrBase(cmp, edi, eax, 0xF0, i8, 6, 0x3A, 0xB8, 0xF0, 0x00, 0x00, 424 0x00); 425 426 /* cmp GPR, Imm(,Index,Scale) */ 427 TestRegAddrScaledIndex(cmp, eax, ecx, 1, 0, i32, 7, 0x3B, 0x04, 0x0D, 0x00, 428 0x00, 0x00, 0x00); 429 TestRegAddrScaledIndex(cmp, ecx, edx, 2, 0, i32, 7, 0x3B, 0x0C, 0x55, 0x00, 430 0x00, 0x00, 0x00); 431 TestRegAddrScaledIndex(cmp, edx, ebx, 4, 0, i32, 7, 0x3B, 0x14, 0x9D, 0x00, 432 0x00, 0x00, 0x00); 433 // esp cannot be an scaled index. 434 TestRegAddrScaledIndex(cmp, esp, ebp, 8, 0, i32, 7, 0x3B, 0x24, 0xED, 0x00, 435 0x00, 0x00, 0x00); 436 TestRegAddrScaledIndex(cmp, ebp, esi, 1, 0, i32, 7, 0x3B, 0x2C, 0x35, 0x00, 437 0x00, 0x00, 0x00); 438 TestRegAddrScaledIndex(cmp, esi, edi, 2, 0, i32, 7, 0x3B, 0x34, 0x7D, 0x00, 439 0x00, 0x00, 0x00); 440 TestRegAddrScaledIndex(cmp, edi, eax, 4, 0, i32, 7, 0x3B, 0x3C, 0x85, 0x00, 441 0x00, 0x00, 0x00); 442 TestRegAddrScaledIndex(cmp, ebx, ecx, 8, 0, i32, 7, 0x3B, 0x1C, 0xCD, 0x00, 443 0x00, 0x00, 0x00); 444 445 TestRegAddrScaledIndex(cmp, eax, ecx, 8, 0, i16, 8, 0x66, 0x3B, 0x04, 0xCD, 446 0x00, 0x00, 0x00, 0x00); 447 TestRegAddrScaledIndex(cmp, ecx, edx, 1, 0, i16, 8, 0x66, 0x3B, 0x0C, 0x15, 448 0x00, 0x00, 0x00, 0x00); 449 TestRegAddrScaledIndex(cmp, edx, ebx, 2, 0, i16, 8, 0x66, 0x3B, 0x14, 0x5D, 450 0x00, 0x00, 0x00, 0x00); 451 // esp cannot be an scaled index. 452 TestRegAddrScaledIndex(cmp, esp, ebp, 4, 0, i16, 8, 0x66, 0x3B, 0x24, 0xAD, 453 0x00, 0x00, 0x00, 0x00); 454 TestRegAddrScaledIndex(cmp, ebp, esi, 8, 0, i16, 8, 0x66, 0x3B, 0x2C, 0xF5, 455 0x00, 0x00, 0x00, 0x00); 456 TestRegAddrScaledIndex(cmp, esi, edi, 1, 0, i16, 8, 0x66, 0x3B, 0x34, 0x3D, 457 0x00, 0x00, 0x00, 0x00); 458 TestRegAddrScaledIndex(cmp, edi, eax, 2, 0, i16, 8, 0x66, 0x3B, 0x3C, 0x45, 459 0x00, 0x00, 0x00, 0x00); 460 TestRegAddrScaledIndex(cmp, ebx, ecx, 8, 0, i16, 8, 0x66, 0x3B, 0x1C, 0xCD, 461 0x00, 0x00, 0x00, 0x00); 462 463 TestRegAddrScaledIndex(cmp, eax, ecx, 4, 0, i8, 7, 0x3A, 0x04, 0x8D, 0x00, 464 0x00, 0x00, 0x00); 465 TestRegAddrScaledIndex(cmp, ecx, edx, 8, 0, i8, 7, 0x3A, 0x0C, 0xD5, 0x00, 466 0x00, 0x00, 0x00); 467 TestRegAddrScaledIndex(cmp, edx, ebx, 1, 0, i8, 7, 0x3A, 0x14, 0x1D, 0x00, 468 0x00, 0x00, 0x00); 469 // esp cannot be an scaled index. 470 TestRegAddrScaledIndex(cmp, esp, ebp, 2, 0, i8, 7, 0x3A, 0x24, 0x6D, 0x00, 471 0x00, 0x00, 0x00); 472 TestRegAddrScaledIndex(cmp, ebp, esi, 4, 0, i8, 7, 0x3A, 0x2C, 0xB5, 0x00, 473 0x00, 0x00, 0x00); 474 TestRegAddrScaledIndex(cmp, esi, edi, 8, 0, i8, 7, 0x3A, 0x34, 0xFD, 0x00, 475 0x00, 0x00, 0x00); 476 TestRegAddrScaledIndex(cmp, edi, eax, 1, 0, i8, 7, 0x3A, 0x3C, 0x05, 0x00, 477 0x00, 0x00, 0x00); 478 TestRegAddrScaledIndex(cmp, ebx, ecx, 8, 0, i8, 7, 0x3a, 0x1C, 0xCD, 0x00, 479 0x00, 0x00, 0x00); 480 481 /* cmp GPR, 0(Base,Index,Scale) */ 482 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0, i32, 3, 0x3B, 0x04, 483 0x11); 484 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0, i32, 3, 0x3B, 0x0C, 485 0x5A); 486 // esp cannot be an scaled index. 487 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0, i32, 3, 0x3B, 0x1C, 488 0xAC); 489 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0, i32, 4, 0x3B, 0x64, 0xF5, 490 0x00); 491 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0, i32, 3, 0x3B, 0x2C, 492 0x3E); 493 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0, i32, 3, 0x3B, 0x34, 494 0x47); 495 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0, i32, 3, 0x3B, 0x3C, 496 0x98); 497 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0, i32, 3, 0x3B, 0x1C, 498 0xD1); 499 500 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0, i16, 4, 0x66, 0x3B, 0x04, 501 0x11); 502 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0, i16, 4, 0x66, 0x3B, 0x0C, 503 0x5A); 504 // esp cannot be an scaled index. 505 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0, i16, 4, 0x66, 0x3B, 0x1C, 506 0xAC); 507 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0, i16, 5, 0x66, 0x3B, 0x64, 508 0xF5, 0x00); 509 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0, i16, 4, 0x66, 0x3B, 0x2C, 510 0x3E); 511 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0, i16, 4, 0x66, 0x3B, 0x34, 512 0x47); 513 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0, i16, 4, 0x66, 0x3B, 0x3C, 514 0x98); 515 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0, i16, 4, 0x66, 0x3B, 0x1C, 516 0xD1); 517 518 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0, i8, 3, 0x3A, 0x04, 0x11); 519 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0, i8, 3, 0x3A, 0x0C, 0x5A); 520 // esp cannot be an scaled index. 521 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0, i8, 3, 0x3A, 0x1C, 0xAC); 522 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0, i8, 4, 0x3A, 0x64, 0xF5, 523 0x00); 524 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0, i8, 3, 0x3A, 0x2C, 0x3E); 525 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0, i8, 3, 0x3A, 0x34, 0x47); 526 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0, i8, 3, 0x3A, 0x3C, 0x98); 527 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0, i8, 3, 0x3A, 0x1C, 0xD1); 528 529 /* cmp GPR, Imm8(Base,Index,Scale) */ 530 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0x40, i32, 4, 0x3B, 0x44, 531 0x11, 0x40); 532 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0x40, i32, 4, 0x3B, 0x4C, 533 0x5A, 0x40); 534 // esp cannot be an scaled index. 535 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0x40, i32, 4, 0x3B, 0x5C, 536 0xAC, 0x40); 537 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0x40, i32, 4, 0x3B, 0x64, 538 0xF5, 0x40); 539 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0x40, i32, 4, 0x3B, 0x6C, 540 0x3E, 0x40); 541 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0x40, i32, 4, 0x3B, 0x74, 542 0x47, 0x40); 543 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0x40, i32, 4, 0x3B, 0x7C, 544 0x98, 0x40); 545 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0x40, i32, 4, 0x3B, 0x5C, 546 0xD1, 0x40); 547 548 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0x40, i16, 5, 0x66, 0x3B, 549 0x44, 0x11, 0x40); 550 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0x40, i16, 5, 0x66, 0x3B, 551 0x4C, 0x5A, 0x40); 552 // esp cannot be an scaled index. 553 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0x40, i16, 5, 0x66, 0x3B, 554 0x5C, 0xAC, 0x40); 555 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0x40, i16, 5, 0x66, 0x3B, 556 0x64, 0xF5, 0x40); 557 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0x40, i16, 5, 0x66, 0x3B, 558 0x6C, 0x3E, 0x40); 559 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0x40, i16, 5, 0x66, 0x3B, 560 0x74, 0x47, 0x40); 561 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0x40, i16, 5, 0x66, 0x3B, 562 0x7C, 0x98, 0x40); 563 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0x40, i16, 5, 0x66, 0x3B, 564 0x5C, 0xD1, 0x40); 565 566 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0x40, i8, 4, 0x3A, 0x44, 567 0x11, 0x40); 568 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0x40, i8, 4, 0x3A, 0x4C, 569 0x5A, 0x40); 570 // esp cannot be an scaled index. 571 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0x40, i8, 4, 0x3A, 0x5C, 572 0xAC, 0x40); 573 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0x40, i8, 4, 0x3A, 0x64, 574 0xF5, 0x40); 575 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0x40, i8, 4, 0x3A, 0x6C, 576 0x3E, 0x40); 577 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0x40, i8, 4, 0x3A, 0x74, 578 0x47, 0x40); 579 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0x40, i8, 4, 0x3A, 0x7C, 580 0x98, 0x40); 581 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0x40, i8, 4, 0x3A, 0x5C, 582 0xD1, 0x40); 583 584 /* cmp GPR, Imm32(Base,Index,Scale) */ 585 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0xF0, i32, 7, 0x3B, 0x84, 586 0x11, 0xF0, 0x00, 0x00, 0x00); 587 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0xF0, i32, 7, 0x3B, 0x8C, 588 0x5A, 0xF0, 0x00, 0x00, 0x00); 589 // esp cannot be an scaled index. 590 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0xF0, i32, 7, 0x3B, 0x9C, 591 0xAC, 0xF0, 0x00, 0x00, 0x00); 592 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0xF0, i32, 7, 0x3B, 0xA4, 593 0xF5, 0xF0, 0x00, 0x00, 0x00); 594 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0xF0, i32, 7, 0x3B, 0xAC, 595 0x3E, 0xF0, 0x00, 0x00, 0x00); 596 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0xF0, i32, 7, 0x3B, 0xB4, 597 0x47, 0xF0, 0x00, 0x00, 0x00); 598 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0xF0, i32, 7, 0x3B, 0xBC, 599 0x98, 0xF0, 0x00, 0x00, 0x00); 600 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0xF0, i32, 7, 0x3B, 0x9C, 601 0xD1, 0xF0, 0x00, 0x00, 0x00); 602 603 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0xF0, i16, 8, 0x66, 0x3B, 604 0x84, 0x11, 0xF0, 0x00, 0x00, 0x00); 605 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0xF0, i16, 8, 0x66, 0x3B, 606 0x8C, 0x5A, 0xF0, 0x00, 0x00, 0x00); 607 // esp cannot be an scaled index. 608 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0xF0, i16, 8, 0x66, 0x3B, 609 0x9C, 0xAC, 0xF0, 0x00, 0x00, 0x00); 610 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0xF0, i16, 8, 0x66, 0x3B, 611 0xA4, 0xF5, 0xF0, 0x00, 0x00, 0x00); 612 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0xF0, i16, 8, 0x66, 0x3B, 613 0xAC, 0x3E, 0xF0, 0x00, 0x00, 0x00); 614 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0xF0, i16, 8, 0x66, 0x3B, 615 0xB4, 0x47, 0xF0, 0x00, 0x00, 0x00); 616 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0xF0, i16, 8, 0x66, 0x3B, 617 0xBC, 0x98, 0xF0, 0x00, 0x00, 0x00); 618 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0xF0, i16, 8, 0x66, 0x3B, 619 0x9C, 0xD1, 0xF0, 0x00, 0x00, 0x00); 620 621 TestRegAddrBaseScaledIndex(cmp, eax, ecx, edx, 1, 0xF0, i8, 7, 0x3A, 0x84, 622 0x11, 0xF0, 0x00, 0x00, 0x00); 623 TestRegAddrBaseScaledIndex(cmp, ecx, edx, ebx, 2, 0xF0, i8, 7, 0x3A, 0x8C, 624 0x5A, 0xF0, 0x00, 0x00, 0x00); 625 // esp cannot be an scaled index. 626 TestRegAddrBaseScaledIndex(cmp, ebx, esp, ebp, 4, 0xF0, i8, 7, 0x3A, 0x9C, 627 0xAC, 0xF0, 0x00, 0x00, 0x00); 628 TestRegAddrBaseScaledIndex(cmp, esp, ebp, esi, 8, 0xF0, i8, 7, 0x3A, 0xA4, 629 0xF5, 0xF0, 0x00, 0x00, 0x00); 630 TestRegAddrBaseScaledIndex(cmp, ebp, esi, edi, 1, 0xF0, i8, 7, 0x3A, 0xAC, 631 0x3E, 0xF0, 0x00, 0x00, 0x00); 632 TestRegAddrBaseScaledIndex(cmp, esi, edi, eax, 2, 0xF0, i8, 7, 0x3A, 0xB4, 633 0x47, 0xF0, 0x00, 0x00, 0x00); 634 TestRegAddrBaseScaledIndex(cmp, edi, eax, ebx, 4, 0xF0, i8, 7, 0x3A, 0xBC, 635 0x98, 0xF0, 0x00, 0x00, 0x00); 636 TestRegAddrBaseScaledIndex(cmp, ebx, ecx, edx, 8, 0xF0, i8, 7, 0x3A, 0x9C, 637 0xD1, 0xF0, 0x00, 0x00, 0x00); 638 639 /* cmp Addr, Imm */ 640 // Note: at this point we trust the assembler knows how to encode addresses, 641 // so no more exhaustive addressing mode testing. 642 TestAddrBaseScaledIndexImm(cmp, eax, ecx, 1, 0xF0, 0x12, i32, 8, 0x83, 0xBC, 643 0x08, 0xF0, 0x00, 0x00, 0x00, 0x12); 644 TestAddrBaseScaledIndexImm(cmp, ecx, edx, 1, 0xF0, 0xF0, i32, 11, 0x81, 0xBC, 645 0x11, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 646 0x00); 647 648 TestAddrBaseScaledIndexImm(cmp, eax, ecx, 1, 0xF0, 0x12, i16, 9, 0x66, 0x83, 649 0xBC, 0x08, 0xF0, 0x00, 0x00, 0x00, 0x12); 650 TestAddrBaseScaledIndexImm(cmp, ecx, edx, 1, 0xF0, 0xF0, i16, 10, 0x66, 0x81, 651 0xBC, 0x11, 0xF0, 0x00, 0x00, 0x00, 0xF0, 0x00); 652 653 TestAddrBaseScaledIndexImm(cmp, eax, ecx, 1, 0xF0, 0x12, i8, 8, 0x80, 0xBC, 654 0x08, 0xF0, 0x00, 0x00, 0x00, 0x12); 655 656 /* cmp Addr, GPR */ 657 TestAddrBaseScaledIndexReg(cmp, eax, ecx, 1, 0xF0, edx, i32, 7, 0x39, 0x94, 658 0x08, 0xF0, 0x00, 0x00, 0x00); 659 660 TestAddrBaseScaledIndexReg(cmp, eax, ecx, 1, 0xF0, edx, i16, 8, 0x66, 0x39, 661 0x94, 0x08, 0xF0, 0x00, 0x00, 0x00); 662 663 TestAddrBaseScaledIndexReg(cmp, eax, ecx, 1, 0xF0, edx, i8, 7, 0x38, 0x94, 664 0x08, 0xF0, 0x00, 0x00, 0x00); 665 666 #undef TestAddrBaseScaledIndexReg 667 #undef TestAddrBaseScaledIndexImm 668 #undef TestRegAddrBaseScaledIndex 669 #undef TestRegAddrScaledIndex 670 #undef TestRegAddrBase 671 #undef TestRegAbsoluteAddr 672 #undef TestRegImm 673 #undef TestRegReg 674 } 675 676 TEST_F(AssemblerX8632Test, ScratchpadGettersAndSetters) { 677 const uint32_t S0 = allocateDword(); 678 const uint32_t S1 = allocateDword(); 679 const uint32_t S2 = allocateDword(); 680 const uint32_t S3 = allocateDword(); 681 AssembledTest test = assemble(); 682 test.setDwordTo(S0, 0xBEEF0000u); 683 test.setDwordTo(S1, 0xDEADu); 684 test.setDwordTo(S2, 0x20406080u); 685 ASSERT_EQ(0xBEEF0000u, test.contentsOfDword(S0)); 686 ASSERT_EQ(0xDEADu, test.contentsOfDword(S1)); 687 ASSERT_EQ(0x20406080u, test.contentsOfDword(S2)); 688 ASSERT_EQ(0xDEADBEEF0000ull, test.contentsOfQword(S0)); 689 ASSERT_EQ(0x204060800000DEADull, test.contentsOfQword(S1)); 690 691 test.setQwordTo(S1, 0x1234567890ABCDEFull); 692 ASSERT_EQ(0x1234567890ABCDEFull, test.contentsOfQword(S1)); 693 test.setDwordTo(S0, 0xBEEF0000u); 694 ASSERT_EQ(0x90ABCDEFull, test.contentsOfDword(S1)); 695 ASSERT_EQ(0x12345678ull, test.contentsOfDword(S2)); 696 697 test.setDwordTo(S0, 1.0f); 698 ASSERT_FLOAT_EQ(1.0f, test.contentsOfDword<float>(S0)); 699 test.setQwordTo(S0, 3.14); 700 ASSERT_DOUBLE_EQ(3.14, test.contentsOfQword<double>(S0)); 701 702 test.setDqwordTo(S0, Dqword(1.0f, 2.0f, 3.0f, 4.0f)); 703 ASSERT_EQ(Dqword(1.0f, 2.0f, 3.0f, 4.0f), test.contentsOfDqword(S0)); 704 EXPECT_FLOAT_EQ(1.0f, test.contentsOfDword<float>(S0)); 705 EXPECT_FLOAT_EQ(2.0f, test.contentsOfDword<float>(S1)); 706 EXPECT_FLOAT_EQ(3.0f, test.contentsOfDword<float>(S2)); 707 EXPECT_FLOAT_EQ(4.0f, test.contentsOfDword<float>(S3)); 708 } 709 710 } // end of anonymous namespace 711 } // end of namespace Test 712 } // end of namespace X8632 713 } // end of namespace Ice 714