Fix incorrect register calculation in RegBank::unit_by_name
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user