diff options
Diffstat (limited to 'Q1.core/Arch/Chip.cs')
| -rw-r--r-- | Q1.core/Arch/Chip.cs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Q1.core/Arch/Chip.cs b/Q1.core/Arch/Chip.cs index af131dd..69a0877 100644 --- a/Q1.core/Arch/Chip.cs +++ b/Q1.core/Arch/Chip.cs @@ -140,4 +140,13 @@ public class Chip else throw new InvalidOperationException($"Invalid register index: {index}"); } + public void Interrupt(u16 code) + { + if (code >= ChipLayout.IVT_COUNT) + throw new InvalidOperationException($"Invalid interrupt code: {code}"); + + this.Push(this.Pc); + u16 interruptVectorAddress = (u16) (ChipLayout.IVT_START + code * 2); + this.Pc = this.Bus.ReadWord(interruptVectorAddress); + } }
\ No newline at end of file |
