From cb3cc7e94327c57a0f7539d8f8f2406ca4b04037 Mon Sep 17 00:00:00 2001 From: Melodi <62381002+Melodi17@users.noreply.github.com> Date: Sat, 11 Jul 2026 09:03:50 +1000 Subject: checkpoint --- Q1.core/Pipeline/Disassembler.cs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Q1.core/Pipeline/Disassembler.cs (limited to 'Q1.core/Pipeline/Disassembler.cs') 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 -- cgit v1.3.1