summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2008-12-28 00:11:13 -0800
committerKeith Packard <keithp@keithp.com>2008-12-28 00:11:13 -0800
commite0697186a2f9b6139636ff5d5c162879c85caf9c (patch)
treeb639e8ba72e95db8d6e63d41f7f34ca98779a3bc
parent23aca1fcbc169184e32d4ec19f28dd4fd4cfda36 (diff)
Use SFR access funcs. Support 'dump' command. Add -m (monitor) flag.
Not all SFRs are visible in the unified address space, so the SFR-specific accessors are required. The dump command is the same as the various 'd*' commands, but also supports dumping program memory. The new -m (monitor) flag watches the command stream between s51 and sdcdb. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--s51/s51-command.c34
-rw-r--r--s51/s51-main.c14
-rw-r--r--s51/s51.h1
3 files changed, 37 insertions, 12 deletions
diff --git a/s51/s51-command.c b/s51/s51-command.c
index b4f853be..25328f1e 100644
--- a/s51/s51-command.c
+++ b/s51/s51-command.c
@@ -46,6 +46,21 @@ parse_uint16(char *value, uint16_t *uint16)
return command_success;
}
+static enum command_result
+parse_uint8(char *value, uint8_t *uint8)
+{
+ int v;
+ enum command_result result;
+
+ result = parse_int(value, &v);
+ if (result != command_success)
+ return command_error;
+ if (v < 0 || v > 0xff)
+ return command_error;
+ *uint8 = v;
+ return command_success;
+}
+
enum command_result
command_quit (int argc, char **argv)
{
@@ -97,19 +112,19 @@ command_di (int argc, char **argv)
enum command_result
command_ds (int argc, char **argv)
{
- uint16_t start, end;
- uint8_t memory[65536];
+ uint8_t start, end;
+ uint8_t memory[0x100];
uint8_t status;
int length;
if (argc != 3)
return command_error;
- if (parse_uint16(argv[1], &start) != command_success)
+ if (parse_uint8(argv[1], &start) != command_success)
return command_error;
- if (parse_uint16(argv[2], &end) != command_success)
+ if (parse_uint8(argv[2], &end) != command_success)
return command_error;
length = (int) end - (int) start + 1;
- status = ccdbg_read_memory(s51_dbg, start + 0xdf00, memory, length);
+ status = ccdbg_read_sfr(s51_dbg, start, memory, length);
dump_bytes(memory, length, start);
return command_success;
}
@@ -143,6 +158,15 @@ command_set (int argc, char **argv)
enum command_result
command_dump (int argc, char **argv)
{
+ if (argv[1]) {
+ if (strcmp(argv[1], "rom") == 0 ||
+ strcmp(argv[1], "xram") == 0)
+ return command_dx(argc-1, argv+1);
+ if (strcmp(argv[1], "iram") == 0)
+ return command_di(argc-1, argv+1);
+ if (strcmp(argv[1], "sfr") == 0)
+ return command_ds(argc-1, argv+1);
+ }
return command_error;
}
diff --git a/s51/s51-main.c b/s51/s51-main.c
index 27ed571a..eef55157 100644
--- a/s51/s51-main.c
+++ b/s51/s51-main.c
@@ -31,6 +31,7 @@ static double freq = 11059200;
char *s51_prompt = "> ";
struct ccdbg *s51_dbg;
int s51_interrupted = 0;
+int s51_monitor = 0;
static FILE *s51_input;
static FILE *s51_output;
@@ -54,7 +55,7 @@ main(int argc, char **argv)
char *endptr;
struct sigvec vec, ovec;
- while ((opt = getopt(argc, argv, "PVvHht:X:c:r:Z:s:S:p:")) != -1) {
+ while ((opt = getopt(argc, argv, "PVvHhmt:X:c:r:Z:s:S:p:")) != -1) {
switch (opt) {
case 't':
cpu = optarg;
@@ -100,6 +101,9 @@ main(int argc, char **argv)
case 'h':
usage ();
break;
+ case 'm':
+ s51_monitor = 1;
+ break;
}
}
if (s51_port) {
@@ -174,10 +178,8 @@ s51_printf(char *format, ...)
va_start(ap, format);
vfprintf(s51_output, format, ap);
-#if 1
- if (s51_port)
+ if (s51_monitor)
vfprintf(stdout, format, ap);
-#endif
va_end(ap);
}
@@ -197,10 +199,8 @@ s51_read_line(char *line, int len)
s51_putc('\0');
fflush(s51_output);
ret = fgets(line, len, s51_input) != NULL;
-#if 1
- if (s51_port)
+ if (s51_monitor)
printf("> %s", line);
-#endif
fflush(stdout);
return ret;
}
diff --git a/s51/s51.h b/s51/s51.h
index 7c96e2a6..eab61452 100644
--- a/s51/s51.h
+++ b/s51/s51.h
@@ -21,6 +21,7 @@
extern char *s51_prompt;
extern struct ccdbg *s51_dbg;
extern int s51_interrupted;
+extern int s51_monitor;
enum command_result {
command_success, command_debug, command_syntax, command_interrupt, command_error,