Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions fuguex-concrete/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ log = "0.4"
parking_lot = "0.11"
rand = { version = "0.8", features = ["small_rng"] }
thiserror = "1"
serde_any = "0.5"
ux = "0.1"
10 changes: 9 additions & 1 deletion fuguex-concrete/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ use fuguex_microx::ViolationSource;

use fuguex_state::pcode::{self, PCodeState};
use fuguex_state::pcode::{
MAX_POINTER_SIZE, POINTER_16_SIZE, POINTER_32_SIZE, POINTER_64_SIZE, POINTER_8_SIZE,
MAX_POINTER_SIZE, POINTER_16_SIZE, POINTER_32_SIZE, POINTER_64_SIZE, POINTER_8_SIZE, POINTER_20_SIZE
};
use fuguex_state::register::ReturnLocation;
use fuguex_state::traits::State;

use thiserror::Error;
use ux::u24;

#[derive(Debug, Error)]
pub enum Error {
Expand Down Expand Up @@ -582,6 +583,10 @@ impl<O: Order, R: Clone + Default + 'static, const OPERAND_SIZE: usize>
self.read_operand_with(pointer, &mut buf[..psize], source, |buf| {
u8::from_bytes::<O>(buf) as u64
})?
} else if psize == POINTER_20_SIZE {
self.read_operand_with(pointer, &mut buf[..psize], source, |buf| {
u64::from(ux::u24::from_bytes::<O>(buf))
})?
} else {
return Err(Error::UnsupportedAddressSize(pointer.size()));
};
Expand Down Expand Up @@ -613,6 +618,9 @@ impl<O: Order, R: Clone + Default + 'static, const OPERAND_SIZE: usize>
} else if psize == POINTER_8_SIZE {
u8::from(address).into_bytes::<O>(&mut buf[..psize]);
self.write_operand(pointer, &buf[..psize])
} else if psize == POINTER_20_SIZE {
u24::new(u32::from(address)).into_bytes::<O>(&mut buf[..psize]);
self.write_operand(pointer, &buf[..psize])
} else {
Err(Error::UnsupportedAddressSize(psize))
}
Expand Down
3 changes: 3 additions & 0 deletions fuguex-state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ intervals = { version = "0.1", registry = "fugue" }
log = "0.4"
paste = "1"
thiserror = "1"
serde = "1"
ux = "0.1"
ustr = "0.8"
# serde = { version = "1", features = ["derive"], optional = true }
11 changes: 11 additions & 0 deletions fuguex-state/src/pcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use fugue::ir::il::pcode::Operand;
use fugue::ir::{Address, AddressSpace, Translator};

use thiserror::Error;
use ux::u24;

use crate::paged::{self, PagedState};
use crate::register::{self, RegisterState};
Expand All @@ -18,6 +19,7 @@ use crate::traits::{FromStateValues, IntoStateValues};

pub const POINTER_8_SIZE: usize = 1;
pub const POINTER_16_SIZE: usize = 2;
pub const POINTER_20_SIZE: usize = 3;
pub const POINTER_32_SIZE: usize = 4;
pub const POINTER_64_SIZE: usize = 8;
pub const MAX_POINTER_SIZE: usize = POINTER_64_SIZE;
Expand Down Expand Up @@ -228,6 +230,11 @@ impl<O: Order> PCodeState<u8, O> {
buf[..size].copy_from_slice(values);
u8::from_bytes::<O>(values) as u64
})
} else if size == POINTER_20_SIZE {
self.with_operand_values(operand, |values| {
buf[..size].copy_from_slice(values);
u64::from(u24::from_bytes::<O>(values))
})
} else {
return Err(Error::UnsupportedAddressSize(size))
}?;
Expand Down Expand Up @@ -267,6 +274,10 @@ impl<O: Order> PCodeState<u8, O> {
self.with_operand_values_mut(operand, |values| {
u8::from(address).into_bytes::<O>(values)
})
} else if size == POINTER_20_SIZE {
self.with_operand_values_mut(operand, |values| {
u24::new(u32::from(address)).into_bytes::<O>(values)
})
} else {
return Err(Error::UnsupportedAddressSize(size))
}?;
Expand Down
7 changes: 4 additions & 3 deletions fuguex-state/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use fugue::bv::BitVec;
use fugue::bytes::Order;
use fugue::bytes::traits::ByteCast;

use fugue::ir::Address;

use fugue::db::Endian;
use fugue::ir::address::IntoAddress;
use ux::u24;
use paste::paste;

pub use fuguex_state_derive::AsState;
Expand Down Expand Up @@ -56,7 +57,7 @@ macro_rules! impls_for {
};
}

impls_for![bool, i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize];
impls_for![bool, i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize, u24];

impl FromStateValues<u8> for BitVec {
#[inline(always)]
Expand Down