本文整理汇总了C++中CPU::printState方法的典型用法代码示例。如果您正苦于以下问题:C++ CPU::printState方法的具体用法?C++ CPU::printState怎么用?C++ CPU::printState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPU
的用法示例。
在下文中一共展示了CPU::printState方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cmd_continue
void cmd_continue(CPU &cpu, stringstream &cmdstream) {
cout << "Continuing\n";
cpu.install_sigint();
do {
cpu.tick();
} while (find(breakpoints.begin(), breakpoints.end(), cpu.pc)
== breakpoints.end());
cpu.uninstall_sigint();
cpu.printState();
}
示例2: run_debugger
void run_debugger(CPU &cpu) {
cpu.printState();
string last_cmd;
while (1) {
string cmd_full;
cout << "> ";
getline(cin, cmd_full);
if (!cin) {
if (DEBUG_SHUTDOWN_ON_EOF) {
cout << "\n";
exit(0);
}
break;
}
if (cmd_full.empty()) {
cmd_full = last_cmd;
}
last_cmd = cmd_full;
stringstream cmdstream = stringstream(cmd_full);
string cmd;
cmdstream >> cmd;
bool recognized = 0;
if (cmd.compare("exit") == 0) {
break;
}
for (int i = 0; i < sizeof(cmds) / sizeof(cmds[0]); i++){
if (cmd.compare(cmds[i].name) == 0) {
cmds[i].cmd(cpu, cmdstream);
recognized = 1;
break;
}
}
if (!recognized) {
cout << "Unrecognized command\n";
}
}
cout << "\n";
}
示例3: cmd_state
void cmd_state(CPU &cpu, stringstream &cmdstream) {
cpu.printState();
}
示例4: cmd_step
void cmd_step(CPU &cpu, stringstream &cmdstream) {
cpu.tick();
cpu.printState();
}
示例5: cmd_wreg
void cmd_wreg(CPU &cpu, stringstream &cmdstream) {
string regname;
cmdstream >> regname;
if (!cmdstream) {
printf("Couldn't read register name\n");
return;
}
int val;
cmdstream >> hex >> val;
if (!cmdstream) {
printf("Couldn't read value\n");
return;
}
struct {string name; gb_ptr ptr;} regs_8[] = {
{"b", gb_reg_ptr(cpu, &cpu.bc.high)},
{"c", gb_reg_ptr(cpu, &cpu.bc.low)},
{"d", gb_reg_ptr(cpu, &cpu.de.high)},
{"e", gb_reg_ptr(cpu, &cpu.de.low)},
{"a", gb_reg_ptr(cpu, &cpu.af.high)},
{"f", gb_reg_ptr(cpu, &cpu.af.low)},
{"h", gb_reg_ptr(cpu, &cpu.hl.high)},
{"l", gb_reg_ptr(cpu, &cpu.hl.low)},
};
struct {string name; gb_ptr_16 ptr;} regs_16[] = {
{"af", gb_reg16_ptr(cpu, &cpu.af.full)},
{"bc", gb_reg16_ptr(cpu, &cpu.bc.full)},
{"de", gb_reg16_ptr(cpu, &cpu.de.full)},
{"hl", gb_reg16_ptr(cpu, &cpu.hl.full)},
{"pc", gb_reg16_ptr(cpu, &cpu.pc)},
{"sp", gb_reg16_ptr(cpu, &cpu.sp)},
};
bool recognized = 0;
for (int i = 0; i < sizeof(regs_8) / sizeof(regs_8[0]); i++){
if (regname.compare(regs_8[i].name) == 0) {
if ((val < 0) || (val > 0xff)) {
cout << "Bad value " << hex << val << " for register " << regname << "\n";
return;
}
regs_8[i].ptr.write(val);
recognized = 1;
break;
}
}
if (!recognized) {
for (int i = 0; i < sizeof(regs_16) / sizeof(regs_16[0]); i++){
if (regname.compare(regs_16[i].name) == 0) {
if ((val < 0) || (val > 0xffff)) {
cout << "Bad value " << hex << val << " for register " << regname << "\n";
return;
}
regs_8[i].ptr.write(val);
recognized = 1;
break;
}
}
}
if (recognized) {
// confirm write
cpu.printState();
} else {
cout << "Unrecognized register\n";
}
}