2 * Simulator of microcontrollers (cmd.src/cmdset.cc)
4 * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
6 * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
10 /* This file is part of microcontroller simulator: ucsim.
12 UCSIM is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 UCSIM is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with UCSIM; see the file COPYING. If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
45 *----------------------------------------------------------------------------
49 //cl_run_cmd::do_work(class cl_sim *sim,
50 // class cl_cmdline *cmdline, class cl_console *con)
51 COMMAND_DO_WORK_SIM(cl_run_cmd)
55 class cl_cmd_arg *params[4]= { cmdline->param(0),
61 if (!(params[0]->get_address(sim->uc, &start)))
63 con->dd_printf("Error: wrong start address\n");
67 if (!(params[1]->get_address(sim->uc, &end)))
69 con->dd_printf("Error: wromg end address\n");
74 if (!sim->uc->inst_at(start))
75 con->dd_printf("Warning: maybe not instruction at 0x%06lx\n", start);
81 con->dd_printf("Addresses must be different.\n");
84 if ((b= sim->uc->fbrk_at(end)))
89 b= new cl_fetch_brk(sim->uc->make_new_brknr(), end,
91 sim->uc->fbrk->add_bp(b);
95 con->dd_printf("Simulation started, PC=0x%06x\n", sim->uc->PC);
96 if (sim->uc->fbrk_at(start))
105 *----------------------------------------------------------------------------
109 //cl_stop_cmd::do_work(class cl_sim *sim,
110 // class cl_cmdline *cmdline, class cl_console *con)
111 COMMAND_DO_WORK_SIM(cl_stop_cmd)
114 sim->uc->print_disass(sim->uc->PC, con);
121 *----------------------------------------------------------------------------
125 //cl_step_cmd::do_work(class cl_sim *sim,
126 // class cl_cmdline *cmdline, class cl_console *con)
127 COMMAND_DO_WORK_UC(cl_step_cmd)
137 *----------------------------------------------------------------------------
141 //cl_next_cmd::do_work(class cl_sim *sim,
142 // class cl_cmdline *cmdline, class cl_console *con)
143 COMMAND_DO_WORK_SIM(cl_next_cmd)
147 struct dis_entry *de;
149 t_mem code= sim->uc->get_mem(MEM_ROM, sim->uc->PC);
151 de= &(sim->uc->dis_tbl()[i]);
152 while ((code & de->mask) != de->code &&
156 de= &(sim->uc->dis_tbl()[i]);
158 if ((de->branch == 'a') ||
161 next= sim->uc->PC + de->length;
162 if (!sim->uc->fbrk_at(next))
164 b= new cl_fetch_brk(sim->uc->make_new_brknr(),
165 next, brkDYNAMIC, 1);
166 sim->uc->fbrk->add(b);
169 //sim->uc->do_inst(-1);
173 sim->uc->print_regs(con);
180 *----------------------------------------------------------------------------
184 //cl_help_cmd::do_work(class cl_sim *sim,
185 // class cl_cmdline *cmdline, class cl_console *con)
186 COMMAND_DO_WORK_APP(cl_help_cmd)
189 class cl_commander *cmd;
190 class cl_cmdset *cmdset= 0;
193 class cl_cmd_arg *parm= cmdline->param(0);
196 if ((cmd= app->get_commander()) != 0)
201 for (i= 0; i < cmdset->count; i++)
203 c= (class cl_cmd *)(cmdset->at(i));
205 con->dd_printf("%s\n", c->short_help);
207 con->dd_printf("%s\n", (char*)(c->names->at(0)));
210 else if (cmdline->syntax_match(/*sim*/0, STRING)) {
212 for (i= 0; i < cmdset->count; i++)
214 c= (class cl_cmd *)(cmdset->at(i));
215 if (c->name_match(parm->value.string.string, DD_FALSE))
219 con->dd_printf("No such command\n");
220 else if (matches > 1)
221 for (i= 0; i < cmdset->count; i++)
223 c= (class cl_cmd *)(cmdset->at(i));
224 if (!c->name_match(parm->value.string.string, DD_FALSE))
227 con->dd_printf("%s\n", c->short_help);
229 con->dd_printf("%s\n", (char*)(c->names->at(0)));
232 for (i= 0; i < cmdset->count; i++)
234 c= (class cl_cmd *)(cmdset->at(i));
235 if (!c->name_match(parm->value.string.string, DD_FALSE))
238 con->dd_printf("%s\n", c->short_help);
240 con->dd_printf("%s\n", (char*)(c->names->at(0)));
242 con->dd_printf("Names of command:");
243 for (names= 0; names < c->names->count; names++)
244 con->dd_printf(" %s", (char*)(c->names->at(names)));
245 con->dd_printf("\n");
247 con->dd_printf("%s\n", c->long_help);
249 con->dd_printf("%s\n", (char*)(c->names->at(0)));
253 con->dd_printf("%s\n", short_help?short_help:"Error: wrong syntax");
261 *----------------------------------------------------------------------------
265 //cl_quit_cmd::do_work(class cl_sim *sim,
266 // class cl_cmdline */*cmdline*/, class cl_console */*con*/)
267 COMMAND_DO_WORK(cl_quit_cmd)
275 *----------------------------------------------------------------------------
279 //cl_kill_cmd::do_work(class cl_sim *sim,
280 // class cl_cmdline */*cmdline*/, class cl_console */*con*/)
281 COMMAND_DO_WORK_APP(cl_kill_cmd)
285 app->sim->state|= SIM_QUIT;
290 /* End of cmd.src/cmdset.cc */