2017-06-04 20:38:34 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <boost/format.hpp>
|
2018-10-20 19:52:41 +00:00
|
|
|
#include <Bus.h>
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-06-05 21:39:15 +00:00
|
|
|
namespace EightBit {
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-06-05 21:39:15 +00:00
|
|
|
class Z80;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2018-10-20 19:52:41 +00:00
|
|
|
class Disassembler final {
|
2017-06-05 21:39:15 +00:00
|
|
|
public:
|
2018-10-20 19:52:41 +00:00
|
|
|
Disassembler(Bus& bus) noexcept;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2018-06-24 19:58:20 +00:00
|
|
|
static std::string state(Z80& cpu);
|
|
|
|
std::string disassemble(Z80& cpu);
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-06-05 21:39:15 +00:00
|
|
|
static std::string flag(uint8_t value, int flag, const std::string& represents);
|
|
|
|
static std::string flags(uint8_t value);
|
|
|
|
static std::string hex(uint8_t value);
|
|
|
|
static std::string hex(uint16_t value);
|
|
|
|
static std::string binary(uint8_t value);
|
|
|
|
static std::string decimal(uint8_t value);
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-06-05 21:39:15 +00:00
|
|
|
static std::string invalid(uint8_t value);
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-06-05 21:39:15 +00:00
|
|
|
private:
|
|
|
|
mutable boost::format m_formatter;
|
2018-08-11 20:19:19 +00:00
|
|
|
bool m_prefixCB = false;
|
|
|
|
bool m_prefixDD = false;
|
|
|
|
bool m_prefixED = false;
|
|
|
|
bool m_prefixFD = false;
|
2018-10-20 19:52:41 +00:00
|
|
|
Bus& m_bus;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2018-06-24 19:58:20 +00:00
|
|
|
void disassemble(std::ostringstream& output, Z80& cpu, uint16_t pc);
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-06-05 21:39:15 +00:00
|
|
|
void disassembleCB(
|
|
|
|
std::ostringstream& output,
|
2018-06-09 23:40:56 +00:00
|
|
|
const Z80& cpu,
|
2017-06-05 21:39:15 +00:00
|
|
|
uint16_t pc,
|
|
|
|
std::string& specification,
|
|
|
|
int& dumpCount,
|
|
|
|
int x, int y, int z,
|
2018-06-09 23:40:56 +00:00
|
|
|
int p, int q) const;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-06-05 21:39:15 +00:00
|
|
|
void disassembleED(
|
|
|
|
std::ostringstream& output,
|
2018-06-09 23:40:56 +00:00
|
|
|
const Z80& cpu,
|
2017-06-05 21:39:15 +00:00
|
|
|
uint16_t pc,
|
|
|
|
std::string& specification,
|
|
|
|
int& dumpCount,
|
|
|
|
int x, int y, int z,
|
2018-06-09 23:40:56 +00:00
|
|
|
int p, int q) const;
|
2017-06-04 20:38:34 +00:00
|
|
|
|
2017-06-05 21:39:15 +00:00
|
|
|
void disassembleOther(
|
|
|
|
std::ostringstream& output,
|
2018-06-24 19:58:20 +00:00
|
|
|
Z80& cpu,
|
2017-06-05 21:39:15 +00:00
|
|
|
uint16_t pc,
|
|
|
|
std::string& specification,
|
|
|
|
int& dumpCount,
|
|
|
|
int x, int y, int z,
|
|
|
|
int p, int q);
|
|
|
|
|
|
|
|
std::string RP(int rp) const;
|
|
|
|
std::string RP2(int rp) const;
|
|
|
|
std::string R(int r) const;
|
|
|
|
static std::string cc(int flag);
|
|
|
|
static std::string alu(int which);
|
2018-10-20 19:52:41 +00:00
|
|
|
|
|
|
|
Bus& BUS() { return m_bus; }
|
2017-06-05 21:39:15 +00:00
|
|
|
};
|
|
|
|
}
|