Incorporate disassembly into address profile output.

Signed-off-by: Adrian.Conlon <adrian.conlon@arup.com>
This commit is contained in:
Adrian.Conlon 2017-06-19 17:37:41 +01:00
parent c7e65f5447
commit 67fa2a7afe
2 changed files with 21 additions and 3 deletions

View File

@ -4,9 +4,13 @@
#include <cstdint> #include <cstdint>
namespace EightBit { namespace EightBit {
class Disassembler;
class Z80;
class Profiler { class Profiler {
public: public:
Profiler(); Profiler(Z80& cpu, Disassembler& disassembler);
~Profiler(); ~Profiler();
void addInstruction(uint8_t instruction); void addInstruction(uint8_t instruction);
@ -17,6 +21,8 @@ namespace EightBit {
private: private:
std::array<uint64_t, 0x100> m_instructions; std::array<uint64_t, 0x100> m_instructions;
std::array<uint64_t, 0x10000> m_addresses; std::array<uint64_t, 0x10000> m_addresses;
Disassembler& m_disassembler;
Z80& m_cpu;
void dumpInstructionProfiles() const; void dumpInstructionProfiles() const;
void dumpAddressProfiles() const; void dumpAddressProfiles() const;

View File

@ -1,8 +1,11 @@
#include "stdafx.h" #include "stdafx.h"
#include "Profiler.h" #include "Profiler.h"
#include "Disassembler.h" #include "Disassembler.h"
#include "Z80.h"
EightBit::Profiler::Profiler() { EightBit::Profiler::Profiler(Z80& cpu, Disassembler& disassembler)
: m_cpu(cpu),
m_disassembler(disassembler) {
std::fill(m_instructions.begin(), m_instructions.end(), 0); std::fill(m_instructions.begin(), m_instructions.end(), 0);
std::fill(m_addresses.begin(), m_addresses.end(), 0); std::fill(m_addresses.begin(), m_addresses.end(), 0);
} }
@ -36,7 +39,16 @@ void EightBit::Profiler::dumpAddressProfiles() const {
std::cout << "** addresses" << std::endl; std::cout << "** addresses" << std::endl;
for (int i = 0; i < 0x10000; ++i) { for (int i = 0; i < 0x10000; ++i) {
auto count = m_addresses[i]; auto count = m_addresses[i];
m_cpu.PC().word = i;
if (count > 0) if (count > 0)
std::cout << Disassembler::hex((uint16_t)i) << "\t" << count << std::endl; std::cout
<< Disassembler::hex((uint16_t)i)
<< "\t"
<< count
<< "\t"
<< m_disassembler.disassemble(m_cpu)
<< std::endl;
} }
} }