Fix incorrect register calculation in RegBank::unit_by_name

This commit is contained in:
Andrew Brown
2020-02-14 13:24:13 -08:00
parent 2c41648471
commit 518c7526d2

View File

@@ -57,12 +57,12 @@ impl RegBank {
// Ultimate try: try to parse a number and use this in the array, eg r15 on x86. // Ultimate try: try to parse a number and use this in the array, eg r15 on x86.
if let Ok(as_num) = name_without_prefix.parse::<u8>() { if let Ok(as_num) = name_without_prefix.parse::<u8>() {
assert!( assert!(
(as_num - self.first_unit) < self.units, as_num < self.units,
"trying to get {}, but bank only has {} registers!", "trying to get {}, but bank only has {} registers!",
name, name,
self.units self.units
); );
(as_num - self.first_unit) as usize as_num as usize
} else { } else {
panic!("invalid register name {}", name); panic!("invalid register name {}", name);
} }