diff options
| author | Melodi <62381002+Melodi17@users.noreply.github.com> | 2026-03-17 23:57:39 +1000 |
|---|---|---|
| committer | Melodi <62381002+Melodi17@users.noreply.github.com> | 2026-03-17 23:57:39 +1000 |
| commit | c528862deca86c606cead1c9d199ff22a6b4ac89 (patch) | |
| tree | a6ae363b24c75f305fb2268ece94d80b9845aaa2 | |
| parent | 327b872ae63402e37df08e98773abc5cf59b0ec8 (diff) | |
chore: Cleanup workspace.xml
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | Q1.core/Arch/ChipLayout.cs | 7 | ||||
| -rw-r--r-- | Q1.core/Arch/InstructionSet.cs | 77 |
3 files changed, 84 insertions, 3 deletions
@@ -2,4 +2,5 @@ bin/ obj/ /packages/ riderModule.iml -/_ReSharper.Caches/
\ No newline at end of file +/_ReSharper.Caches/ +.idea/
\ No newline at end of file diff --git a/Q1.core/Arch/ChipLayout.cs b/Q1.core/Arch/ChipLayout.cs index 8c916f6..2948f9a 100644 --- a/Q1.core/Arch/ChipLayout.cs +++ b/Q1.core/Arch/ChipLayout.cs @@ -3,9 +3,12 @@ namespace Q1.core.Arch; public static class ChipLayout { public const u16 MEMORY_START = 0x0000; - public const u16 MEMORY_SIZE = 0xFF00; // 64KB - 256 bytes reserved for stack + public const u16 MEMORY_SIZE = 0x4000; // 16KB of memory (0x0000 to 0x3FFF) - public const u16 STACK_START = ChipLayout.MEMORY_START; + public const u16 IVT_START = ChipLayout.MEMORY_START; + public const u16 IVT_SIZE = 256; // 256 bytes for 128 interrupt vectors (2 bytes each) + + public const u16 STACK_START = ChipLayout.IVT_START + ChipLayout.IVT_SIZE; public const u16 STACK_SIZE = 256 * 2; // 256 words (512 bytes) public const u16 PROGRAM_START = ChipLayout.MEMORY_START + ChipLayout.STACK_SIZE; diff --git a/Q1.core/Arch/InstructionSet.cs b/Q1.core/Arch/InstructionSet.cs index 68a9b55..f9c20f8 100644 --- a/Q1.core/Arch/InstructionSet.cs +++ b/Q1.core/Arch/InstructionSet.cs @@ -186,6 +186,83 @@ public static class InstructionSet { chip.Dx = (u16)~chip.Dx; } + + private static void And(Chip chip, u8 m1, u8 m2, bool word) + { + u16 value1 = chip.Load(m1, word); + u16 value2 = chip.Load(m2, word); + u16 result = (u16)(value1 & value2); + + chip.Dx = result; + } + + private static void Or(Chip chip, u8 m1, u8 m2, bool word) + { + u16 value1 = chip.Load(m1, word); + u16 value2 = chip.Load(m2, word); + u16 result = (u16)(value1 | value2); + + chip.Dx = result; + } + + private static void Xor(Chip chip, u8 m1, u8 m2, bool word) + { + u16 value1 = chip.Load(m1, word); + u16 value2 = chip.Load(m2, word); + u16 result = (u16)(value1 ^ value2); + + chip.Dx = result; + } + + private static void ShiftLeft(Chip chip, u8 m1, u8 m2, bool word) + { + u16 value = chip.Load(m1, word); + u16 shiftAmount = (u16) (chip.Load(m2, word) & 0xF); // Limit shift to 0-15 + u16 result = (u16) (value << shiftAmount); + + chip.Dx = result; + } + + private static void ShiftRight(Chip chip, u8 m1, u8 m2, bool word) + { + u16 value = chip.Load(m1, word); + u16 shiftAmount = (u16) (chip.Load(m2, word) & 0xF); // Limit shift to 0-15 + u16 result = (u16) (value >> shiftAmount); + + chip.Dx = result; + } + + private static void ShiftPlaceLeft(Chip chip, u8 m1, bool word) + { + u16 value = chip.Load(m1, word); + u16 result = (u16) ((value << 1) | (value >> 15)); // Rotate left + + chip.Dx = result; + } + + private static void ShiftPlaceRight(Chip chip, u8 m1, bool word) + { + u16 value = chip.Load(m1, word); + u16 result = (u16) ((value >> 1) | (value << 15)); // Rotate right + + chip.Dx = result; + } + + private static void ShiftPlaceLeftDx(Chip chip, bool word) + { + u16 value = chip.Dx; + u16 result = (u16) ((value << 1) | (value >> 15)); // Rotate left + + chip.Dx = result; + } + + private static void ShiftPlaceRightDx(Chip chip, bool word) + { + u16 value = chip.Dx; + u16 result = (u16) ((value >> 1) | (value << 15)); // Rotate right + + chip.Dx = result; + } #endregion |
