+void printRAM(const vector<string>& in)
+{
+ int i, start = 0, end = 15;
+ /* Todo:
+ * 1) make 2 columns
+ */
+
+ if(in.size() >= 2) {
+ try {
+ start = lexical_cast<int>(in[1]);
+ if(start < 0 || start > (RAM_END-1)) {
+ cerr << "start is out of range" << endl;
+ return;
+ }
+ end = start;
+ }
+ catch(bad_cast&) {
+ cerr << "given parameter is not a number" << endl;
+ return;
+ }
+ }
+
+ if(in.size() >= 3) {
+ try {
+ end = lexical_cast<int>(in[2]);
+ if(start > end || end > (RAM_END-1)) {
+ cerr << "end is out of range or smaller than start" << endl;
+ return;
+ }
+ }
+ catch(bad_cast&) {
+ cerr << "given parameter is not a number" << endl;
+ return;
+ }
+ }
+
+ for(i = start*4; i <= end*4; i += 4) {
+ cout << std::hex << "0x" << setw(8) << setfill('0') << i << ": 0x" << std::hex << setw(8) << setfill('0') << global_cpu->getRAM(i) << " " << std::dec << setw(10) << setfill(' ') << global_cpu->getRAM(i) << endl;
+ }
+}
+
+void printPROG(const vector<string>& in)
+{
+ int i, start = 0, end = 15;
+ /* Todo:
+ * 1) make 2 columns
+ */
+
+ if(in.size() >= 2) {
+ try {
+ start = lexical_cast<int>(in[1]);
+ if(start < 0 || start > (PROG_END-1)) {
+ cerr << "start is out of range" << endl;
+ return;
+ }
+ end = start;
+ }
+ catch(bad_cast&) {
+ cerr << "given parameter is not a number" << endl;
+ return;
+ }
+ }
+
+ if(in.size() >= 3) {
+ try {
+ end = lexical_cast<int>(in[2]);
+ if(start > end || end > (PROG_END-1)) {
+ cerr << "end is out of range or smaller than start" << endl;
+ return;
+ }
+ }
+ catch(bad_cast&) {
+ cerr << "given parameter is not a number" << endl;
+ return;
+ }
+ }
+
+ for(i = start*4; i <= end*4; i += 4) {
+ Iinstr* pi = global_cpu->getProg(i);
+ if(pi == NULL) {
+ cout << std::hex << "0x" << setw(8) << setfill('0') << i << ": NOP" << endl;
+ }
+ else {
+ cout << std::hex << "0x" << setw(8) << setfill('0') << i << ": " << std::dec << pi->toString() << endl;
+ }
+ }
+}
+
+void setBreak(const vector<string>& in)
+{
+ int addr = 0;
+ if(in.size() == 2) {
+ try {
+ addr = lexical_cast<uint32_from_hex>(in.back());
+ breakpoints.push_back(addr);
+ }
+ catch(bad_cast&) {
+ cerr << "Given parameter is not a valid address" << endl;
+ }
+ }
+ else {
+ cerr << "Invalid parameter count!" << endl;
+ }
+}
+
+void printStatus(const vector<string>&)
+{
+ CDat stackp = global_cpu->getStack();
+ CDat stackd = global_cpu->getRAM(stackp);
+ cout << "Stack pointer: " << stackp << " @stackpointer: " << stackd << endl;
+ cout << "PSW: 0x" << std::hex << setw(8) << setfill('0') << global_cpu->getFlags() << std::dec << endl;
+
+}