summaryrefslogtreecommitdiff
path: root/log/log-readable.cpp
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2023-12-03 11:32:39 +1100
committeralekseiplusplus <alekseijeaves@protonmail.com>2023-12-03 11:32:39 +1100
commit991c09b01e6b099a5b00d7a9236d252b85a714b5 (patch)
treebee9445cbd318bbf7a805c80b5bc4b94517b44df /log/log-readable.cpp
parent7a5672d085399d0de9d2c77431ea7a2f089faacb (diff)
half-fixed infinite loop; new debug util, old one out
Diffstat (limited to 'log/log-readable.cpp')
-rw-r--r--log/log-readable.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/log/log-readable.cpp b/log/log-readable.cpp
new file mode 100644
index 0000000..82e263d
--- /dev/null
+++ b/log/log-readable.cpp
@@ -0,0 +1,68 @@
+// log-readable.cpp
+// A simple utility which makes the runtime log files into a more readable
+// format by adding commented code lines from wozmon.
+
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <string>
+#include <map>
+
+using namespace std;
+
+int main()
+{
+ ifstream RomLine ("rom-hex-positions");
+ ifstream Code ("rom-code-lines");
+
+ map<string, string> Convert;
+
+ string x;
+ string y;
+
+ for (int i = 0; i < 128; i++)
+ {
+ getline (RomLine, x);
+ getline (Code, y, (char)0x0d);
+ if (i != 0)
+ y.erase(0,1);
+ Convert[x] = y;
+
+ cout << x << " : " << Convert[x] << endl;
+ }
+
+ RomLine.close();
+ Code.close();
+
+ ifstream Log("log.raw");
+ ofstream Output("log.new");
+
+ Output << "Time PC Label Instruction Comment\n" << endl;
+ while(!Log.eof())
+ {
+ string t;
+ // Expects time counter, and prints.
+ Log >> t;
+ Output << t;
+ // Expecting a delimiter surrounded with space.
+ Log >> t;
+ Output << " : ";
+ // Expecting program counter
+ Log >> t;
+ Output << t;
+ // If a mapping exists, print out the program counter and line code.
+ try {
+ string s = Convert[t];
+ Output << t << " : ";
+ Output << s;
+ }
+ // Otherwise, don't do anything.
+ catch (out_of_range) { }
+ // Newline
+ Output << endl;
+ }
+
+ Log.close();
+ Output.close();
+ return 0;
+}