2013-12-12 22:05:33 +00:00
|
|
|
/*
|
|
|
|
* File: Trace.cpp
|
|
|
|
* Author: cmosher
|
|
|
|
*
|
|
|
|
* Created on December 12, 2013, 3:39 PM
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Trace.h"
|
|
|
|
#include "SegmentCache.h"
|
2013-12-15 02:04:57 +00:00
|
|
|
#include "Common.h"
|
2013-12-12 22:05:33 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
2013-12-14 23:10:32 +00:00
|
|
|
#include <cassert>
|
2013-12-12 22:05:33 +00:00
|
|
|
|
2013-12-14 05:26:34 +00:00
|
|
|
static void pHex(const unsigned long x, const int width) {
|
|
|
|
std::cout << std::setw(width) << std::setfill('0') << std::hex << x << std::dec;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pHexb(const unsigned char x) {
|
|
|
|
pHex(x,2);
|
2013-12-12 22:05:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void pHexw(const unsigned short x) {
|
2013-12-14 05:26:34 +00:00
|
|
|
pHex(x,4);
|
2013-12-12 22:05:33 +00:00
|
|
|
}
|
|
|
|
|
2013-12-14 05:26:34 +00:00
|
|
|
void Trace::dumpSegments() const {
|
2013-12-14 23:10:32 +00:00
|
|
|
for (auto sp : this->s) {
|
|
|
|
Segment* seg = sp.second.get();
|
2013-12-15 05:03:46 +00:00
|
|
|
if (seg->pull == Pull::UP) {
|
2013-12-14 23:10:32 +00:00
|
|
|
std::cout << (seg->on ? "U" : "u");
|
2013-12-15 05:03:46 +00:00
|
|
|
} else if (seg->pull == Pull::DOWN) {
|
2013-12-14 23:10:32 +00:00
|
|
|
std::cout << (seg->on ? "D" : "d");
|
|
|
|
} else {
|
|
|
|
std::cout << (seg->on ? "F" : "f");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
std::cout << std::endl;
|
2013-12-12 22:05:33 +00:00
|
|
|
}
|
|
|
|
|
2013-12-14 05:26:34 +00:00
|
|
|
void Trace::dumpRegisters() const {
|
2013-12-12 22:05:33 +00:00
|
|
|
std::cout << "A";
|
2013-12-15 03:48:06 +00:00
|
|
|
pHexb(common.rA());
|
2013-12-12 22:05:33 +00:00
|
|
|
std::cout << " X";
|
2013-12-15 03:48:06 +00:00
|
|
|
pHexb(common.rX());
|
2013-12-12 22:05:33 +00:00
|
|
|
std::cout << " Y";
|
2013-12-15 03:48:06 +00:00
|
|
|
pHexb(common.rY());
|
2013-12-12 22:05:33 +00:00
|
|
|
std::cout << " ";
|
2013-12-15 03:48:06 +00:00
|
|
|
std::cout << (this->common.P7->on ? "N" : "n");
|
|
|
|
std::cout << (this->common.P6->on ? "V" : "v");
|
2013-12-12 22:05:33 +00:00
|
|
|
std::cout << ".";
|
2013-12-15 03:48:06 +00:00
|
|
|
std::cout << (this->common.P4->on ? "B" : "b");
|
|
|
|
std::cout << (this->common.P3->on ? "D" : "d");
|
|
|
|
std::cout << (this->common.P2->on ? "I" : "i");
|
|
|
|
std::cout << (this->common.P1->on ? "Z" : "z");
|
|
|
|
std::cout << (this->common.P0->on ? "C" : "c");
|
2013-12-12 22:05:33 +00:00
|
|
|
std::cout << " S";
|
2013-12-15 03:48:06 +00:00
|
|
|
pHexb(common.rS());
|
2013-12-12 22:05:33 +00:00
|
|
|
std::cout << " PC";
|
2013-12-15 03:48:06 +00:00
|
|
|
pHexw(common.rPC());
|
|
|
|
if (this->common.CLK1OUT->on) {
|
2013-12-12 22:05:33 +00:00
|
|
|
std::cout << " PH1 ";
|
|
|
|
}
|
2013-12-15 03:48:06 +00:00
|
|
|
if (this->common.CLK2OUT->on) {
|
2013-12-12 22:05:33 +00:00
|
|
|
std::cout << " PH2";
|
2013-12-15 03:48:06 +00:00
|
|
|
if (this->common.RW->on) {
|
2013-12-12 22:05:33 +00:00
|
|
|
std::cout << " R";
|
|
|
|
} else {
|
|
|
|
std::cout << " W";
|
|
|
|
}
|
|
|
|
}
|
2013-12-15 03:48:06 +00:00
|
|
|
if (!(this->common.CLK1OUT->on || this->common.CLK2OUT->on)) {
|
2013-12-12 22:05:33 +00:00
|
|
|
std::cout << " PH- ";
|
|
|
|
}
|
|
|
|
std::cout << " DB";
|
2013-12-15 03:48:06 +00:00
|
|
|
pHexb(common.rData());
|
2013-12-12 22:05:33 +00:00
|
|
|
std::cout << " AB";
|
2013-12-15 03:48:06 +00:00
|
|
|
pHexw(common.rAddr());
|
2013-12-12 22:05:33 +00:00
|
|
|
std::cout << std::endl;
|
|
|
|
}
|