aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2022-12-03 14:12:38 -0800
committeriximeow <me@iximeow.net>2022-12-03 14:12:38 -0800
commitc549f10115e727a6c0694e1ca59704826910e165 (patch)
treea3b28df742c53fee8a2a370b282ed7fdaf6390eb
parent091f1d66ef853d6339a96e43d71c137ee7d3907a (diff)
apply 2444de11 to 16-bit and 32-bit decoders
these don't need the extra `rex`-supporting index space, so they don't have it.
-rw-r--r--src/protected_mode/mod.rs15
-rw-r--r--src/real_mode/mod.rs15
2 files changed, 18 insertions, 12 deletions
diff --git a/src/protected_mode/mod.rs b/src/protected_mode/mod.rs
index 5457b9d..71ddf37 100644
--- a/src/protected_mode/mod.rs
+++ b/src/protected_mode/mod.rs
@@ -6087,12 +6087,15 @@ fn read_M<
#[inline]
fn width_to_gp_reg_bank(width: u8) -> RegisterBank {
- match width {
- 1 => return RegisterBank::B,
- 2 => return RegisterBank::W,
- 4 => return RegisterBank::D,
- _ => unsafe { unreachable_unchecked(); }
- }
+ let index = width.trailing_zeros();
+
+ const BANK_LUT: [RegisterBank; 3] = [
+ RegisterBank::B,
+ RegisterBank::W,
+ RegisterBank::D,
+ ];
+
+ *BANK_LUT.get(index as usize).unwrap_or_else(|| unsafe { unreachable_unchecked() })
}
fn read_0f_opcode(opcode: u8, prefixes: &mut Prefixes) -> OpcodeRecord {
diff --git a/src/real_mode/mod.rs b/src/real_mode/mod.rs
index 8749ae2..bff00ad 100644
--- a/src/real_mode/mod.rs
+++ b/src/real_mode/mod.rs
@@ -6089,12 +6089,15 @@ fn read_M<
#[inline]
fn width_to_gp_reg_bank(width: u8) -> RegisterBank {
- match width {
- 1 => return RegisterBank::B,
- 2 => return RegisterBank::W,
- 4 => return RegisterBank::D,
- _ => unsafe { unreachable_unchecked(); }
- }
+ let index = width.trailing_zeros();
+
+ const BANK_LUT: [RegisterBank; 3] = [
+ RegisterBank::B,
+ RegisterBank::W,
+ RegisterBank::D,
+ ];
+
+ *BANK_LUT.get(index as usize).unwrap_or_else(|| unsafe { unreachable_unchecked() })
}
fn read_0f_opcode(opcode: u8, prefixes: &mut Prefixes) -> OpcodeRecord {