From 1b66847647ee86799b660d82eab9e9e5929c89a6 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 11 Nov 2016 20:10:58 -0500 Subject: [PATCH] Started trying to implement something sufficient of a 6502 disassembler. --- .../Clock Signal.xcodeproj/project.pbxproj | 14 ++++++ .../Disassembler/Disassembler6502.cpp | 24 +++++++++++ .../Disassembler/Disassembler6502.hpp | 43 +++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 StaticAnalyser/Disassembler/Disassembler6502.cpp create mode 100644 StaticAnalyser/Disassembler/Disassembler6502.hpp diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index a0340de54..f7941d5bc 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -50,6 +50,7 @@ 4B55CE5D1C3B7D6F0093A61B /* CSOpenGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B55CE5C1C3B7D6F0093A61B /* CSOpenGLView.m */; }; 4B55CE5F1C3B7D960093A61B /* MachineDocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B55CE5E1C3B7D960093A61B /* MachineDocument.swift */; }; 4B59199C1DAC6C46005BB85C /* OricTAP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B59199A1DAC6C46005BB85C /* OricTAP.cpp */; }; + 4B5A12571DD55862007A2231 /* Disassembler6502.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B5A12551DD55862007A2231 /* Disassembler6502.cpp */; }; 4B643F3A1D77AD1900D431D6 /* CSStaticAnalyser.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B643F391D77AD1900D431D6 /* CSStaticAnalyser.mm */; }; 4B643F3F1D77B88000D431D6 /* DocumentController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B643F3E1D77B88000D431D6 /* DocumentController.swift */; }; 4B69FB3D1C4D908A00B5F0AA /* Tape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B69FB3B1C4D908A00B5F0AA /* Tape.cpp */; }; @@ -490,6 +491,8 @@ 4B55CE5E1C3B7D960093A61B /* MachineDocument.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MachineDocument.swift; sourceTree = ""; }; 4B59199A1DAC6C46005BB85C /* OricTAP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OricTAP.cpp; sourceTree = ""; }; 4B59199B1DAC6C46005BB85C /* OricTAP.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = OricTAP.hpp; sourceTree = ""; }; + 4B5A12551DD55862007A2231 /* Disassembler6502.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Disassembler6502.cpp; path = ../../StaticAnalyser/Disassembler/Disassembler6502.cpp; sourceTree = ""; }; + 4B5A12561DD55862007A2231 /* Disassembler6502.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Disassembler6502.hpp; path = ../../StaticAnalyser/Disassembler/Disassembler6502.hpp; sourceTree = ""; }; 4B643F381D77AD1900D431D6 /* CSStaticAnalyser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSStaticAnalyser.h; path = StaticAnalyser/CSStaticAnalyser.h; sourceTree = ""; }; 4B643F391D77AD1900D431D6 /* CSStaticAnalyser.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CSStaticAnalyser.mm; path = StaticAnalyser/CSStaticAnalyser.mm; sourceTree = ""; }; 4B643F3C1D77AE5C00D431D6 /* CSMachine+Target.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CSMachine+Target.h"; sourceTree = ""; }; @@ -1145,6 +1148,15 @@ path = Views; sourceTree = ""; }; + 4B5A12581DD55873007A2231 /* Disassembler */ = { + isa = PBXGroup; + children = ( + 4B5A12551DD55862007A2231 /* Disassembler6502.cpp */, + 4B5A12561DD55862007A2231 /* Disassembler6502.hpp */, + ); + name = Disassembler; + sourceTree = ""; + }; 4B643F3B1D77AD6D00D431D6 /* StaticAnalyser */ = { isa = PBXGroup; children = ( @@ -1851,6 +1863,7 @@ 4BA799961D8B65730045123D /* Atari */, 4BC830D21D6E7C6D0000A26F /* Commodore */, 4BCF1FAC1DADD41F0039D2E7 /* Oric */, + 4B5A12581DD55873007A2231 /* Disassembler */, ); name = StaticAnalyser; sourceTree = ""; @@ -2313,6 +2326,7 @@ 4B6C73BD1D387AE500AFCFCA /* DiskController.cpp in Sources */, 4B643F3A1D77AD1900D431D6 /* CSStaticAnalyser.mm in Sources */, 4B4DC8281D2C2470003C5BF8 /* C1540.cpp in Sources */, + 4B5A12571DD55862007A2231 /* Disassembler6502.cpp in Sources */, 4B1E85751D170228001EF87D /* Typer.cpp in Sources */, 4BF829631D8F536B001BAE39 /* SSD.cpp in Sources */, 4B2E2D9D1C3A070400138695 /* Electron.cpp in Sources */, diff --git a/StaticAnalyser/Disassembler/Disassembler6502.cpp b/StaticAnalyser/Disassembler/Disassembler6502.cpp new file mode 100644 index 000000000..69cb7102d --- /dev/null +++ b/StaticAnalyser/Disassembler/Disassembler6502.cpp @@ -0,0 +1,24 @@ +// +// Disassembler6502.cpp +// Clock Signal +// +// Created by Thomas Harte on 10/11/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +#include "Disassembler6502.hpp" + +using namespace StaticAnalyser::MOS6502; + +static void AddToDisassembly(const std::unique_ptr &disassembly, uint16_t start_address, uint16_t entry_point) +{ +} + +std::unique_ptr Disassemble(std::vector memory, uint16_t start_address, std::vector entry_points) +{ + std::unique_ptr disassembly; + + + + return disassembly; +} diff --git a/StaticAnalyser/Disassembler/Disassembler6502.hpp b/StaticAnalyser/Disassembler/Disassembler6502.hpp new file mode 100644 index 000000000..9e8464604 --- /dev/null +++ b/StaticAnalyser/Disassembler/Disassembler6502.hpp @@ -0,0 +1,43 @@ +// +// Disassembler6502.hpp +// Clock Signal +// +// Created by Thomas Harte on 10/11/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +#ifndef Disassembler6502_hpp +#define Disassembler6502_hpp + +#include +#include +#include +#include + +namespace StaticAnalyser { +namespace MOS6502 { + +struct Instruction { + uint16_t address; + enum { + BRK, ORA, KIL, SLO, NOP, ASL, PHP, ANC, BPL + } operation; + enum { + Absolute, AbsoluteIndirect, Accumulator, + Immediate, Implied, IndexAbsolute, IndexedZeroPage, + IndexedIndirectX, IndirectIndexedY, Relative, ZeroPage + } addressing_mode; + uint16_t operand; +}; + +struct Disassembly { + std::vector instructions; + std::set outward_calls; +}; + +std::unique_ptr Disassemble(std::vector memory, uint16_t start_address, std::vector entry_points); + +} +} + +#endif /* Disassembler6502_hpp */