From cb3cc7e94327c57a0f7539d8f8f2406ca4b04037 Mon Sep 17 00:00:00 2001 From: Melodi <62381002+Melodi17@users.noreply.github.com> Date: Sat, 11 Jul 2026 09:03:50 +1000 Subject: checkpoint --- Q1.core/Arch/Constants/ChipRegisters.cs | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'Q1.core/Arch/Constants') diff --git a/Q1.core/Arch/Constants/ChipRegisters.cs b/Q1.core/Arch/Constants/ChipRegisters.cs index 042ce32..40caf6a 100644 --- a/Q1.core/Arch/Constants/ChipRegisters.cs +++ b/Q1.core/Arch/Constants/ChipRegisters.cs @@ -16,4 +16,40 @@ public static class ChipRegisters public const u8 PC = 0x4C; public const u8 SP = 0x4D; + + public static u8? GetRegisterIndex(string name) + { + return name switch + { + "AX" => AX, + "AH" => AH, + "AL" => AL, + "DX" => DX, + "DH" => DH, + "DL" => DL, + "LX" => LX, + "PC" => PC, + "SP" => SP, + _ when name.StartsWith("V") && byte.TryParse(name[1..], out u8 index) && index < GENERIC_REGISTER_COUNT => index, + _ => null + }; + } + + public static string? GetRegisterName(u8 index) + { + return index switch + { + AX => "AX", + AH => "AH", + AL => "AL", + DX => "DX", + DH => "DH", + DL => "DL", + LX => "LX", + PC => "PC", + SP => "SP", + _ when index < GENERIC_REGISTER_COUNT => $"V{index}", + _ => null + }; + } } \ No newline at end of file -- cgit v1.3.1