diff options
author | iximeow <me@iximeow.net> | 2021-07-01 21:03:04 -0700 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2021-07-01 23:54:28 -0700 |
commit | 0637f629067c0aa8777466fa8e6e3ac4280356b1 (patch) | |
tree | ac1c78c0a13dd82e6dfea2ab1caa1c63a59ff698 /src/long_mode | |
parent | a781322552d9fb52b7b5e51641f49f12678f682f (diff) |
reorder prefix checks
this measures a bit faster. it doesn't seem like it should be. the rex
prefix checks compile identically but move a lea for a later expression
up and pipelines better?
Diffstat (limited to 'src/long_mode')
-rw-r--r-- | src/long_mode/mod.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs index d04a091..65b1a35 100644 --- a/src/long_mode/mod.rs +++ b/src/long_mode/mod.rs @@ -6980,22 +6980,23 @@ fn read_instr<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_ return Err(DecodeError::TooLong); } let record = OPCODES[b as usize]; - if (b & 0xf0) == 0x40 { + if b >= 0x40 && b < 0x50 { prefixes.rex_from(b); - } else if b == 0x0f { - let b = words.next().ok().ok_or(DecodeError::ExhaustedInput)?; - if b == 0x38 { - let b = words.next().ok().ok_or(DecodeError::ExhaustedInput)?; - break read_0f38_opcode(b, &mut prefixes); - } else if b == 0x3a { - let b = words.next().ok().ok_or(DecodeError::ExhaustedInput)?; - break read_0f3a_opcode(b, &mut prefixes); - } else { - break read_0f_opcode(b, &mut prefixes); - } } else if let Interpretation::Instruction(_) = record.0 { break record; } else { + if b == 0x0f { + let b = words.next().ok().ok_or(DecodeError::ExhaustedInput)?; + if b == 0x38 { + let b = words.next().ok().ok_or(DecodeError::ExhaustedInput)?; + break read_0f38_opcode(b, &mut prefixes); + } else if b == 0x3a { + let b = words.next().ok().ok_or(DecodeError::ExhaustedInput)?; + break read_0f3a_opcode(b, &mut prefixes); + } else { + break read_0f_opcode(b, &mut prefixes); + } + } // some prefix seen after we saw rex, but before the 0f escape or an actual // opcode. so we must forget the rex prefix! // this is to handle sequences like 41660f21cf |