diff options
author | Keith Packard <keithp@keithp.com> | 2008-12-30 22:35:53 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2008-12-30 22:38:35 -0800 |
commit | 6c2a65c743a4ffae96ed27dbc38c1bf9242ed1df (patch) | |
tree | bea5fb122dfcc2edfcff0baca30dd1166a1d24af /s51/s51-parse.c | |
parent | ea366058aa467a8a7caf17e7014758f3741ea7f7 (diff) |
Save/restore registers to host during memory operations. Cache ROM data.
Because the debug port uses instructions for most operations, the debug code
will clobber registers used by the running program. Save and restore these
to avoid corrupting application data.
If the ROM file is known, use that to return data instead of fetching it
from the target to improve performance.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 's51/s51-parse.c')
-rw-r--r-- | s51/s51-parse.c | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/s51/s51-parse.c b/s51/s51-parse.c index d0bfb45b..749d7bd8 100644 --- a/s51/s51-parse.c +++ b/s51/s51-parse.c @@ -18,14 +18,6 @@ #include "s51.h" -struct command_function { - char *name; - char *alias; - enum command_result (*func)(int argc, char **argv); - char *usage; - char *help; -}; - static struct command_function functions[] = { { "help", "?", command_help, "help", "Print this list\n" }, { "quit", "q", command_quit, "[q]uit", "Quit\n" }, @@ -50,6 +42,8 @@ static struct command_function functions[] = { "Clear break point\n" }, { "run", "r", command_run, "[r]un [start] [stop]", "Run with optional start and temp breakpoint addresses\n" }, + { "go", "g", command_run, "[g]o [start] [stop]", + "Run with optional start and temp breakpoint addresses\n" }, { "next", "n", command_next, "[n]ext", "Step over one instruction, past any call\n" }, { "step", "s", command_step, "[s]tep", @@ -62,10 +56,13 @@ static struct command_function functions[] = { "Reset the CPU\n" }, { "status","status",command_status, "status", "Display CC1111 debug status\n" }, + { "info", "i", command_info, "[i]info", + "Get information\n" }, + { "stop", "stop", command_stop, "stop", + "Ignored\n" }, + { NULL, NULL, NULL, NULL, NULL }, }; -#define NUM_FUNCTIONS (sizeof functions / sizeof functions[0]) - #ifndef FALSE #define FALSE 0 #define TRUE 1 @@ -106,17 +103,41 @@ string_to_int(char *s, int *v) return TRUE; } -static struct command_function * -command_string_to_function(char *name) +struct command_function * +command_string_to_function(struct command_function *functions, char *name) { int i; - for (i = 0; i < NUM_FUNCTIONS; i++) + for (i = 0; functions[i].name; i++) if (!strcmp(name, functions[i].name) || !strcmp(name, functions[i].alias)) return &functions[i]; return NULL; } +enum command_result +command_function_help(struct command_function *functions, int argc, char **argv) +{ + int i; + struct command_function *func; + + if (argc == 1) { + for (i = 0; functions[i].name; i++) + s51_printf("%-10s%s\n", functions[i].name, + functions[i].usage); + } else { + for (i = 1; i < argc; i++) { + func = command_string_to_function(functions, argv[i]); + if (!func) { + s51_printf("%-10s unknown command\n", argv[i]); + return command_syntax; + } + s51_printf("%-10s %s\n%s", func->name, + func->usage, func->help); + } + } + return command_debug; +} + static int command_split_into_words(char *line, char **argv) { @@ -153,28 +174,10 @@ command_split_into_words(char *line, char **argv) enum command_result command_help(int argc, char **argv) { - int i; - struct command_function *func; - - if (argc == 1) { - for (i = 0; i < NUM_FUNCTIONS; i++) - s51_printf("%-10s%s\n", functions[i].name, - functions[i].usage); - } else { - for (i = 1; i < argc; i++) { - func = command_string_to_function(argv[i]); - if (!func) { - s51_printf("%-10s unknown command\n", argv[i]); - return command_syntax; - } - s51_printf("%-10s %s\n%s", func->name, - func->usage, func->help); - } - } - return command_debug; + return command_function_help(functions, argc, argv); } -static void +void command_syntax_error(int argc, char **argv) { s51_printf("Syntax error in:"); @@ -206,7 +209,7 @@ command_read (void) s51_interrupted = 0; argc = command_split_into_words(line, argv); if (argc > 0) { - func = command_string_to_function(argv[0]); + func = command_string_to_function(functions, argv[0]); if (!func) command_syntax_error(argc, argv); else |