Line 31... |
Line 31... |
|
|
|
|
static Bool quit;
|
static Bool quit;
|
|
|
|
|
|
typedef struct {
|
|
char *name;
|
|
void (*hlpProc)(void);
|
|
void (*cmdProc)(char *tokens[], int n);
|
|
} Command;
|
|
|
|
extern Command commands[];
|
|
extern int numCommands;
|
|
|
|
|
static void help(void) {
|
static void help(void) {
|
cPrintf("valid commands are:\n");
|
cPrintf("valid commands are:\n");
|
|
cPrintf(" help get help\n");
|
|
cPrintf(" + add and subtract\n");
|
|
cPrintf(" a assemble\n");
|
|
cPrintf(" u unassemble\n");
|
|
cPrintf(" b set/reset breakpoint\n");
|
|
cPrintf(" c continue from breakpoint\n");
|
|
cPrintf(" s single-step\n");
|
|
cPrintf(" # show/set PC\n");
|
|
cPrintf(" p show/set PSW\n");
|
|
cPrintf(" r show/set register\n");
|
|
cPrintf(" d dump memory\n");
|
|
cPrintf(" mw show/set memory word\n");
|
|
cPrintf(" mh show/set memory halfword\n");
|
|
cPrintf(" mb show/set memory byte\n");
|
|
cPrintf(" t show/set TLB contents\n");
|
|
cPrintf(" i initialize hardware\n");
|
|
cPrintf(" q quit simulator\n");
|
|
cPrintf("type 'help <cmd>' to get help for <cmd>\n");
|
|
}
|
|
|
|
|
|
static void help00(void) {
|
|
cPrintf(" help show a list of commands\n");
|
|
cPrintf(" help <cmd> show help for <cmd>\n");
|
|
}
|
|
|
|
|
|
static void help01(void) {
|
cPrintf(" + <num1> <num2> add and subtract <num1> and <num2>\n");
|
cPrintf(" + <num1> <num2> add and subtract <num1> and <num2>\n");
|
|
}
|
|
|
|
|
|
static void help02(void) {
|
cPrintf(" a assemble starting at PC\n");
|
cPrintf(" a assemble starting at PC\n");
|
cPrintf(" a <addr> assemble starting at <addr>\n");
|
cPrintf(" a <addr> assemble starting at <addr>\n");
|
|
}
|
|
|
|
|
|
static void help03(void) {
|
cPrintf(" u unassemble 16 instrs starting at PC\n");
|
cPrintf(" u unassemble 16 instrs starting at PC\n");
|
cPrintf(" u <addr> unassemble 16 instrs starting at <addr>\n");
|
cPrintf(" u <addr> unassemble 16 instrs starting at <addr>\n");
|
cPrintf(" u <addr> <cnt> unassemble <cnt> instrs starting at <addr>\n");
|
cPrintf(" u <addr> <cnt> unassemble <cnt> instrs starting at <addr>\n");
|
|
}
|
|
|
|
|
|
static void help04(void) {
|
cPrintf(" b reset break\n");
|
cPrintf(" b reset break\n");
|
cPrintf(" b <addr> set break at <addr>\n");
|
cPrintf(" b <addr> set break at <addr>\n");
|
|
}
|
|
|
|
|
|
static void help05(void) {
|
cPrintf(" c continue execution\n");
|
cPrintf(" c continue execution\n");
|
cPrintf(" c <cnt> continue execution <cnt> times\n");
|
cPrintf(" c <cnt> continue execution <cnt> times\n");
|
|
}
|
|
|
|
|
|
static void help06(void) {
|
cPrintf(" s single-step one instruction\n");
|
cPrintf(" s single-step one instruction\n");
|
cPrintf(" s <cnt> single-step <cnt> instructions\n");
|
cPrintf(" s <cnt> single-step <cnt> instructions\n");
|
cPrintf(" @ show PC\n");
|
}
|
cPrintf(" @ <addr> set PC to <addr>\n");
|
|
|
|
|
static void help07(void) {
|
|
cPrintf(" # show PC\n");
|
|
cPrintf(" # <addr> set PC to <addr>\n");
|
|
}
|
|
|
|
|
|
static void help08(void) {
|
cPrintf(" p show PSW\n");
|
cPrintf(" p show PSW\n");
|
cPrintf(" p <data> set PSW to <data>\n");
|
cPrintf(" p <data> set PSW to <data>\n");
|
|
}
|
|
|
|
|
|
static void help09(void) {
|
cPrintf(" r show all registers\n");
|
cPrintf(" r show all registers\n");
|
cPrintf(" r <reg> show register <reg>\n");
|
cPrintf(" r <reg> show register <reg>\n");
|
cPrintf(" r <reg> <data> set register <reg> to <data>\n");
|
cPrintf(" r <reg> <data> set register <reg> to <data>\n");
|
|
}
|
|
|
|
|
|
static void help10(void) {
|
cPrintf(" d dump 256 bytes starting at PC\n");
|
cPrintf(" d dump 256 bytes starting at PC\n");
|
cPrintf(" d <addr> dump 256 bytes starting at <addr>\n");
|
cPrintf(" d <addr> dump 256 bytes starting at <addr>\n");
|
cPrintf(" d <addr> <cnt> dump <cnt> bytes starting at <addr>\n");
|
cPrintf(" d <addr> <cnt> dump <cnt> bytes starting at <addr>\n");
|
|
}
|
|
|
|
|
|
static void help11(void) {
|
cPrintf(" mw show memory word at PC\n");
|
cPrintf(" mw show memory word at PC\n");
|
cPrintf(" mw <addr> show memory word at <addr>\n");
|
cPrintf(" mw <addr> show memory word at <addr>\n");
|
cPrintf(" mw <addr> <data> set memory word at <addr> to <data>\n");
|
cPrintf(" mw <addr> <data> set memory word at <addr> to <data>\n");
|
|
}
|
|
|
|
|
|
static void help12(void) {
|
cPrintf(" mh show memory halfword at PC\n");
|
cPrintf(" mh show memory halfword at PC\n");
|
cPrintf(" mh <addr> show memory halfword at <addr>\n");
|
cPrintf(" mh <addr> show memory halfword at <addr>\n");
|
cPrintf(" mh <addr> <data> set memory halfword at <addr> to <data>\n");
|
cPrintf(" mh <addr> <data> set memory halfword at <addr> to <data>\n");
|
|
}
|
|
|
|
|
|
static void help13(void) {
|
cPrintf(" mb show memory byte at PC\n");
|
cPrintf(" mb show memory byte at PC\n");
|
cPrintf(" mb <addr> show memory byte at <addr>\n");
|
cPrintf(" mb <addr> show memory byte at <addr>\n");
|
cPrintf(" mb <addr> <data> set memory byte at <addr> to <data>\n");
|
cPrintf(" mb <addr> <data> set memory byte at <addr> to <data>\n");
|
|
}
|
|
|
|
|
|
static void help14(void) {
|
cPrintf(" t show TLB contents\n");
|
cPrintf(" t show TLB contents\n");
|
cPrintf(" t <i> show TLB contents at <i>\n");
|
cPrintf(" t <i> show TLB contents at <i>\n");
|
cPrintf(" t <i> p <data> set TLB contents at <i> to page <data>\n");
|
cPrintf(" t <i> p <data> set TLB contents at <i> to page <data>\n");
|
cPrintf(" t <i> f <data> set TLB contents at <i> to frame <data>\n");
|
cPrintf(" t <i> f <data> set TLB contents at <i> to frame <data>\n");
|
|
}
|
|
|
|
|
|
static void help15(void) {
|
cPrintf(" i initialize hardware\n");
|
cPrintf(" i initialize hardware\n");
|
|
}
|
|
|
|
|
|
static void help16(void) {
|
cPrintf(" q quit simulator\n");
|
cPrintf(" q quit simulator\n");
|
}
|
}
|
|
|
|
|
static char *cause[32] = {
|
static char *cause[32] = {
|
Line 192... |
Line 290... |
}
|
}
|
cPrintf("\n");
|
cPrintf("\n");
|
}
|
}
|
|
|
|
|
|
static void doHelp(char *tokens[], int n) {
|
|
int i;
|
|
|
|
if (n == 1) {
|
|
help();
|
|
} else if (n == 2) {
|
|
for (i = 0; i < numCommands; i++) {
|
|
if (strcmp(commands[i].name, tokens[1]) == 0) {
|
|
(*commands[i].hlpProc)();
|
|
return;
|
|
}
|
|
}
|
|
cPrintf("no help available for '%s', sorry\n", tokens[1]);
|
|
} else {
|
|
help00();
|
|
}
|
|
}
|
|
|
|
|
static void doArith(char *tokens[], int n) {
|
static void doArith(char *tokens[], int n) {
|
Word num1, num2, num3, num4;
|
Word num1, num2, num3, num4;
|
|
|
if (n == 3) {
|
if (n == 3) {
|
if (!getHexNumber(tokens[1], &num1)) {
|
if (!getHexNumber(tokens[1], &num1)) {
|
Line 235... |
Line 352... |
return;
|
return;
|
}
|
}
|
addr &= ~0x00000003;
|
addr &= ~0x00000003;
|
psw = cpuGetPSW();
|
psw = cpuGetPSW();
|
while (1) {
|
while (1) {
|
sprintf(prompt, "ASM @ %08X: ", addr);
|
sprintf(prompt, "ASM # %08X: ", addr);
|
line = cGetLine(prompt);
|
line = cGetLine(prompt);
|
if (*line == '\0' || *line == '\n') {
|
if (*line == '\0' || *line == '\n') {
|
break;
|
break;
|
}
|
}
|
cAddHist(line);
|
cAddHist(line);
|
Line 752... |
Line 869... |
help();
|
help();
|
}
|
}
|
}
|
}
|
|
|
|
|
typedef struct {
|
Command commands[] = {
|
char *name;
|
{ "help", help00, doHelp },
|
void (*cmdProc)(char *tokens[], int n);
|
{ "+", help01, doArith },
|
} Command;
|
{ "a", help02, doAssemble },
|
|
{ "u", help03, doUnassemble },
|
|
{ "b", help04, doBreak },
|
static Command commands[] = {
|
{ "c", help05, doContinue },
|
{ "+", doArith },
|
{ "s", help06, doStep },
|
{ "a", doAssemble },
|
{ "#", help07, doPC },
|
{ "u", doUnassemble },
|
{ "p", help08, doPSW },
|
{ "b", doBreak },
|
{ "r", help09, doRegister },
|
{ "c", doContinue },
|
{ "d", help10, doDump },
|
{ "s", doStep },
|
{ "mw", help11, doMemoryWord },
|
{ "@", doPC },
|
{ "mh", help12, doMemoryHalf },
|
{ "p", doPSW },
|
{ "mb", help13, doMemoryByte },
|
{ "r", doRegister },
|
{ "t", help14, doTLB },
|
{ "d", doDump },
|
{ "i", help15, doInit },
|
{ "mw", doMemoryWord },
|
{ "q", help16, doQuit },
|
{ "mh", doMemoryHalf },
|
|
{ "mb", doMemoryByte },
|
|
{ "t", doTLB },
|
|
{ "i", doInit },
|
|
{ "q", doQuit }
|
|
};
|
};
|
|
|
|
int numCommands = sizeof(commands) / sizeof(commands[0]);
|
|
|
|
|
static Bool doCommand(char *line) {
|
static Bool doCommand(char *line) {
|
char *tokens[MAX_TOKENS];
|
char *tokens[MAX_TOKENS];
|
int n;
|
int n;
|
char *p;
|
char *p;
|