summaryrefslogtreecommitdiff
path: root/Emulator
diff options
context:
space:
mode:
authorMelodi <62381002+Melodi17@users.noreply.github.com>2025-09-05 10:20:03 +1000
committerMelodi <62381002+Melodi17@users.noreply.github.com>2025-09-05 10:20:03 +1000
commit9e8ba6e00dc4a4137a5187dbe5fe5b1394219735 (patch)
treee5a54706a8a85243fdb0fe0f2ed73fb7b7566bcd /Emulator
parent4ea967c6089bbcaba5d71145546d288e186fba40 (diff)
stuff
Diffstat (limited to 'Emulator')
-rw-r--r--Emulator/Chip/Q1CpuInstructions.cs4
-rw-r--r--Emulator/Program.cs15
2 files changed, 17 insertions, 2 deletions
diff --git a/Emulator/Chip/Q1CpuInstructions.cs b/Emulator/Chip/Q1CpuInstructions.cs
index 72d78e5..0041b25 100644
--- a/Emulator/Chip/Q1CpuInstructions.cs
+++ b/Emulator/Chip/Q1CpuInstructions.cs
@@ -125,14 +125,14 @@ public partial class Q1Cpu
private void Instruction_SHL(u8 m1, u8 m2)
{
u16 v1 = this.Address(m1).read();
- u16 v2 = this.Address(m1).read();
+ u16 v2 = this.Address(m2).read();
u16 shifted = (u16) (v1 << v2);
this.DX = shifted;
}
private void Instruction_SHR(u8 m1, u8 m2)
{
u16 v1 = this.Address(m1).read();
- u16 v2 = this.Address(m1).read();
+ u16 v2 = this.Address(m2).read();
u16 shifted = (u16) (v1 >> v2);
this.DX = shifted;
}
diff --git a/Emulator/Program.cs b/Emulator/Program.cs
index 65bf068..f6fa932 100644
--- a/Emulator/Program.cs
+++ b/Emulator/Program.cs
@@ -64,6 +64,7 @@ public class Program
cpu.Clock();
}
Console.WriteLine($"Exit code: 0x{cpu.V[0]:X4}");
+ MemoryDump(memory, Q1Layout.FreeMemoryStart, (u16) (Q1Layout.Memory.start + Q1Layout.Memory.size - 1));
});
t.IsBackground = true;
t.Start();
@@ -80,4 +81,18 @@ public class Program
Console.WriteLine("Display surface closed. Waiting for CPU thread to finish...");
t.Join();
}
+
+ private static void MemoryDump(RamDevice memory, u16 start, u16 end)
+ {
+ for (u16 addr = start; addr <= end; addr += 16)
+ {
+ Console.Write($"0x{addr:X4}: ");
+ for (u16 offset = 0; offset < 16; offset++)
+ {
+ if (addr + offset > end) break;
+ Console.Write($"{memory.Read((u16) (addr + offset)):X2} ");
+ }
+ Console.WriteLine();
+ }
+ }
} \ No newline at end of file