Skip to content

Commit

Permalink
Add a name_to_register routine to convert names into register numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaksalyar committed Aug 29, 2020
1 parent e659d6e commit 50438cd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ macro_rules! registers {
_ => return None,
}
}

/// Converts a register name into a register number.
pub fn name_to_register(value: &'static str) -> Option<Register> {
match value {
$(
$disp => Some(Self::$name),
)+
_ => return None,
}
}
}
};
}
Expand Down

0 comments on commit 50438cd

Please sign in to comment.