Skip to content

Commit

Permalink
Merge pull request #532 from nbaksalyar/convert-string-into-register
Browse files Browse the repository at this point in the history
Add a name_to_register routine to convert names into register numbers
  • Loading branch information
philipc authored Aug 29, 2020
2 parents e659d6e + 2421d01 commit e046ca5
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: &str) -> Option<Register> {
match value {
$(
$disp => Some(Self::$name),
)+
_ => return None,
}
}
}
};
}
Expand Down

0 comments on commit e046ca5

Please sign in to comment.