#include "SReadline/SReadline.h"
using namespace swift;
-#define RAM_END (1000)
-#define PROG_END (1000)
+#define RAM_END (0x1000)
+#define PROG_END (0x1000)
#define REG_COUNT (16)
typedef boost::function<void (const vector<string> &)> Func;
void close_prog(const std::vector<std::string> &);
CCpu* Iinstr::m_cpu;
+disasm* Iinstr::m_disasm;
CCpu* global_cpu = NULL;
bool ignoreBreak = false;
+bool exitProg = false;
+
void doExit(const vector<string>&)
{
- exit(EXIT_SUCCESS);
+ exitProg = true;
}
unsigned int convertStringToNum(const std::string& in)
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;
+ addr *= BYTE_COUNT;
+
+ cout << "Setting RAM-Address 0x" << std::hex << setw(8) << setfill('0') << addr;
+ cout << " to 0x" << setw(8) << setfill('0') << val << std::dec << endl;
global_cpu->setRAM(addr,val);
}
catch(bad_cast&) {
* 1) make 2 columns
*/
- if(in.size() >= 2) {
+ if(in.size() >= 2 && in[1][0] == 'c') {
+ start = global_cpu->getCurPC() / BYTE_COUNT;
+ end = start + 9;
+ }
+ else if(in.size() >= 2) {
try {
start = convertStringToNum(in[1]);
if(start < 0 || start > (PROG_END-1)) {
return;
}
}
+
for(i = start*BYTE_COUNT; i <= end*BYTE_COUNT; i += BYTE_COUNT) {
Iinstr* pi = global_cpu->getProg(i);
}
}
+void getPerf(const vector<string>&)
+{
+ cout << "current perfcounter is " << std::dec << global_cpu->getPerf() << endl;
+}
+
+void resetPerf(const vector<string>&)
+{
+ cout << "reset perfcounter" << endl;
+ global_cpu->setPerf(0);
+}
+
void printStatus(const vector<string>&)
{
CDat stackp = global_cpu->getStack();
Iinstr::setCPU(&cpu);
+ disasm disasm(instr);
+
+ Iinstr::setDisasm(&disasm);
std::string str = "";
int addr = 0;
boost::char_separator<char> sep(";", "", boost::keep_empty_tokens);
boost::tokenizer<boost::char_separator<char> > tokens(str, sep);
- disasm disasm(instr);
while(getline(inFile, str)) {
int count = 0;
tokens.assign(str);
cout << i << " : " << std::hex << i << std::dec << " " << data << endl;
}
*/
- cpu.setRegister(1, 4);
+/* cpu.setRegister(1, 4);
cpu.setRegister(2, 0);
cpu.setRAM(0,5);
- cpu.setRAM(4,50);
+ cpu.setRAM(4,0x66334455);
cpu.setRAM(8,32);
cpu.setRAM(12,45);
-
+*/
// following: job of the bootloader
//set stackpointer
cpu.setStack(500);
//set return to nowhere for ret
- cpu.setRAM(500,50);
+ cpu.setRAM(500,500);
SReadline Reader;
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."));
+ Completers.push_back(CompleterElement("getperf",&getPerf, "Prints performance counter."));
+ Completers.push_back(CompleterElement("resetperf",&resetPerf, "Resets performance counter to 0."));
Reader.RegisterCompletions(Completers);
Func lastFunc = NULL;
- while(1) {
+ while(!exitProg) {
UserInput = Reader.GetLine("> ", Tokens, EndOfInput);
if(EndOfInput) {
break;