diff options
| author | iximeow <me@iximeow.net> | 2019-11-30 19:25:23 -0800 | 
|---|---|---|
| committer | iximeow <me@iximeow.net> | 2020-01-12 16:10:13 -0800 | 
| commit | 767c604e2ee47cde4edf72b63d17998ce1767bde (patch) | |
| tree | 2ddebaebd7d9e6ca2961435805f3d5d217c98421 | |
| parent | ccdc601e2a70a0f27891f6db8c9151456d08f05a (diff) | |
add pxor and some others, support mm operands
| -rw-r--r-- | src/lib.rs | 23 | ||||
| -rw-r--r-- | test/test.rs | 25 | 
2 files changed, 30 insertions, 18 deletions
@@ -1133,7 +1133,6 @@ pub enum OperandCode {      Yv_AX,      Yv_Xv,      G_E_q, -    G_E_mm,      G_U_mm,      G_M_q,      E_G_q, @@ -1193,6 +1192,7 @@ pub enum OperandCode {      AL_Xb = 0x68,      AX_AL = 0x69,      AX_Ov = 0x6a, +    G_E_mm = 0x6b,      Eb_Gb = 0x80,      Ev_Gv = 0x81, @@ -1509,7 +1509,7 @@ const OPCODE_660F_MAP: [OpcodeRecord; 256] = [      OpcodeRecord(Interpretation::Instruction(Opcode::Invalid), OperandCode::Nothing),      OpcodeRecord(Interpretation::Instruction(Opcode::Invalid), OperandCode::Nothing),      OpcodeRecord(Interpretation::Instruction(Opcode::Invalid), OperandCode::Nothing), -    OpcodeRecord(Interpretation::Instruction(Opcode::Invalid), OperandCode::Nothing), +    OpcodeRecord(Interpretation::Instruction(Opcode::PXOR), OperandCode::G_E_xmm),  // 0xf0      OpcodeRecord(Interpretation::Instruction(Opcode::Invalid), OperandCode::Nothing),      OpcodeRecord(Interpretation::Instruction(Opcode::Invalid), OperandCode::Nothing), @@ -2234,9 +2234,9 @@ const OPCODE_0F_MAP: [OpcodeRecord; 256] = [      OpcodeRecord(Interpretation::Instruction(Opcode::MAXPS), OperandCode::G_E_xmm),  // 0x60 -    OpcodeRecord(Interpretation::Instruction(Opcode::PUNPCKLBW), OperandCode::Unsupported), -    OpcodeRecord(Interpretation::Instruction(Opcode::PUNPCKLWD), OperandCode::Unsupported), -    OpcodeRecord(Interpretation::Instruction(Opcode::PUNPCKLDQ), OperandCode::Unsupported), +    OpcodeRecord(Interpretation::Instruction(Opcode::PUNPCKLBW), OperandCode::G_E_mm), +    OpcodeRecord(Interpretation::Instruction(Opcode::PUNPCKLWD), OperandCode::G_E_mm), +    OpcodeRecord(Interpretation::Instruction(Opcode::PUNPCKLDQ), OperandCode::G_E_mm),      OpcodeRecord(Interpretation::Instruction(Opcode::PACKSSWB), OperandCode::Unsupported),      OpcodeRecord(Interpretation::Instruction(Opcode::PCMPGTB), OperandCode::Unsupported),      OpcodeRecord(Interpretation::Instruction(Opcode::PCMPGTW), OperandCode::Unsupported), @@ -2394,7 +2394,7 @@ const OPCODE_0F_MAP: [OpcodeRecord; 256] = [      OpcodeRecord(Interpretation::Instruction(Opcode::PADDSB), OperandCode::Unsupported),      OpcodeRecord(Interpretation::Instruction(Opcode::PADDSW), OperandCode::Unsupported),      OpcodeRecord(Interpretation::Instruction(Opcode::PMAXSW), OperandCode::Unsupported), -    OpcodeRecord(Interpretation::Instruction(Opcode::PXOR), OperandCode::Unsupported), +    OpcodeRecord(Interpretation::Instruction(Opcode::PXOR), OperandCode::G_E_mm),  // 0xf0      OpcodeRecord(Interpretation::Instruction(Opcode::Invalid), OperandCode::Nothing),      OpcodeRecord(Interpretation::Instruction(Opcode::PSLLW), OperandCode::Unsupported), @@ -3433,6 +3433,17 @@ pub fn read_operands<T: Iterator<Item=u8>>(mut bytes_iter: T, instruction: &mut              instruction.operands[1] = OperandSpec::RegRRR;              instruction.operand_count = 2;          }, +        OperandCode::G_E_mm => { +            let modrm = read_modrm(&mut bytes_iter, instruction, length)?; +            bytes_read = 1; + +//                println!("mod_bits: {:2b}, r: {:3b}, m: {:3b}", mod_bits, r, m); +            instruction.operands[1] = read_E_xmm(&mut bytes_iter, instruction, modrm, length)?; +            instruction.modrm_rrr = +                RegSpec::from_parts((modrm >> 3) & 7, instruction.prefixes.rex().r(), RegisterBank::MM); +            instruction.operands[0] = OperandSpec::RegRRR; +            instruction.operand_count = 2; +        },          OperandCode::G_E_xmm => {              let modrm = read_modrm(&mut bytes_iter, instruction, length)?;              bytes_read = 1; diff --git a/test/test.rs b/test/test.rs index f3ae928..a08dbec 100644 --- a/test/test.rs +++ b/test/test.rs @@ -142,6 +142,7 @@ fn test_sse() {      test_display(&[0x67, 0x66, 0x4f, 0x0f, 0x28, 0x00], "movapd xmm8, [r8d]");      test_display(&[0x66, 0x0f, 0x29, 0x00], "movapd [rax], xmm0");      test_display(&[0x66, 0x0f, 0xef, 0xc0], "pxor xmm0, xmm0"); +    test_display(&[0x66, 0x4f, 0x0f, 0xef, 0xc0], "pxor xmm8, xmm8");      test_display(&[0xf2, 0x0f, 0x10, 0x0c, 0xc6], "movsd xmm1, [rsi + rax * 8]");      test_display(&[0xf3, 0x0f, 0x10, 0x04, 0x86], "movss xmm0, [rsi + rax * 4]");      test_display(&[0xf2, 0x0f, 0x59, 0xc8], "mulsd xmm1, xmm0"); @@ -328,18 +329,18 @@ fn prefixed_0f() {      test_display(&[0x0f, 0x35], "sysexit");      test_invalid(&[0x0f, 0x36]);      test_display(&[0x0f, 0x37], "getsec"); -    test_display(&[0x0f, 0x60, 0x00], "punpcklbw mm0, qword [rax]"); -    test_display(&[0x0f, 0x61, 0x00], "punpcklwd mm0, qword [rax]"); -    test_display(&[0x0f, 0x62, 0x00], "punpckldq mm0, qword [rax]"); -    test_display(&[0x0f, 0x63, 0x00], "packsswb mm0, qword [rax]"); -    test_display(&[0x0f, 0x64, 0x00], "pcmpgtb mm0, qword [rax]"); -    test_display(&[0x0f, 0x65, 0x00], "pcmpgtw mm0, qword [rax]"); -    test_display(&[0x0f, 0x66, 0x00], "pcmpgtd mm0, qword [rax]"); -    test_display(&[0x0f, 0x67, 0x00], "packuswb mm0, qword [rax]"); -    test_display(&[0x0f, 0x68, 0x00], "punpckhbw mm0, qword [rax]"); -    test_display(&[0x0f, 0x69, 0x00], "punpckhbd mm0, qword [rax]"); -    test_display(&[0x0f, 0x6a, 0x00], "punpckhdq mm0, qword [rax]"); -    test_display(&[0x0f, 0x6b, 0x00], "packssdw mm0, qword [rax]"); +    test_display(&[0x0f, 0x60, 0x00], "punpcklbw mm0, [rax]"); +    test_display(&[0x0f, 0x61, 0x00], "punpcklwd mm0, [rax]"); +    test_display(&[0x0f, 0x62, 0x00], "punpckldq mm0, [rax]"); +    test_display(&[0x0f, 0x63, 0x00], "packsswb mm0, [rax]"); +    test_display(&[0x0f, 0x64, 0x00], "pcmpgtb mm0, [rax]"); +    test_display(&[0x0f, 0x65, 0x00], "pcmpgtw mm0, [rax]"); +    test_display(&[0x0f, 0x66, 0x00], "pcmpgtd mm0, [rax]"); +    test_display(&[0x0f, 0x67, 0x00], "packuswb mm0, [rax]"); +    test_display(&[0x0f, 0x68, 0x00], "punpckhbw mm0, [rax]"); +    test_display(&[0x0f, 0x69, 0x00], "punpckhbd mm0, [rax]"); +    test_display(&[0x0f, 0x6a, 0x00], "punpckhdq mm0, [rax]"); +    test_display(&[0x0f, 0x6b, 0x00], "packssdw mm0, [rax]");      test_invalid(&[0x0f, 0x6c]);      test_invalid(&[0x0f, 0x6d]);      test_display(&[0x0f, 0x6e], "movd mm0, dword [rax]");  | 
