diff options
author | iximeow <me@iximeow.net> | 2022-12-03 14:12:38 -0800 |
---|---|---|
committer | iximeow <git@iximeow.net> | 2022-12-03 15:11:09 -0800 |
commit | 1cda006a87ea266397c1d376e7d2d231d6bbbd30 (patch) | |
tree | 672c208b42f21a3375c051cd5afbf0f3faddae8f /src/protected_mode | |
parent | 635bf0336fe2f654945a23a6b59591866cdb1d2e (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.
Diffstat (limited to 'src/protected_mode')
-rw-r--r-- | src/protected_mode/mod.rs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/protected_mode/mod.rs b/src/protected_mode/mod.rs index 644413f..65da028 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 { |