blob: 559d7e2ebed2097af7567b11e6099690dc5fb53b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// 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 acc X Y Flags S Label Instruction Comment\n" << endl;
while(!Log.eof())
{
string pc;
string t;
#define GobbleDelimiter Log >> t; Output << " : "
// Time Counter
Log >> t; Output << t; GobbleDelimiter;
// Program counter
Log >> pc; Output << pc; GobbleDelimiter;
// acc
Log >> t; Output << t; GobbleDelimiter;
// X
Log >> t; Output << t; GobbleDelimiter;
// Y
Log >> t; Output << t; GobbleDelimiter;
// Flags
for (int i = 0; i < 8; i++) {
char c;
Log >> c;
Output << c;
}
GobbleDelimiter;
// Stack Pointer
Log >> t; Output << t;
// If a mapping exists, print out the program counter and line code.
try {
string s = Convert[pc];
Output << " " << s;
}
// Otherwise, don't do anything.
catch (out_of_range) {
}
// Newline
Output << endl;
}
Log.close();
Output.close();
return 0;
}
|