2 * Copyright © 2008 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 static enum command_result
22 parse_int(char *value, int *result)
26 *result = strtol(value, &endptr, 0);
28 return command_syntax;
29 return command_proceed;
32 static enum command_result
33 parse_uint16(char *value, uint16_t *uint16)
36 enum command_result result;
38 result = parse_int(value, &v);
39 if (result != command_proceed)
41 if (v < 0 || v > 0xffff)
44 return command_proceed;
48 command_quit (FILE *output, int argc, char **argv)
55 command_di (FILE *output, int argc, char **argv)
61 command_ds (FILE *output, int argc, char **argv)
67 command_dx (FILE *output, int argc, char **argv)
73 command_set (FILE *output, int argc, char **argv)
79 command_dump (FILE *output, int argc, char **argv)
85 command_pc (FILE *output, int argc, char **argv)
89 enum command_result result;
91 result = parse_uint16(argv[1], &pc);
92 if (result != command_proceed)
94 ccdbg_set_pc(s51_dbg, pc);
96 pc = ccdbg_get_pc(s51_dbg);
97 printf (" 0x%04x\n", pc);
99 return command_proceed;
103 command_break (FILE *output, int argc, char **argv)
105 return command_error;
109 command_clear (FILE *output, int argc, char **argv)
111 return command_error;
115 command_run (FILE *output, int argc, char **argv)
118 enum command_result result;
121 result = parse_uint16(argv[1], &start);
122 if (result != command_proceed)
125 result = parse_uint16(argv[2], &end);
126 if (result != command_proceed)
129 ccdbg_set_pc(s51_dbg, start);
132 start = ccdbg_get_pc(s51_dbg);
133 fprintf(output, "Resume at 0x%04x\n", start);
134 ccdbg_resume(s51_dbg);
135 return command_proceed;
139 command_next (FILE *output, int argc, char **argv)
141 return command_error;
145 command_step (FILE *output, int argc, char **argv)
147 return command_error;
151 command_load (FILE *output, int argc, char **argv)
153 return command_error;
157 command_halt (FILE *output, int argc, char **argv)
161 pc = ccdbg_get_pc(s51_dbg);
162 fprintf(output, "Halted at 0x%04x\n", pc);
163 return command_proceed;
167 command_reset (FILE *output, int argc, char **argv)
169 ccdbg_debug_mode(s51_dbg);
170 return command_proceed;