aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib.rs8
-rw-r--r--src/long_mode/mod.rs47
-rw-r--r--src/protected_mode/mod.rs47
-rw-r--r--src/real_mode/mod.rs47
4 files changed, 80 insertions, 69 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 43ff634..aea4c91 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -131,6 +131,14 @@ extern crate alloc;
#[macro_use]
mod isa_settings;
+// you'd hope that if Arch: yaxpeax_arch::Arch you could write Arch::Address and only mention the
+// trait if there were ambiguous definitions of Address on different traits. unfortunately:
+// https://github.com/rust-lang/rust/issues/38078
+//
+// these should probably go over to yaxpeax_arch 'cause they show up everywhere.
+type Address<Arch> = <Arch as yaxpeax_arch::Arch>::Address;
+type Word<Arch> = <Arch as yaxpeax_arch::Arch>::Word;
+
pub mod long_mode;
pub use long_mode as amd64;
pub use long_mode::Arch as x86_64;
diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs
index 823221e..5163ba6 100644
--- a/src/long_mode/mod.rs
+++ b/src/long_mode/mod.rs
@@ -5,6 +5,7 @@ mod display;
pub mod uarch;
pub use crate::MemoryAccessSize;
+use crate::{Address, Word};
#[cfg(feature = "fmt")]
pub use self::display::{DisplayStyle, InstructionDisplayer};
@@ -2842,14 +2843,14 @@ impl Default for InstDecoder {
}
impl Decoder<Arch> for InstDecoder {
- fn decode<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(&self, words: &mut T) -> Result<Instruction, <Arch as yaxpeax_arch::Arch>::DecodeError> {
+ fn decode<T: Reader<Address<Arch>, Word<Arch>>>(&self, words: &mut T) -> Result<Instruction, <Arch as yaxpeax_arch::Arch>::DecodeError> {
let mut instr = Instruction::invalid();
self.decode_into(&mut instr, words)?;
Ok(instr)
}
#[inline(always)]
- fn decode_into<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(&self, instr: &mut Instruction, words: &mut T) -> Result<(), <Arch as yaxpeax_arch::Arch>::DecodeError> {
+ fn decode_into<T: Reader<Address<Arch>, Word<Arch>>>(&self, instr: &mut Instruction, words: &mut T) -> Result<(), <Arch as yaxpeax_arch::Arch>::DecodeError> {
self.decode_with_annotation(instr, words, &mut NullSink)
}
}
@@ -2859,7 +2860,7 @@ impl AnnotatingDecoder<Arch> for InstDecoder {
#[inline(always)]
fn decode_with_annotation<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<Self::FieldDescription>
>(&self, instr: &mut Instruction, words: &mut T, sink: &mut S) -> Result<(), <Arch as yaxpeax_arch::Arch>::DecodeError> {
decode_with_annotation(self, instr, words, sink)
@@ -2868,7 +2869,7 @@ impl AnnotatingDecoder<Arch> for InstDecoder {
#[inline(always)]
fn decode_with_annotation<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>
>(decoder: &InstDecoder, instr: &mut Instruction, words: &mut T, sink: &mut S) -> Result<(), <Arch as yaxpeax_arch::Arch>::DecodeError> {
DecodeCtx::new().read_with_annotations(decoder, words, instr, sink)?;
@@ -4677,7 +4678,7 @@ const OPCODES: [OpcodeRecord; 256] = [
#[cfg_attr(feature="profiling", inline(never))]
#[cfg_attr(not(feature="profiling"), inline(always))]
pub(self) fn read_E<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instr: &mut Instruction, modrm: u8, bank: RegisterBank, sink: &mut S) -> Result<OperandSpec, DecodeError> {
if modrm >= 0b11000000 {
@@ -4688,7 +4689,7 @@ pub(self) fn read_E<
}
#[allow(non_snake_case)]
pub(self) fn read_E_st<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result<OperandSpec, DecodeError> {
if modrm >= 0b11000000 {
@@ -4700,7 +4701,7 @@ pub(self) fn read_E_st<
}
#[allow(non_snake_case)]
pub(self) fn read_E_xmm<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result<OperandSpec, DecodeError> {
if modrm >= 0b11000000 {
@@ -4711,7 +4712,7 @@ pub(self) fn read_E_xmm<
}
#[allow(non_snake_case)]
pub(self) fn read_E_ymm<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result<OperandSpec, DecodeError> {
if modrm >= 0b11000000 {
@@ -4722,7 +4723,7 @@ pub(self) fn read_E_ymm<
}
#[allow(non_snake_case)]
pub(self) fn read_E_vex<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instr: &mut Instruction, modrm: u8, bank: RegisterBank, sink: &mut S) -> Result<OperandSpec, DecodeError> {
if modrm >= 0b11000000 {
@@ -4739,7 +4740,7 @@ pub(self) fn read_E_vex<
#[allow(non_snake_case)]
#[inline(always)]
fn read_modrm_reg<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(instr: &mut Instruction, words: &mut T, modrm: u8, reg_bank: RegisterBank, sink: &mut S) -> Result<OperandSpec, DecodeError> {
instr.regs[1] = RegSpec::from_parts(modrm & 7, instr.prefixes.rex_unchecked().b(), reg_bank);
@@ -4754,7 +4755,7 @@ fn read_modrm_reg<
#[inline(always)]
fn read_sib_disp<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(instr: &Instruction, words: &mut T, modrm: u8, sibbyte: u8, sink: &mut S) -> Result<i32, DecodeError> {
let sib_start = words.offset() as u32 * 8 - 8;
@@ -4801,7 +4802,7 @@ fn read_sib_disp<
#[allow(non_snake_case)]
#[inline(always)]
fn read_sib<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result<OperandSpec, DecodeError> {
let modrm_start = words.offset() as u32 * 8 - 8;
@@ -4997,7 +4998,7 @@ fn read_sib<
#[allow(non_snake_case)]
#[inline(always)]
fn read_M<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>
>(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result<OperandSpec, DecodeError> {
let modrm_start = words.offset() as u32 * 8 - 8;
@@ -5250,7 +5251,7 @@ impl fmt::Display for FieldDescription {
#[inline(always)]
fn record_opcode_record_found<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, sink: &mut S, opc: Opcode, code: OperandCode, opc_length: u32) {
let offset = words.offset() as u32;
@@ -5306,7 +5307,7 @@ impl DecodeCtx {
#[cfg_attr(feature="profiling", inline(never))]
fn read_opc_hotpath<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(&mut self, mut b: u8, nextb: &mut u8, record: &mut OpcodeRecord, words: &mut T, instruction: &mut Instruction, sink: &mut S) -> Result<bool, DecodeError> {
if b >= 0x40 && b < 0x50 {
@@ -5364,7 +5365,7 @@ fn read_opc_hotpath<
#[cfg_attr(feature="profiling", inline(never))]
#[cfg_attr(not(feature="profiling"), inline(always))]
fn read_with_annotations<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(mut self, decoder: &InstDecoder, words: &mut T, instruction: &mut Instruction, sink: &mut S) -> Result<(), DecodeError> {
words.mark();
@@ -5527,7 +5528,7 @@ fn read_with_annotations<
#[inline(never)]
fn read_avx_prefixed<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(self, b: u8, words: &mut T, instruction: &mut Instruction, sink: &mut S) -> Result<(), DecodeError> {
if instruction.prefixes.vex_invalid() {
@@ -5583,7 +5584,7 @@ fn read_avx_prefixed<
#[cfg_attr(feature="profiling", inline(never))]
#[cfg_attr(not(feature="profiling"), inline(always))]
fn read_operands<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>
>(&mut self, decoder: &InstDecoder, words: &mut T, instruction: &mut Instruction, operand_code: OperandCode, sink: &mut S) -> Result<(), DecodeError> {
sink.record(
@@ -9196,7 +9197,7 @@ fn read_0f3a_opcode(&mut self, opcode: u8, prefixes: &mut Prefixes) -> Result<Op
}
fn decode_x87<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instruction: &mut Instruction, operand_code: OperandCase, sink: &mut S) -> Result<(), DecodeError> {
sink.record(
@@ -9725,7 +9726,7 @@ fn decode_x87<
}
#[inline(always)]
-fn read_num<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(bytes: &mut T, width: u8) -> Result<u64, DecodeError> {
+fn read_num<T: Reader<Address<Arch>, Word<Arch>>>(bytes: &mut T, width: u8) -> Result<u64, DecodeError> {
match width {
1 => { bytes.next().ok().ok_or(DecodeError::ExhaustedInput).map(|x| x as u64) }
2 => {
@@ -9750,7 +9751,7 @@ fn read_num<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_ar
}
#[inline(always)]
-fn read_imm_signed<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(bytes: &mut T, num_width: u8) -> Result<i64, DecodeError> {
+fn read_imm_signed<T: Reader<Address<Arch>, Word<Arch>>>(bytes: &mut T, num_width: u8) -> Result<i64, DecodeError> {
if num_width == 1 {
Ok(read_num(bytes, 1)? as i8 as i64)
} else if num_width == 2 {
@@ -9762,7 +9763,7 @@ fn read_imm_signed<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yax
}
#[inline]
-fn read_imm_unsigned<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(bytes: &mut T, width: u8) -> Result<u64, DecodeError> {
+fn read_imm_unsigned<T: Reader<Address<Arch>, Word<Arch>>>(bytes: &mut T, width: u8) -> Result<u64, DecodeError> {
read_num(bytes, width)
}
@@ -9793,7 +9794,7 @@ fn bank_from_prefixes_64(interpretation: SizeCode, prefixes: Prefixes) -> Regist
}
#[inline]
-fn read_modrm<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(words: &mut T) -> Result<u8, DecodeError> {
+fn read_modrm<T: Reader<Address<Arch>, Word<Arch>>>(words: &mut T) -> Result<u8, DecodeError> {
words.next().ok().ok_or(DecodeError::ExhaustedInput)
}
diff --git a/src/protected_mode/mod.rs b/src/protected_mode/mod.rs
index 56290d2..615efe6 100644
--- a/src/protected_mode/mod.rs
+++ b/src/protected_mode/mod.rs
@@ -5,6 +5,7 @@ mod display;
pub mod uarch;
pub use crate::MemoryAccessSize;
+use crate::{Address, Word};
#[cfg(feature = "fmt")]
pub use self::display::{DisplayStyle, InstructionDisplayer};
@@ -2756,13 +2757,13 @@ impl Default for InstDecoder {
}
impl Decoder<Arch> for InstDecoder {
- fn decode<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(&self, words: &mut T) -> Result<Instruction, <Arch as yaxpeax_arch::Arch>::DecodeError> {
+ fn decode<T: Reader<Address<Arch>, Word<Arch>>>(&self, words: &mut T) -> Result<Instruction, <Arch as yaxpeax_arch::Arch>::DecodeError> {
let mut instr = Instruction::invalid();
self.decode_into(&mut instr, words)?;
Ok(instr)
}
- fn decode_into<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(&self, instr: &mut Instruction, words: &mut T) -> Result<(), <Arch as yaxpeax_arch::Arch>::DecodeError> {
+ fn decode_into<T: Reader<Address<Arch>, Word<Arch>>>(&self, instr: &mut Instruction, words: &mut T) -> Result<(), <Arch as yaxpeax_arch::Arch>::DecodeError> {
self.decode_with_annotation(instr, words, &mut NullSink)
}
}
@@ -2771,7 +2772,7 @@ impl AnnotatingDecoder<Arch> for InstDecoder {
type FieldDescription = FieldDescription;
fn decode_with_annotation<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<Self::FieldDescription>
>(&self, instr: &mut Instruction, words: &mut T, sink: &mut S) -> Result<(), <Arch as yaxpeax_arch::Arch>::DecodeError> {
decode_with_annotation(self, instr, words, sink)
@@ -2780,7 +2781,7 @@ impl AnnotatingDecoder<Arch> for InstDecoder {
#[inline(always)]
fn decode_with_annotation<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>
>(decoder: &InstDecoder, instr: &mut Instruction, words: &mut T, sink: &mut S) -> Result<(), <Arch as yaxpeax_arch::Arch>::DecodeError> {
DecodeCtx::new().read_with_annotations(decoder, words, instr, sink)?;
@@ -4585,7 +4586,7 @@ const OPCODES: [OpcodeRecord; 256] = [
#[cfg_attr(feature="profiling", inline(never))]
#[cfg_attr(not(feature="profiling"), inline(always))]
pub(self) fn read_E<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instr: &mut Instruction, modrm: u8, bank: RegisterBank, sink: &mut S) -> Result<OperandSpec, DecodeError> {
if modrm >= 0b11000000 {
@@ -4596,7 +4597,7 @@ pub(self) fn read_E<
}
#[allow(non_snake_case)]
pub(self) fn read_E_st<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result<OperandSpec, DecodeError> {
if modrm >= 0b11000000 {
@@ -4608,7 +4609,7 @@ pub(self) fn read_E_st<
}
#[allow(non_snake_case)]
pub(self) fn read_E_xmm<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result<OperandSpec, DecodeError> {
if modrm >= 0b11000000 {
@@ -4619,7 +4620,7 @@ pub(self) fn read_E_xmm<
}
#[allow(non_snake_case)]
pub(self) fn read_E_ymm<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result<OperandSpec, DecodeError> {
if modrm >= 0b11000000 {
@@ -4630,7 +4631,7 @@ pub(self) fn read_E_ymm<
}
#[allow(non_snake_case)]
pub(self) fn read_E_vex<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instr: &mut Instruction, modrm: u8, bank: RegisterBank, sink: &mut S) -> Result<OperandSpec, DecodeError> {
if modrm >= 0b11000000 {
@@ -4647,7 +4648,7 @@ pub(self) fn read_E_vex<
#[allow(non_snake_case)]
#[inline(always)]
fn read_modrm_reg<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(instr: &mut Instruction, words: &mut T, modrm: u8, reg_bank: RegisterBank, sink: &mut S) -> Result<OperandSpec, DecodeError> {
instr.regs[1] = RegSpec::from_parts(modrm & 7, reg_bank);
@@ -4662,7 +4663,7 @@ fn read_modrm_reg<
#[inline(always)]
fn read_sib_disp<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(instr: &Instruction, words: &mut T, modrm: u8, sibbyte: u8, sink: &mut S) -> Result<i32, DecodeError> {
let sib_start = words.offset() as u32 * 8 - 8;
@@ -4709,7 +4710,7 @@ fn read_sib_disp<
#[allow(non_snake_case)]
#[inline(always)]
fn read_sib<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>
>(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result<OperandSpec, DecodeError> {
let modrm_start = words.offset() as u32 * 8 - 8;
@@ -4890,7 +4891,7 @@ fn read_sib<
#[allow(non_snake_case)]
fn read_M_16bit<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>
>(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result<OperandSpec, DecodeError> {
let modrm_start = words.offset() as u32 * 8 - 8;
@@ -5056,7 +5057,7 @@ fn read_M_16bit<
#[allow(non_snake_case)]
fn read_M<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>
>(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result<OperandSpec, DecodeError> {
let modrm_start = words.offset() as u32 * 8 - 8;
@@ -5281,7 +5282,7 @@ impl fmt::Display for FieldDescription {
#[inline(always)]
fn record_opcode_record_found<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, sink: &mut S, opc: Opcode, code: OperandCode, opc_length: u32) {
let offset = words.offset() as u32;
@@ -5323,7 +5324,7 @@ impl DecodeCtx {
#[cfg_attr(feature="profiling", inline(never))]
fn read_opc_hotpath<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(&mut self, mut b: u8, nextb: &mut u8, record: &mut OpcodeRecord, words: &mut T, instruction: &mut Instruction, sink: &mut S) -> Result<bool, DecodeError> {
if b == 0x66 {
@@ -5375,7 +5376,7 @@ fn read_opc_hotpath<
#[cfg_attr(feature="profiling", inline(never))]
#[cfg_attr(not(feature="profiling"), inline(always))]
fn read_with_annotations<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(&mut self, decoder: &InstDecoder, words: &mut T, instruction: &mut Instruction, sink: &mut S) -> Result<(), DecodeError> {
words.mark();
@@ -5537,7 +5538,7 @@ fn read_with_annotations<
#[cfg_attr(feature="profiling", inline(never))]
#[cfg_attr(not(feature="profiling"), inline(always))]
fn read_operands<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>
>(&mut self, decoder: &InstDecoder, words: &mut T, instruction: &mut Instruction, operand_code: OperandCode, sink: &mut S) -> Result<(), DecodeError> {
sink.record(
@@ -9071,7 +9072,7 @@ fn read_0f3a_opcode(&mut self, opcode: u8, prefixes: &mut Prefixes) -> OpcodeRec
}
fn decode_x87<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instruction: &mut Instruction, operand_code: OperandCase, sink: &mut S) -> Result<(), DecodeError> {
sink.record(
@@ -9599,7 +9600,7 @@ fn decode_x87<
Ok(())
}
#[inline]
-fn read_num<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(bytes: &mut T, width: u8) -> Result<u32, DecodeError> {
+fn read_num<T: Reader<Address<Arch>, Word<Arch>>>(bytes: &mut T, width: u8) -> Result<u32, DecodeError> {
match width {
1 => { bytes.next().ok().ok_or(DecodeError::ExhaustedInput).map(|x| x as u32) }
2 => {
@@ -9619,7 +9620,7 @@ fn read_num<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_ar
}
#[inline]
-fn read_imm_signed<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(bytes: &mut T, num_width: u8) -> Result<i32, DecodeError> {
+fn read_imm_signed<T: Reader<Address<Arch>, Word<Arch>>>(bytes: &mut T, num_width: u8) -> Result<i32, DecodeError> {
if num_width == 1 {
Ok(read_num(bytes, 1)? as i8 as i32)
} else if num_width == 2 {
@@ -9630,12 +9631,12 @@ fn read_imm_signed<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yax
}
#[inline]
-fn read_imm_unsigned<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(bytes: &mut T, width: u8) -> Result<u32, DecodeError> {
+fn read_imm_unsigned<T: Reader<Address<Arch>, Word<Arch>>>(bytes: &mut T, width: u8) -> Result<u32, DecodeError> {
read_num(bytes, width)
}
#[inline]
-fn read_modrm<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(words: &mut T) -> Result<u8, DecodeError> {
+fn read_modrm<T: Reader<Address<Arch>, Word<Arch>>>(words: &mut T) -> Result<u8, DecodeError> {
words.next().ok().ok_or(DecodeError::ExhaustedInput)
}
diff --git a/src/real_mode/mod.rs b/src/real_mode/mod.rs
index 1ef76ea..709a301 100644
--- a/src/real_mode/mod.rs
+++ b/src/real_mode/mod.rs
@@ -5,6 +5,7 @@ mod display;
pub mod uarch;
pub use crate::MemoryAccessSize;
+use crate::{Address, Word};
#[cfg(feature = "fmt")]
pub use self::display::{DisplayStyle, InstructionDisplayer};
@@ -2756,13 +2757,13 @@ impl Default for InstDecoder {
}
impl Decoder<Arch> for InstDecoder {
- fn decode<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(&self, words: &mut T) -> Result<Instruction, <Arch as yaxpeax_arch::Arch>::DecodeError> {
+ fn decode<T: Reader<Address<Arch>, Word<Arch>>>(&self, words: &mut T) -> Result<Instruction, <Arch as yaxpeax_arch::Arch>::DecodeError> {
let mut instr = Instruction::invalid();
self.decode_into(&mut instr, words)?;
Ok(instr)
}
- fn decode_into<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(&self, instr: &mut Instruction, words: &mut T) -> Result<(), <Arch as yaxpeax_arch::Arch>::DecodeError> {
+ fn decode_into<T: Reader<Address<Arch>, Word<Arch>>>(&self, instr: &mut Instruction, words: &mut T) -> Result<(), <Arch as yaxpeax_arch::Arch>::DecodeError> {
self.decode_with_annotation(instr, words, &mut NullSink)
}
}
@@ -2771,7 +2772,7 @@ impl AnnotatingDecoder<Arch> for InstDecoder {
type FieldDescription = FieldDescription;
fn decode_with_annotation<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<Self::FieldDescription>
>(&self, instr: &mut Instruction, words: &mut T, sink: &mut S) -> Result<(), <Arch as yaxpeax_arch::Arch>::DecodeError> {
decode_with_annotation(self, instr, words, sink)
@@ -2780,7 +2781,7 @@ impl AnnotatingDecoder<Arch> for InstDecoder {
#[inline(always)]
fn decode_with_annotation<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>
>(decoder: &InstDecoder, instr: &mut Instruction, words: &mut T, sink: &mut S) -> Result<(), <Arch as yaxpeax_arch::Arch>::DecodeError> {
DecodeCtx::new().read_with_annotations(decoder, words, instr, sink)?;
@@ -4585,7 +4586,7 @@ const OPCODES: [OpcodeRecord; 256] = [
#[cfg_attr(feature="profiling", inline(never))]
#[cfg_attr(not(feature="profiling"), inline(always))]
pub(self) fn read_E<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instr: &mut Instruction, modrm: u8, bank: RegisterBank, sink: &mut S) -> Result<OperandSpec, DecodeError> {
if modrm >= 0b11000000 {
@@ -4596,7 +4597,7 @@ pub(self) fn read_E<
}
#[allow(non_snake_case)]
pub(self) fn read_E_st<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result<OperandSpec, DecodeError> {
if modrm >= 0b11000000 {
@@ -4608,7 +4609,7 @@ pub(self) fn read_E_st<
}
#[allow(non_snake_case)]
pub(self) fn read_E_xmm<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result<OperandSpec, DecodeError> {
if modrm >= 0b11000000 {
@@ -4619,7 +4620,7 @@ pub(self) fn read_E_xmm<
}
#[allow(non_snake_case)]
pub(self) fn read_E_ymm<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result<OperandSpec, DecodeError> {
if modrm >= 0b11000000 {
@@ -4630,7 +4631,7 @@ pub(self) fn read_E_ymm<
}
#[allow(non_snake_case)]
pub(self) fn read_E_vex<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instr: &mut Instruction, modrm: u8, bank: RegisterBank, sink: &mut S) -> Result<OperandSpec, DecodeError> {
if modrm >= 0b11000000 {
@@ -4647,7 +4648,7 @@ pub(self) fn read_E_vex<
#[allow(non_snake_case)]
#[inline(always)]
fn read_modrm_reg<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(instr: &mut Instruction, words: &mut T, modrm: u8, reg_bank: RegisterBank, sink: &mut S) -> Result<OperandSpec, DecodeError> {
instr.regs[1] = RegSpec::from_parts(modrm & 7, reg_bank);
@@ -4662,7 +4663,7 @@ fn read_modrm_reg<
#[inline(always)]
fn read_sib_disp<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(instr: &Instruction, words: &mut T, modrm: u8, sibbyte: u8, sink: &mut S) -> Result<i32, DecodeError> {
let sib_start = words.offset() as u32 * 8 - 8;
@@ -4709,7 +4710,7 @@ fn read_sib_disp<
#[allow(non_snake_case)]
#[inline(always)]
fn read_sib<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>
>(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result<OperandSpec, DecodeError> {
let modrm_start = words.offset() as u32 * 8 - 8;
@@ -4890,7 +4891,7 @@ fn read_sib<
#[allow(non_snake_case)]
fn read_M_16bit<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>
>(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result<OperandSpec, DecodeError> {
let modrm_start = words.offset() as u32 * 8 - 8;
@@ -5056,7 +5057,7 @@ fn read_M_16bit<
#[allow(non_snake_case)]
fn read_M<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>
>(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result<OperandSpec, DecodeError> {
let modrm_start = words.offset() as u32 * 8 - 8;
@@ -5282,7 +5283,7 @@ impl fmt::Display for FieldDescription {
#[inline(always)]
fn record_opcode_record_found<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, sink: &mut S, opc: Opcode, code: OperandCode, opc_length: u32) {
let offset = words.offset() as u32;
@@ -5324,7 +5325,7 @@ impl DecodeCtx {
#[cfg_attr(feature="profiling", inline(never))]
fn read_opc_hotpath<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(&mut self, mut b: u8, nextb: &mut u8, record: &mut OpcodeRecord, words: &mut T, instruction: &mut Instruction, sink: &mut S) -> Result<bool, DecodeError> {
if b == 0x66 {
@@ -5376,7 +5377,7 @@ fn read_opc_hotpath<
#[cfg_attr(feature="profiling", inline(never))]
#[cfg_attr(not(feature="profiling"), inline(always))]
fn read_with_annotations<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(mut self, decoder: &InstDecoder, words: &mut T, instruction: &mut Instruction, sink: &mut S) -> Result<(), DecodeError> {
words.mark();
@@ -5538,7 +5539,7 @@ fn read_with_annotations<
#[cfg_attr(feature="profiling", inline(never))]
#[cfg_attr(not(feature="profiling"), inline(always))]
fn read_operands<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>
>(&mut self, decoder: &InstDecoder, words: &mut T, instruction: &mut Instruction, operand_code: OperandCode, sink: &mut S) -> Result<(), DecodeError> {
sink.record(
@@ -9086,7 +9087,7 @@ fn read_0f3a_opcode(&mut self, opcode: u8, prefixes: &mut Prefixes) -> OpcodeRec
}
fn decode_x87<
- T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>,
+ T: Reader<Address<Arch>, Word<Arch>>,
S: DescriptionSink<FieldDescription>,
>(words: &mut T, instruction: &mut Instruction, operand_code: OperandCase, sink: &mut S) -> Result<(), DecodeError> {
sink.record(
@@ -9614,7 +9615,7 @@ fn decode_x87<
Ok(())
}
#[inline]
-fn read_num<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(bytes: &mut T, width: u8) -> Result<u32, DecodeError> {
+fn read_num<T: Reader<Address<Arch>, Word<Arch>>>(bytes: &mut T, width: u8) -> Result<u32, DecodeError> {
match width {
1 => { bytes.next().ok().ok_or(DecodeError::ExhaustedInput).map(|x| x as u32) }
2 => {
@@ -9634,7 +9635,7 @@ fn read_num<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_ar
}
#[inline]
-fn read_imm_signed<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(bytes: &mut T, num_width: u8) -> Result<i32, DecodeError> {
+fn read_imm_signed<T: Reader<Address<Arch>, Word<Arch>>>(bytes: &mut T, num_width: u8) -> Result<i32, DecodeError> {
if num_width == 1 {
Ok(read_num(bytes, 1)? as i8 as i32)
} else if num_width == 2 {
@@ -9645,12 +9646,12 @@ fn read_imm_signed<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yax
}
#[inline]
-fn read_imm_unsigned<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(bytes: &mut T, width: u8) -> Result<u32, DecodeError> {
+fn read_imm_unsigned<T: Reader<Address<Arch>, Word<Arch>>>(bytes: &mut T, width: u8) -> Result<u32, DecodeError> {
read_num(bytes, width)
}
#[inline]
-fn read_modrm<T: Reader<<Arch as yaxpeax_arch::Arch>::Address, <Arch as yaxpeax_arch::Arch>::Word>>(words: &mut T) -> Result<u8, DecodeError> {
+fn read_modrm<T: Reader<Address<Arch>, Word<Arch>>>(words: &mut T) -> Result<u8, DecodeError> {
words.next().ok().ok_or(DecodeError::ExhaustedInput)
}