}
for(i = start; i <= end; i++) {
- cout << setw(2) << setfill('0') << i << ": 0x" << std::hex << setw(8) << setfill('0') << global_cpu->getRegister(i) << " " << std::dec << setw(10) << setfill(' ') << global_cpu->getRegister(i) << endl;
+ cout << setw(2) << setfill('0') << i << ": 0x";
+ cout << std::hex << setw(8) << setfill('0') << global_cpu->getRegister(i) << " ";
+ cout << std::dec << setw(10) << setfill(' ') << global_cpu->getRegister(i) << " ";
+ cout << std::dec << setw(10) << setfill(' ') << (int)global_cpu->getRegister(i) << endl;
+ }
+}
+
+void setReg(const vector<string>& in)
+{
+ int reg = 0;
+ CDat val = 0;
+
+ if(in.size() >= 3) {
+ try {
+ reg = convertStringToNum(in[1]);
+ if(reg < 0 || reg > (REG_COUNT-1)) {
+ cerr << "register is out of range" << endl;
+ return;
+ }
+
+ val = convertStringToNum(in[2]);
+
+ cout << "Setting register " << reg << " to 0x" << std::hex << setw(8) << setfill('0') << val << std::dec << endl;
+ global_cpu->setRegister(reg,val);
+ }
+ catch(bad_cast&) {
+ cerr << "given parameter is not a number" << endl;
+ return;
+ }
}
}
}
}
for(i = start*BYTE_COUNT; i <= end*BYTE_COUNT; i += BYTE_COUNT) {
- 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;
+ 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;
}
}
+void setRam(const vector<string>& in)
+{
+ int addr = 0;
+ CDat val = 0;
+
+ if(in.size() >= 3) {
+ try {
+ addr = convertStringToNum(in[1]);
+ if(addr < 0 || addr > (RAM_END-1)) {
+ cerr << "RAM-Address is out of range" << endl;
+ return;
+ }
+
+ addr = (addr & (~(BYTE_COUNT-1))) / BYTE_COUNT;
+ val = convertStringToNum(in[2]);
+
+ cout << "Setting RAM-Address " << addr << " to 0x" << std::hex << setw(8) << setfill('0') << val << std::dec << endl;
+ global_cpu->setRAM(addr,val);
+ }
+ catch(bad_cast&) {
+ cerr << "given parameter is not a number" << endl;
+ return;
+ }
+ }
+}
void printPROG(const vector<string>& in)
{
int i, start = 0, end = 15;
Completers.push_back(CompleterElement("listbreaks",&listBreaks, "Lists all breakpoints."));
Completers.push_back(CompleterElement("run",&execRun, "Runs till next breakpoint or end of program."));
Completers.push_back(CompleterElement("setpc [num]",&setPC, "Sets PC to num. if num is omitted 0 is used."));
+ Completers.push_back(CompleterElement("setreg [s] [num]",&setReg, "Sets Register s to num."));
+ Completers.push_back(CompleterElement("setdata [s] [num]",&setRam, "Sets RAM-Addr s to num."));
Completers.push_back(CompleterElement("status",&printStatus, "Prints status of CPU."));
Reader.RegisterCompletions(Completers);