diff options
author | Keith Packard <keithp@keithp.com> | 2009-01-25 08:38:48 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2009-01-25 08:38:48 -0800 |
commit | 3cc8d11eb8d5d0b42141dd84a58d461287f59e3a (patch) | |
tree | 11702b387bff81165f4f4f5832a627414a48fdf3 /s51/s51-command.c | |
parent | 60940b4be23962db79b8e914ec943d0636dd68ad (diff) |
Support 'set' command
The 'set' command modifies target memory and registers
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 's51/s51-command.c')
-rw-r--r-- | s51/s51-command.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/s51/s51-command.c b/s51/s51-command.c index 63d142f4..034d5dce 100644 --- a/s51/s51-command.c +++ b/s51/s51-command.c @@ -152,7 +152,35 @@ command_dx (int argc, char **argv) enum command_result command_set (int argc, char **argv) { - return command_error; + uint16_t address; + uint8_t *data; + int len = argc - 3; + int i; + enum command_result ret = command_success; + + if (len < 0) + return command_error; + if (parse_uint16(argv[2], &address) != command_success) + return command_error; + if (len == 0) + return command_success; + data = malloc(len); + if (!data) + return command_error; + for (i = 0; i < len; i++) + if (parse_uint8(argv[i+3], &data[i]) != command_success) + return command_error; + + if (strcmp(argv[1], "xram") == 0) { + ccdbg_write_memory(s51_dbg, address, data, len); + } else if (strcmp(argv[1], "iram") == 0) { + ccdbg_write_memory(s51_dbg, address + 0xff00, data, len); + } else if (strcmp(argv[1], "sfr") == 0) { + ccdbg_write_sfr(s51_dbg, (uint8_t) address, data, len); + } else + ret = command_error; + free(data); + return ret; } enum command_result |