2016-11-12 01:10:58 +00:00
|
|
|
//
|
|
|
|
// 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 <cstdint>
|
|
|
|
#include <memory>
|
|
|
|
#include <set>
|
|
|
|
#include <vector>
|
2016-11-14 04:19:09 +00:00
|
|
|
#include <map>
|
2016-11-12 01:10:58 +00:00
|
|
|
|
|
|
|
namespace StaticAnalyser {
|
|
|
|
namespace MOS6502 {
|
|
|
|
|
|
|
|
struct Instruction {
|
|
|
|
uint16_t address;
|
|
|
|
enum {
|
2016-11-15 00:19:57 +00:00
|
|
|
BRK, JSR, RTI, RTS, JMP,
|
2016-11-14 04:19:09 +00:00
|
|
|
CLC, SEC, CLD, SED, CLI, SEI, CLV,
|
|
|
|
NOP,
|
|
|
|
|
2016-11-15 00:19:57 +00:00
|
|
|
SLO, RLA, SRE, RRA, ALR, ARR,
|
|
|
|
SAX, LAX, DCP, ISC,
|
|
|
|
ANC, XAA, AXS,
|
|
|
|
AND, EOR, ORA, BIT,
|
2016-11-14 04:19:09 +00:00
|
|
|
ADC, SBC,
|
2016-11-15 00:19:57 +00:00
|
|
|
AHX, SHY, SHX, TAS, LAS,
|
2016-11-14 04:19:09 +00:00
|
|
|
|
|
|
|
LDA, STA, LDX, STX, LDY, STY,
|
|
|
|
|
|
|
|
BPL, BMI, BVC, BVS, BCC, BCS, BNE, BEQ,
|
|
|
|
|
|
|
|
CMP, CPX, CPY,
|
|
|
|
INC, DEC, DEX, DEY, INX, INY,
|
|
|
|
ASL, ROL, LSR, ROR,
|
|
|
|
TAX, TXA, TAY, TYA, TSX, TXS,
|
2016-11-15 00:19:57 +00:00
|
|
|
PLA, PHA, PLP, PHP,
|
|
|
|
|
|
|
|
KIL
|
2016-11-12 01:10:58 +00:00
|
|
|
} operation;
|
|
|
|
enum {
|
2016-11-14 04:19:09 +00:00
|
|
|
Absolute,
|
|
|
|
AbsoluteX,
|
|
|
|
AbsoluteY,
|
|
|
|
Immediate,
|
|
|
|
Implied,
|
|
|
|
ZeroPage,
|
|
|
|
ZeroPageX,
|
|
|
|
ZeroPageY,
|
|
|
|
Indirect,
|
|
|
|
IndexedIndirectX,
|
|
|
|
IndirectIndexedY,
|
|
|
|
Relative,
|
2016-11-12 01:10:58 +00:00
|
|
|
} addressing_mode;
|
|
|
|
uint16_t operand;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Disassembly {
|
2016-11-14 04:19:09 +00:00
|
|
|
std::map<uint16_t, Instruction> instructions_by_address;
|
2016-11-12 01:10:58 +00:00
|
|
|
std::set<uint16_t> outward_calls;
|
2016-11-14 04:19:09 +00:00
|
|
|
std::set<uint16_t> external_stores, external_loads, external_modifies;
|
2016-11-12 01:10:58 +00:00
|
|
|
};
|
|
|
|
|
2016-11-14 04:19:09 +00:00
|
|
|
Disassembly Disassemble(const std::vector<uint8_t> &memory, uint16_t start_address, std::vector<uint16_t> entry_points);
|
2016-11-12 01:10:58 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* Disassembler6502_hpp */
|