diff options
| author | Melodi <62381002+Melodi17@users.noreply.github.com> | 2026-07-11 09:03:50 +1000 |
|---|---|---|
| committer | Melodi <62381002+Melodi17@users.noreply.github.com> | 2026-07-11 09:03:50 +1000 |
| commit | cb3cc7e94327c57a0f7539d8f8f2406ca4b04037 (patch) | |
| tree | 8e4d241a466e58b438579622a8a1a6e2339489e9 /Q1.core/Arch/Lookups/InstructionSet.cs | |
| parent | 512a5f0efeea46994d01124b409ef51f9b9177a0 (diff) | |
checkpointstability-rewrite
Diffstat (limited to 'Q1.core/Arch/Lookups/InstructionSet.cs')
| -rw-r--r-- | Q1.core/Arch/Lookups/InstructionSet.cs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Q1.core/Arch/Lookups/InstructionSet.cs b/Q1.core/Arch/Lookups/InstructionSet.cs index 2ea20fc..ad81f2e 100644 --- a/Q1.core/Arch/Lookups/InstructionSet.cs +++ b/Q1.core/Arch/Lookups/InstructionSet.cs @@ -20,6 +20,31 @@ public static class InstructionSet throw new ArgumentException($"Instruction '{instructionName}' not found in the instruction set."); } + public static u8 GetOpcodeWithIndex(string instructionName, out u8 index) + { + for (u8 opcode = 0; opcode < InstructionSet.Lookup.Length; opcode++) + { + var group = InstructionSet.Lookup[opcode]; + if (group.Implicit.Name == instructionName || + group.SimpleAddressing.Name == instructionName || + group.ExtendedImplicit.Name == instructionName || + group.ExtendedAddressing.Name == instructionName) + { + if (group.Implicit.Name == instructionName) + index = 0; + else if (group.SimpleAddressing.Name == instructionName) + index = 1; + else if (group.ExtendedImplicit.Name == instructionName) + index = 2; + else + index = 3; + + return opcode; + } + } + throw new ArgumentException($"Instruction '{instructionName}' not found in the instruction set."); + } + static InstructionSet() { var nop = new ImplicitInstruction { Name = "NOP", Execute = InstructionSet.Nop }; |
