summaryrefslogtreecommitdiff
path: root/arch/msp430/src/register.rs
diff options
context:
space:
mode:
Diffstat (limited to 'arch/msp430/src/register.rs')
-rw-r--r--arch/msp430/src/register.rs25
1 files changed, 18 insertions, 7 deletions
diff --git a/arch/msp430/src/register.rs b/arch/msp430/src/register.rs
index 20a5dff8..0886e537 100644
--- a/arch/msp430/src/register.rs
+++ b/arch/msp430/src/register.rs
@@ -1,6 +1,7 @@
use binaryninja::architecture;
-use binaryninja::architecture::ImplicitRegisterExtend;
+use binaryninja::architecture::{ImplicitRegisterExtend, RegisterId};
+use binaryninja::low_level_il::LowLevelILRegister;
use std::borrow::Cow;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@@ -23,15 +24,15 @@ pub enum Register {
R15,
}
-impl TryFrom<u32> for Register {
+impl TryFrom<RegisterId> for Register {
type Error = ();
- fn try_from(id: u32) -> Result<Self, Self::Error> {
+ fn try_from(id: RegisterId) -> Result<Self, Self::Error> {
// TODO: we should return separate errors if the id is between 0x7fff_ffff and 0xffff_ffff
// vs outside of that range. Temporary registers have have the high bit set which we
// shouldn't get, unless there is a bug in core. An id that isn't within that range but we
// don't handle is a bug in the architecture.
- match id {
+ match id.0 {
0 => Ok(Self::Pc),
1 => Ok(Self::Sp),
2 => Ok(Self::Sr),
@@ -53,6 +54,15 @@ impl TryFrom<u32> for Register {
}
}
+// TODO: Get rid of this and lift all u32 vals to a proper register id.
+impl TryFrom<u32> for Register {
+ type Error = ();
+
+ fn try_from(id: u32) -> Result<Self, Self::Error> {
+ Register::try_from(RegisterId(id))
+ }
+}
+
impl architecture::Register for Register {
type InfoType = Self;
@@ -81,7 +91,7 @@ impl architecture::Register for Register {
*self
}
- fn id(&self) -> u32 {
+ fn id(&self) -> RegisterId {
match self {
Self::Pc => 0,
Self::Sp => 1,
@@ -100,6 +110,7 @@ impl architecture::Register for Register {
Self::R14 => 14,
Self::R15 => 15,
}
+ .into()
}
}
@@ -123,8 +134,8 @@ impl architecture::RegisterInfo for Register {
}
}
-impl From<Register> for binaryninja::llil::Register<Register> {
+impl From<Register> for LowLevelILRegister<Register> {
fn from(register: Register) -> Self {
- binaryninja::llil::Register::ArchReg(register)
+ LowLevelILRegister::ArchReg(register)
}
}