diff options
Diffstat (limited to 'test/protected_mode')
| -rw-r--r-- | test/protected_mode/mod.rs | 34 | 
1 files changed, 34 insertions, 0 deletions
diff --git a/test/protected_mode/mod.rs b/test/protected_mode/mod.rs index 84448ef..dd0a51f 100644 --- a/test/protected_mode/mod.rs +++ b/test/protected_mode/mod.rs @@ -50,6 +50,40 @@ fn test_display_under(decoder: &InstDecoder, data: &[u8], expected: &'static str  }  #[test] +fn test_modrm_decode() { +    // just modrm +    test_display(&[0x33, 0x08], "xor ecx, [eax]"); +    test_display(&[0x33, 0x20], "xor esp, [eax]"); +    test_display(&[0x33, 0x05, 0x78, 0x56, 0x34, 0x12], "xor eax, [0x12345678]"); +    test_display(&[0x33, 0x41, 0x23], "xor eax, [ecx + 0x23]"); +    test_display(&[0x33, 0x81, 0x23, 0x01, 0x65, 0x43], "xor eax, [ecx + 0x43650123]"); +    test_display(&[0x33, 0xc1], "xor eax, ecx"); + +    // sib +    test_display(&[0x33, 0x04, 0x0a], "xor eax, [edx + ecx * 1]"); +    test_display(&[0x33, 0x04, 0x4a], "xor eax, [edx + ecx * 2]"); +    test_display(&[0x33, 0x04, 0x8a], "xor eax, [edx + ecx * 4]"); +    test_display(&[0x33, 0x04, 0xca], "xor eax, [edx + ecx * 8]"); +    test_display(&[0x33, 0x04, 0x20], "xor eax, [eax]"); +    test_display(&[0x33, 0x04, 0x60], "xor eax, [eax]"); +    test_display(&[0x33, 0x04, 0xa0], "xor eax, [eax]"); +    test_display(&[0x33, 0x04, 0xe0], "xor eax, [eax]"); +    test_display(&[0x33, 0x04, 0x25, 0x11, 0x22, 0x33, 0x44], "xor eax, [0x44332211]"); + +    test_display(&[0x33, 0x44, 0x65, 0x11], "xor eax, [ebp + 0x11]"); +    test_display(&[0x33, 0x84, 0xa5, 0x11, 0x22, 0x33, 0x44], "xor eax, [ebp + 0x44332211]"); +    test_display(&[0x33, 0x04, 0xe5, 0x11, 0x22, 0x33, 0x44], "xor eax, [0x44332211]"); + +    // specifically sib with base == 0b101 +    // mod bits 00 +    test_display(&[0x33, 0x34, 0x25, 0x20, 0x30, 0x40, 0x50], "xor esi, [0x50403020]"); +    // mod bits 01 +    test_display(&[0x33, 0x74, 0x25, 0x20], "xor esi, [ebp + 0x20]"); +    // mod bits 10 +    test_display(&[0x33, 0xb4, 0x25, 0x20, 0x30, 0x40, 0x50], "xor esi, [ebp + 0x50403020]"); +} + +#[test]  fn test_mmx() {      test_display(&[0x0f, 0xf7, 0xc1], "maskmovq mm0, mm1");      test_invalid(&[0x0f, 0xf7, 0x01]);  | 
