exit(EXIT_SUCCESS);
}
+unsigned int convertStringToNum(const std::string& in)
+{
+ if(in.substr(0,2) == "0x") {
+ return lexical_cast<uint32_from_hex>(in);
+ }
+ else {
+ return lexical_cast<unsigned int>(in);
+ }
+}
+
+
void execStep(const vector<string>& in)
{
int count = 1;
if(in.size() == 2) {
try {
- count = lexical_cast<int>(in.back());
+ count = convertStringToNum(in.back());
}
catch(bad_cast&) {
cerr << "given parameter to step is not a number" << endl;
}
else {
ignoreBreak = true;
- cout << "Breakpoint " << *breakp << " hit" << endl;
+ cout << "Breakpoint 0x" << std::hex << setw(8) << setfill('0') << *breakp << std::hex << " hit" << endl;
break;
}
}
}
else {
ignoreBreak = true;
- cout << "Breakpoint " << *breakp << " hit" << endl;
+ cout << "Breakpoint 0x" << std::hex << setw(8) << setfill('0') << *breakp << std::hex << " hit" << endl;
return;
}
}
CDat addr = 0;
if(in.size() == 2) {
try {
- addr = lexical_cast<uint32_from_hex>(in.back());
+ addr = convertStringToNum(in.back());
}
catch(bad_cast&) {
cerr << "given parameter is not a number" << endl;
}
}
global_cpu->setNextPC(addr);
- cout << "Set programcounter to " << addr << endl;
+ cout << "Set programcounter to 0x" << std::hex << setw(8) << setfill('0') << addr << std::dec << endl;
}
if(in.size() >= 2) {
try {
- start = lexical_cast<int>(in[1]);
+ start = convertStringToNum(in[1]);
if(start < 0 || start > (REG_COUNT-1)) {
cerr << "start is out of range" << endl;
return;
if(in.size() >= 3) {
try {
- end = lexical_cast<int>(in[2]);
+ end = convertStringToNum(in[2]);
if(start > end || end > (REG_COUNT-1)) {
cerr << "end is out of range or smaller than start" << endl;
return;
}
for(i = start; i <= end; i++) {
- cout << setw(2) << 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" << std::hex << setw(8) << setfill('0') << global_cpu->getRegister(i) << " " << std::dec << setw(10) << setfill(' ') << global_cpu->getRegister(i) << endl;
}
}
if(in.size() >= 2) {
try {
- start = lexical_cast<int>(in[1]);
+ start = convertStringToNum(in[1]);
if(start < 0 || start > (RAM_END-1)) {
cerr << "start is out of range" << endl;
return;
}
+ start = (start & (~(BYTE_COUNT-1))) / BYTE_COUNT;
end = start;
}
catch(bad_cast&) {
if(in.size() >= 3) {
try {
- end = lexical_cast<int>(in[2]);
+ end = convertStringToNum(in[2]);
if(start > end || end > (RAM_END-1)) {
cerr << "end is out of range or smaller than start" << endl;
return;
}
+ if(end % BYTE_COUNT != 0) {
+ end = ((end & (~(BYTE_COUNT-1))) / BYTE_COUNT)+1;
+ }
+ else {
+ end = ((end & (~(BYTE_COUNT-1))) / BYTE_COUNT);
+ }
}
catch(bad_cast&) {
cerr << "given parameter is not a number" << endl;
return;
}
}
-
- for(i = start*4; i <= end*4; i += 4) {
+ 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;
}
}
if(in.size() >= 2) {
try {
- start = lexical_cast<int>(in[1]);
+ start = convertStringToNum(in[1]);
if(start < 0 || start > (PROG_END-1)) {
cerr << "start is out of range" << endl;
return;
}
+ start = (start & (~(BYTE_COUNT-1))) / BYTE_COUNT;
end = start;
}
catch(bad_cast&) {
if(in.size() >= 3) {
try {
- end = lexical_cast<int>(in[2]);
+ end = convertStringToNum(in[2]);
if(start > end || end > (PROG_END-1)) {
cerr << "end is out of range or smaller than start" << endl;
return;
}
+ if(end % BYTE_COUNT != 0) {
+ end = ((end & (~(BYTE_COUNT-1))) / BYTE_COUNT)+1;
+ }
+ else {
+ end = ((end & (~(BYTE_COUNT-1))) / BYTE_COUNT);
+ }
+
}
catch(bad_cast&) {
cerr << "given parameter is not a number" << endl;
}
}
- for(i = start*4; i <= end*4; i += 4) {
+ for(i = start*BYTE_COUNT; i <= end*BYTE_COUNT; i += BYTE_COUNT) {
Iinstr* pi = global_cpu->getProg(i);
if(pi == NULL) {
cout << std::hex << "0x" << setw(8) << setfill('0') << i << ": NOP" << endl;
void setBreak(const vector<string>& in)
{
- int addr = 0;
+ unsigned int addr = 0;
if(in.size() == 2) {
try {
- addr = lexical_cast<uint32_from_hex>(in.back());
+ addr = convertStringToNum(in.back());
breakpoints.push_back(addr);
+ cout << "Breakpoint 0x" << std::hex << setw(8) << setfill('0') << addr << std::hex << " set" << endl;
}
catch(bad_cast&) {
cerr << "Given parameter is not a valid address" << endl;