projects
/
calu.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8f5ad46
)
sim: labels and comments are now shown
author
Martin Perner
<martin@perner.cc>
Sun, 9 Jan 2011 16:52:20 +0000
(17:52 +0100)
committer
Martin Perner
<martin@perner.cc>
Sun, 9 Jan 2011 17:11:31 +0000
(18:11 +0100)
3b_sim/sim.cpp
patch
|
blob
|
history
diff --git
a/3b_sim/sim.cpp
b/3b_sim/sim.cpp
index 8589084687a79e362a59335844980287fa11d41d..3200e92a798370baf0ada9c066d7a80fc3d9e65c 100644
(file)
--- a/
3b_sim/sim.cpp
+++ b/
3b_sim/sim.cpp
@@
-74,6
+74,11
@@
CCpu* global_cpu = NULL;
vector<CDat> breakpoints;
vector<CDat> breakpoints;
+#include <map>
+
+multimap<int,string> dataCommentsStore, progCommentsStore, dataLabelStore, progLabelStore;
+map<int,string> dataLineCommentStore, progLineCommentStore;
+
bool ignoreBreak = false;
bool exitProg = false;
bool ignoreBreak = false;
bool exitProg = false;
@@
-276,10
+281,29
@@
void printRAM(const vector<string>& in)
}
}
for(i = start*BYTE_COUNT; i <= end*BYTE_COUNT; i += BYTE_COUNT) {
}
}
for(i = start*BYTE_COUNT; i <= end*BYTE_COUNT; i += BYTE_COUNT) {
+ {
+ auto range = dataLabelStore.equal_range(i);
+ for(auto iter = range.first; iter != range.second; ++iter) {
+ cout << color(yellow,black) << iter->second << ":" << color(white,black) << endl;
+ }
+ }
+ {
+ auto range = dataCommentsStore.equal_range(i);
+ for(auto iter = range.first; iter != range.second; ++iter) {
+ cout << color(blue,black) << ";" << iter->second << color(white,black) << endl;
+ }
+ }
cout << std::hex << "0x" << setw(8) << setfill('0') << i << ": 0x";
cout << std::hex << setw(8) << setfill('0') << global_cpu->getRAM(i) << " ";
cout << std::dec << setw(10) << setfill(' ') << global_cpu->getRAM(i) << " ";
cout << std::hex << "0x" << setw(8) << setfill('0') << i << ": 0x";
cout << std::hex << setw(8) << setfill('0') << global_cpu->getRAM(i) << " ";
cout << std::dec << setw(10) << setfill(' ') << global_cpu->getRAM(i) << " ";
- cout << std::dec << setw(10) << setfill(' ') << (int)global_cpu->getRAM(i) << endl;
+ cout << std::dec << setw(10) << setfill(' ') << (int)global_cpu->getRAM(i);
+
+ auto iter = dataLineCommentStore.find(i);
+ if(iter != dataLineCommentStore.end()) {
+ cout << color(blue,black) << " ;" << iter->second << color(white,black);
+ }
+ cout << endl;
+
}
}
}
}
@@
-361,13
+385,31
@@
void printPROG(const vector<string>& in)
for(i = start*BYTE_COUNT; i <= end*BYTE_COUNT; i += BYTE_COUNT) {
for(i = start*BYTE_COUNT; i <= end*BYTE_COUNT; i += BYTE_COUNT) {
+ {
+ auto range = progLabelStore.equal_range(i);
+ for(auto iter = range.first; iter != range.second; ++iter) {
+ cout << color(yellow,black) << iter->second << ":" << color(white,black) << endl;
+ }
+ }
+ {
+ auto range = progCommentsStore.equal_range(i);
+ for(auto iter = range.first; iter != range.second; ++iter) {
+ cout << color(blue,black) << ";" << iter->second << color(white,black) << endl;
+ }
+ }
+
Iinstr* pi = global_cpu->getProg(i);
if(pi == NULL) {
Iinstr* pi = global_cpu->getProg(i);
if(pi == NULL) {
- cout << std::hex << "0x" << setw(8) << setfill('0') << i << ": NOP"
<< endl
;
+ cout << std::hex << "0x" << setw(8) << setfill('0') << i << ": NOP";
}
else {
}
else {
- cout << std::hex << "0x" << setw(8) << setfill('0') << i << ": " << std::dec << pi->toString() << endl;
+ cout << std::hex << "0x" << setw(8) << setfill('0') << i << ": " << std::dec << pi->toString();
+ }
+ auto iter = progLineCommentStore.find(i);
+ if(iter != progLineCommentStore.end()) {
+ cout << color(blue,black) << " ;" << iter->second << color(white,black);
}
}
+ cout << endl;
}
}
}
}
@@
-498,6
+540,8
@@
int main(int argc, char* argv[])
Iinstr::setDisasm(&disasm);
Iinstr::setDisasm(&disasm);
+ vector<string> commentDefer;
+ vector<string> labelDefer;
std::string str = "";
int addr = 0;
boost::char_separator<char> sep(";", "", boost::keep_empty_tokens);
std::string str = "";
int addr = 0;
boost::char_separator<char> sep(";", "", boost::keep_empty_tokens);
@@
-524,6
+568,15
@@
int main(int argc, char* argv[])
if(count == 1) {
try {
addr = lexical_cast<uint32_from_hex>(*tok_iter);
if(count == 1) {
try {
addr = lexical_cast<uint32_from_hex>(*tok_iter);
+ for(unsigned int i = 0; i < commentDefer.size(); i++) {
+ dataCommentsStore.insert(pair<int,string>(addr, commentDefer.at(i)));
+ }
+ for(unsigned int i = 0; i < labelDefer.size(); i++) {
+ dataLabelStore.insert(pair<int,string>(addr, labelDefer.at(i)));
+ }
+
+ commentDefer.clear();
+ labelDefer.clear();
}
catch(bad_lexical_cast& e) {
cerr << e.what() << endl;
}
catch(bad_lexical_cast& e) {
cerr << e.what() << endl;
@@
-540,11
+593,30
@@
int main(int argc, char* argv[])
exit(EXIT_FAILURE);
}
}
exit(EXIT_FAILURE);
}
}
+ else if(count == 4) {
+ if((*tok_iter).size() > 0) {
+ dataLabelStore.insert(pair<int,string>(addr, *tok_iter));
+ }
+ }
+ else if(count == 5) {
+ if((*tok_iter).size() > 0) {
+ dataLineCommentStore.insert(pair<int,string>(addr, *tok_iter));
+ }
+ }
break;
case 1:
if(count == 1) {
try {
addr = lexical_cast<uint32_from_hex>(*tok_iter);
break;
case 1:
if(count == 1) {
try {
addr = lexical_cast<uint32_from_hex>(*tok_iter);
+ for(unsigned int i = 0; i < commentDefer.size(); i++) {
+ progCommentsStore.insert(pair<int,string>(addr, commentDefer.at(i)));
+ }
+ for(unsigned int i = 0; i < labelDefer.size(); i++) {
+ progLabelStore.insert(pair<int,string>(addr, labelDefer.at(i)));
+ }
+
+ commentDefer.clear();
+ labelDefer.clear();
}
catch(bad_lexical_cast& e) {
cerr << e.what() << endl;
}
catch(bad_lexical_cast& e) {
cerr << e.what() << endl;
@@
-555,10
+627,27
@@
int main(int argc, char* argv[])
Iinstr *pi = disasm.decode(*tok_iter);
cpu.setProg(addr, pi);
}
Iinstr *pi = disasm.decode(*tok_iter);
cpu.setProg(addr, pi);
}
+ else if(count == 4) {
+ if((*tok_iter).size() > 0) {
+ progLabelStore.insert(pair<int,string>(addr, *tok_iter));
+ }
+ }
+ else if(count == 5) {
+ if((*tok_iter).size() > 0) {
+ progLineCommentStore.insert(pair<int,string>(addr, *tok_iter));
+ }
+ }
+
break;
case 2:
break;
case 2:
+ if((*tok_iter).size() > 0) {
+ commentDefer.push_back(*tok_iter);
+ }
+ break;
case 3:
case 3:
- cerr << "ignoring labels and comments for now" << endl;
+ if((*tok_iter).size() > 0) {
+ labelDefer.push_back(*tok_iter);
+ }
break;
default:
cerr << "i was to lazy to implement the other format types for now" << endl;
break;
default:
cerr << "i was to lazy to implement the other format types for now" << endl;