aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2021-07-03 16:45:53 -0700
committeriximeow <me@iximeow.net>2021-07-03 16:45:53 -0700
commit3975ace417ccd0a8381b93e91e3c8b4be9640636 (patch)
treecca085acc516d0ad4cb80d7165a0433e0de53c5f
parent3a1de246641e14e51dc138120d67842448c2bf21 (diff)
more carefully test mmx operand sizes
-rw-r--r--src/long_mode/mod.rs6
-rw-r--r--src/protected_mode/mod.rs6
-rw-r--r--test/long_mode/mod.rs16
-rw-r--r--test/protected_mode/mod.rs20
4 files changed, 41 insertions, 7 deletions
diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs
index 2cda6e4..4955b7c 100644
--- a/src/long_mode/mod.rs
+++ b/src/long_mode/mod.rs
@@ -7951,10 +7951,10 @@ fn unlikely_operands<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as y
instruction.regs[1].bank = RegisterBank::MM;
instruction.regs[1].num &= 0b111;
} else {
- if [Opcode::PACKSSWB, Opcode::PCMPGTB, Opcode::PCMPGTW, Opcode::PCMPGTD, Opcode::PACKUSWB, Opcode::PUNPCKHBW, Opcode::PUNPCKHWD, Opcode::PUNPCKHDQ, Opcode::PACKSSDW, Opcode::PSRLW, Opcode::PMULHW, Opcode::PSHUFB, Opcode::PHADDW, Opcode::PHADDD, Opcode::PHADDSW, Opcode::PMADDUBSW, Opcode::PHSUBW, Opcode::PHSUBD, Opcode::PHSUBSW, Opcode::PSIGNB, Opcode::PSIGNW, Opcode::PSIGND, Opcode::PMULHRSW, Opcode::PABSB, Opcode::PABSW, Opcode::PABSD].contains(&instruction.opcode) {
- instruction.mem_size = 8;
- } else {
+ if [Opcode::PUNPCKLBW, Opcode::PUNPCKLWD, Opcode::PUNPCKLDQ].contains(&instruction.opcode) {
instruction.mem_size = 4;
+ } else {
+ instruction.mem_size = 8;
}
}
},
diff --git a/src/protected_mode/mod.rs b/src/protected_mode/mod.rs
index 5e19676..b191989 100644
--- a/src/protected_mode/mod.rs
+++ b/src/protected_mode/mod.rs
@@ -7850,10 +7850,10 @@ fn unlikely_operands<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as y
instruction.regs[1].bank = RegisterBank::MM;
instruction.regs[1].num &= 0b111;
} else {
- if [Opcode::PACKSSWB, Opcode::PCMPGTB, Opcode::PCMPGTW, Opcode::PCMPGTD, Opcode::PACKUSWB, Opcode::PUNPCKHBW, Opcode::PUNPCKHWD, Opcode::PUNPCKHDQ, Opcode::PACKSSDW, Opcode::PSRLW, Opcode::PMULHW, Opcode::PSHUFB, Opcode::PHADDW, Opcode::PHADDD, Opcode::PHADDSW, Opcode::PMADDUBSW, Opcode::PHSUBW, Opcode::PHSUBD, Opcode::PHSUBSW, Opcode::PSIGNB, Opcode::PSIGNW, Opcode::PSIGND, Opcode::PMULHRSW, Opcode::PABSB, Opcode::PABSW, Opcode::PABSD].contains(&instruction.opcode) {
- instruction.mem_size = 8;
- } else {
+ if [Opcode::PUNPCKLBW, Opcode::PUNPCKLWD, Opcode::PUNPCKLDQ].contains(&instruction.opcode) {
instruction.mem_size = 4;
+ } else {
+ instruction.mem_size = 8;
}
}
instruction.operand_count = 2;
diff --git a/test/long_mode/mod.rs b/test/long_mode/mod.rs
index f9a3fef..d33a4ec 100644
--- a/test/long_mode/mod.rs
+++ b/test/long_mode/mod.rs
@@ -205,6 +205,20 @@ fn test_mmx() {
test_display(&[0x0f, 0xfc, 0xc2], "paddb mm0, mm2");
test_display(&[0x0f, 0xfd, 0xc2], "paddw mm0, mm2");
test_display(&[0x0f, 0xfe, 0xc2], "paddd mm0, mm2");
+
+ test_display(&[0x0f, 0xf1, 0x02], "psllw mm0, qword [rdx]");
+ test_display(&[0x0f, 0xf2, 0x02], "pslld mm0, qword [rdx]");
+ test_display(&[0x0f, 0xf3, 0x02], "psllq mm0, qword [rdx]");
+ test_display(&[0x0f, 0xf4, 0x02], "pmuludq mm0, qword [rdx]");
+ test_display(&[0x0f, 0xf5, 0x02], "pmaddwd mm0, qword [rdx]");
+ test_display(&[0x0f, 0xf6, 0x02], "psadbw mm0, qword [rdx]");
+ test_display(&[0x0f, 0xf8, 0x02], "psubb mm0, qword [rdx]");
+ test_display(&[0x0f, 0xf9, 0x02], "psubw mm0, qword [rdx]");
+ test_display(&[0x0f, 0xfa, 0x02], "psubd mm0, qword [rdx]");
+ test_display(&[0x0f, 0xfb, 0x02], "psubq mm0, qword [rdx]");
+ test_display(&[0x0f, 0xfc, 0x02], "paddb mm0, qword [rdx]");
+ test_display(&[0x0f, 0xfd, 0x02], "paddw mm0, qword [rdx]");
+ test_display(&[0x0f, 0xfe, 0x02], "paddd mm0, qword [rdx]");
}
#[test]
@@ -3147,6 +3161,7 @@ fn test_x87() {
#[test]
fn test_mishegos_finds() {
+ test_display(&[0x0f, 0xfc, 0xaf, 0x40, 0x38, 0x25, 0xbf], "paddb mm5, qword [rdi - 0x40dac7c0]");
test_invalid(&[0xc5, 0x4d, 0x16, 0x0f]);
test_invalid(&[0xf3, 0x67, 0x0f, 0x3a, 0xf0, 0xfb, 0xb4]);
// XOP is still not supported
@@ -3156,7 +3171,6 @@ fn test_mishegos_finds() {
test_display(&[0x62, 0x42, 0xd5, 0x9d, 0x97, 0xf6], "vfmsubadd132pd zmm30{k5}{z}{rne-sae}, zmm5, zmm14");
test_invalid(&[0x67, 0x66, 0x42, 0x0f, 0x01, 0xfe]);
test_display(&[0x62, 0x52, 0x05, 0xff, 0xad, 0xfd], "vfnmadd213ss xmm15{k7}{z}{rz-sae}, xmm15, xmm13");
- test_display(&[0x26, 0xf3, 0x0f, 0x3a, 0xf0, 0xc0, 0x24], "hreset 0x24");
test_invalid(&[0xf2, 0x67, 0x4a, 0x0f, 0x01, 0xd6]);
test_invalid(&[0x36, 0x64, 0x62, 0x33, 0x39, 0xef, 0x55, 0xc2, 0x68]);
test_invalid(&[0x36, 0x66, 0x67, 0xf3, 0x0f, 0x01, 0xce]);
diff --git a/test/protected_mode/mod.rs b/test/protected_mode/mod.rs
index 04a5676..c9afc0b 100644
--- a/test/protected_mode/mod.rs
+++ b/test/protected_mode/mod.rs
@@ -156,8 +156,23 @@ fn test_mmx() {
test_display(&[0x0f, 0xfa, 0xc2], "psubd mm0, mm2");
test_display(&[0x0f, 0xfb, 0xc2], "psubq mm0, mm2");
test_display(&[0x0f, 0xfc, 0xc2], "paddb mm0, mm2");
+ test_display(&[0x0f, 0xfc, 0x02], "paddb mm0, qword [edx]");
test_display(&[0x0f, 0xfd, 0xc2], "paddw mm0, mm2");
test_display(&[0x0f, 0xfe, 0xc2], "paddd mm0, mm2");
+
+ test_display(&[0x0f, 0xf1, 0x02], "psllw mm0, qword [edx]");
+ test_display(&[0x0f, 0xf2, 0x02], "pslld mm0, qword [edx]");
+ test_display(&[0x0f, 0xf3, 0x02], "psllq mm0, qword [edx]");
+ test_display(&[0x0f, 0xf4, 0x02], "pmuludq mm0, qword [edx]");
+ test_display(&[0x0f, 0xf5, 0x02], "pmaddwd mm0, qword [edx]");
+ test_display(&[0x0f, 0xf6, 0x02], "psadbw mm0, qword [edx]");
+ test_display(&[0x0f, 0xf8, 0x02], "psubb mm0, qword [edx]");
+ test_display(&[0x0f, 0xf9, 0x02], "psubw mm0, qword [edx]");
+ test_display(&[0x0f, 0xfa, 0x02], "psubd mm0, qword [edx]");
+ test_display(&[0x0f, 0xfb, 0x02], "psubq mm0, qword [edx]");
+ test_display(&[0x0f, 0xfc, 0x02], "paddb mm0, qword [edx]");
+ test_display(&[0x0f, 0xfd, 0x02], "paddw mm0, qword [edx]");
+ test_display(&[0x0f, 0xfe, 0x02], "paddd mm0, qword [edx]");
}
#[test]
@@ -2864,6 +2879,11 @@ fn test_x87() {
#[test]
fn test_mishegos_finds() {
+ test_display(&[0x0f, 0xfc, 0xaf, 0x40, 0x38, 0x25, 0xbf], "paddb mm5, qword [edi - 0x40dac7c0]");
+ test_invalid(&[0xf3, 0x67, 0x0f, 0x3a, 0xf0, 0xfb, 0xb4]);
+ test_display(&[0x65, 0x66, 0x0f, 0x01, 0xdc], "stgi");
+ test_display(&[0x66, 0x0f, 0x01, 0xd8], "vmrun eax");
+ test_invalid(&[0x2e, 0x2e, 0xf2, 0x36, 0x0f, 0xb2, 0xdb, 0x42, 0xd6, 0xa3, 0x16]);
test_display(&[0x65, 0x67, 0x65, 0x65, 0x0f, 0x0e], "femms");
test_display(&[0x26, 0x66, 0x67, 0x0f, 0x38, 0xdf, 0xe4], "aesdeclast xmm4, xmm4");
test_display(&[0x65, 0x66, 0x66, 0x64, 0x0f, 0x38, 0xdb, 0x0f], "aesimc xmm1, xmmword fs:[edi]");