summaryrefslogtreecommitdiff
path: root/Q1.core/Pipeline/Disassembler.cs
diff options
context:
space:
mode:
authorMelodi <62381002+Melodi17@users.noreply.github.com>2026-07-11 09:03:50 +1000
committerMelodi <62381002+Melodi17@users.noreply.github.com>2026-07-11 09:03:50 +1000
commitcb3cc7e94327c57a0f7539d8f8f2406ca4b04037 (patch)
tree8e4d241a466e58b438579622a8a1a6e2339489e9 /Q1.core/Pipeline/Disassembler.cs
parent512a5f0efeea46994d01124b409ef51f9b9177a0 (diff)
Diffstat (limited to 'Q1.core/Pipeline/Disassembler.cs')
-rw-r--r--Q1.core/Pipeline/Disassembler.cs36
1 files changed, 36 insertions, 0 deletions
diff --git a/Q1.core/Pipeline/Disassembler.cs b/Q1.core/Pipeline/Disassembler.cs
new file mode 100644
index 0000000..ae93e12
--- /dev/null
+++ b/Q1.core/Pipeline/Disassembler.cs
@@ -0,0 +1,36 @@
+namespace Q1.core.Pipeline;
+
+using Arch;
+using Arch.Lookups;
+
+public class Disassembler
+{
+ public StringWriter Disassemble(MemoryStream stream)
+ {
+ var reader = new BinaryReader(stream);
+ var writer = new StringWriter();
+
+ while (reader.BaseStream.Position < reader.BaseStream.Length)
+ {
+ u16 instruction = reader.ReadUInt16();
+ InstructionEncoding.Decode(instruction, out u8 opcode, out u8 m1, out u8 m2, out bool word);
+
+ var group = InstructionSet.Lookup[opcode];
+ (string name, int param) = (m1, m2) switch
+ {
+ (0x00, 0x00) => (group.Implicit.Name, 0),
+ (_, 0x00) => (group.SimpleAddressing.Name, 1),
+ (0x00, 0x01) => (group.ExtendedImplicit.Name, 0),
+ (_, _) => (group.ExtendedAddressing.Name, 2)
+ };
+
+ writer.Write(name);
+ if (param == 1)
+ {
+
+ }
+ }
+
+ return writer;
+ }
+} \ No newline at end of file