Move to a more standard flag representation for the 8080

This commit is contained in:
Adrian.Conlon
2017-06-16 01:58:12 +01:00
parent 71e6902aeb
commit 675b82b5af
7 changed files with 113 additions and 159 deletions

View File

@ -7,7 +7,6 @@
#include "Memory.h"
#include "Intel8080.h"
#include "StatusFlags.h"
EightBit::Disassembler::Disassembler() {
}
@ -35,7 +34,7 @@ std::string EightBit::Disassembler::state(Intel8080& cpu) {
<< "PC=" << hex(pc.word)
<< " "
<< "SP=" << hex(sp.word)
<< " " << "A=" << hex(a) << " " << "F=" << (std::string)f
<< " " << "A=" << hex(a) << " " << "F=" << flags(f)
<< " " << "B=" << hex(b) << " " << "C=" << hex(c)
<< " " << "D=" << hex(d) << " " << "E=" << hex(e)
<< " " << "H=" << hex(h) << " " << "L=" << hex(l);
@ -87,6 +86,26 @@ std::string EightBit::Disassembler::disassemble(Intel8080& cpu) {
return output.str();
}
std::string EightBit::Disassembler::flag(uint8_t value, int flag, const std::string& represents) {
std::ostringstream output;
output << (value & flag ? represents : "-");
return output.str();
}
std::string EightBit::Disassembler::flags(uint8_t value) {
std::ostringstream output;
output
<< flag(value, Intel8080::SF, "S")
<< flag(value, Intel8080::ZF, "Z")
<< "0"
<< flag(value, Intel8080::AC, "A")
<< "0"
<< flag(value, Intel8080::PF, "P")
<< "1"
<< flag(value, Intel8080::CF, "C");
return output.str();
}
std::string EightBit::Disassembler::hex(uint8_t value) {
std::ostringstream output;
output << std::hex << std::setw(2) << std::setfill('0') << (int)value;