@@ -461,10 +461,10 @@ ReadPrefixes:
461
461
462
462
vexEscapeSeq := make ([]byte , 0 , 2 )
463
463
switch vex {
464
- case 0xC5 :
464
+ case PrefixVEX2 :
465
465
vexEscapeSeq = append (vexEscapeSeq , 0x0f )
466
- case 0xC4 :
467
- vexM := inst .Prefix [vexIndex + 1 ] & 0x1f
466
+ case PrefixVEX3 :
467
+ vexM := inst .Prefix [vexIndex + 1 ] & PrefixVEXM
468
468
switch vexM {
469
469
case 0x01 :
470
470
vexEscapeSeq = append (vexEscapeSeq , 0x0f )
@@ -520,7 +520,7 @@ Decode:
520
520
if rex & PrefixREXR != 0 {
521
521
rexUsed |= PrefixREXR
522
522
regop |= 8
523
- } else if vex != 0 && inst .Prefix [vexIndex + 1 ]& 0x80 == 0 {
523
+ } else if vex != 0 && inst .Prefix [vexIndex + 1 ]& PrefixVEXnotR == 0 {
524
524
regop |= 8
525
525
}
526
526
if addrMode == 16 {
@@ -569,11 +569,11 @@ Decode:
569
569
scale = sib >> 6
570
570
index = (sib >> 3 ) & 07
571
571
base = sib & 07
572
- if rex & PrefixREXB != 0 || vex == 0xC4 && inst .Prefix [vexIndex + 1 ]& 0x20 == 0 {
572
+ if rex & PrefixREXB != 0 || vex == PrefixVEX3 && inst .Prefix [vexIndex + 1 ]& PrefixVEXnotB == 0 {
573
573
rexUsed |= PrefixREXB
574
574
base |= 8
575
575
}
576
- if rex & PrefixREXX != 0 || vex == 0xC4 && inst .Prefix [vexIndex + 1 ]& 0x40 == 0 {
576
+ if rex & PrefixREXX != 0 || vex == PrefixVEX3 && inst .Prefix [vexIndex + 1 ]& PrefixVEXnotX == 0 {
577
577
rexUsed |= PrefixREXX
578
578
index |= 8
579
579
}
@@ -593,7 +593,10 @@ Decode:
593
593
if rex & PrefixREXB != 0 {
594
594
rexUsed |= PrefixREXB
595
595
rm |= 8
596
+ } else if vex == PrefixVEX3 && inst .Prefix [vexIndex + 1 ]& PrefixVEXnotB == 0 {
597
+ rm |= 8
596
598
}
599
+
597
600
if mod == 0 && rm & 7 == 5 || rm & 7 == 4 {
598
601
// base omitted
599
602
} else if mod != 3 {
@@ -861,13 +864,13 @@ Decode:
861
864
}
862
865
863
866
var vexW , vexL , vexP Prefix
864
- if vex == 0xC4 {
865
- vexW = inst .Prefix [vexIndex + 2 ] & 0x80
866
- vexL = inst .Prefix [vexIndex + 2 ] & 0x04
867
- vexP = inst .Prefix [vexIndex + 2 ] & 0x03
867
+ if vex == PrefixVEX3 {
868
+ vexW = inst .Prefix [vexIndex + 2 ] & PrefixVEXW
869
+ vexL = inst .Prefix [vexIndex + 2 ] & PrefixVEXL
870
+ vexP = inst .Prefix [vexIndex + 2 ] & PrefixVEXP
868
871
} else {
869
- vexL = inst .Prefix [vexIndex + 1 ] & 0x04
870
- vexP = inst .Prefix [vexIndex + 1 ] & 0x03
872
+ vexL = inst .Prefix [vexIndex + 1 ] & PrefixVEXL
873
+ vexP = inst .Prefix [vexIndex + 1 ] & PrefixVEXP
871
874
}
872
875
873
876
switch vexFlag {
@@ -902,7 +905,7 @@ Decode:
902
905
903
906
if ok {
904
907
// TODO: bit of a hack, some instructions ignore the L bit
905
- if vexL & 4 == 0 {
908
+ if vexL == 0 {
906
909
dataMode = 128
907
910
} else {
908
911
dataMode = 256
@@ -1197,18 +1200,17 @@ Decode:
1197
1200
base := baseReg [x ]
1198
1201
1199
1202
var vexV Prefix
1200
- if vex == 0xC5 {
1201
- vexV = inst .Prefix [vexIndex + 1 ]
1202
- } else if vex == 0xC4 {
1203
- vexV = inst .Prefix [vexIndex + 2 ]
1204
- } else {
1203
+ switch vex {
1204
+ case PrefixVEX2 :
1205
+ vexV = (inst .Prefix [vexIndex + 1 ] & PrefixVEXnotV ) >> 3
1206
+ case PrefixVEX3 :
1207
+ vexV = (inst .Prefix [vexIndex + 2 ] & PrefixVEXnotV ) >> 3
1208
+ default :
1205
1209
println ("bad vex" , vex )
1206
1210
return Inst {Len : pos }, errInternal
1207
1211
}
1208
1212
1209
- vexV = (vexV & 0x78 ) >> 3
1210
- vexV ^= 0xF
1211
- index := Reg (vexV )
1213
+ index := Reg (vexV ^ 0xf )
1212
1214
1213
1215
inst .Args [narg ] = base + index
1214
1216
narg ++
@@ -1299,10 +1301,6 @@ Decode:
1299
1301
index -= 4
1300
1302
base = SPB
1301
1303
}
1302
- case xArgXmm2M8 , xArgXmm2M16 , xArgXmm2M32 , xArgXmm2M64 , xArgXmm2M128 , xArgYmm2M256 :
1303
- if vex == 0xC4 && inst .Prefix [vexIndex + 1 ]& 0x20 == 0 {
1304
- index += 8
1305
- }
1306
1304
}
1307
1305
inst .Args [narg ] = base + index
1308
1306
}
0 commit comments