mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-12-22 09:30:32 +00:00
Make Z80 profile output conditional on the availability of data.
This commit is contained in:
parent
3b01c639fd
commit
91df9ea48b
@ -24,6 +24,27 @@ namespace EightBit {
|
||||
Z80& m_cpu;
|
||||
Disassembler& m_disassembler;
|
||||
|
||||
[[nodiscard]] constexpr const auto& instructions() const { return m_instructions; }
|
||||
[[nodiscard]] constexpr const auto& addresses() const { return m_addresses; }
|
||||
|
||||
[[nodiscard]] constexpr auto instructions_available() const noexcept {
|
||||
const auto found = std::find_if(
|
||||
instructions().begin(), instructions().end(),
|
||||
[](const auto& value) { return value != 0; });
|
||||
return found != instructions().end();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr auto addresses_available() const noexcept {
|
||||
const auto found = std::find_if(
|
||||
addresses().begin(), addresses().end(),
|
||||
[](const auto& value) { return value != 0; });
|
||||
return found != addresses().end();
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr auto available() const noexcept {
|
||||
return instructions_available() || addresses_available();
|
||||
}
|
||||
|
||||
void dumpInstructionProfiles() const;
|
||||
void dumpAddressProfiles() const;
|
||||
};
|
||||
|
@ -27,6 +27,7 @@ void EightBit::Profiler::dump() const {
|
||||
}
|
||||
|
||||
void EightBit::Profiler::dumpInstructionProfiles() const {
|
||||
if (instructions_available()) {
|
||||
std::cout << "** instructions" << std::endl;
|
||||
for (int i = 0; i < 0x100; ++i) {
|
||||
auto count = m_instructions[i];
|
||||
@ -34,8 +35,10 @@ void EightBit::Profiler::dumpInstructionProfiles() const {
|
||||
std::cout << Disassembler::hex((uint8_t)i) << "\t" << count << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EightBit::Profiler::dumpAddressProfiles() const {
|
||||
if (addresses_available()) {
|
||||
std::cout << "** addresses" << std::endl;
|
||||
for (int i = 0; i < 0x10000; ++i) {
|
||||
auto count = m_addresses[i];
|
||||
@ -52,3 +55,4 @@ void EightBit::Profiler::dumpAddressProfiles() const {
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user