2 * Simulator of microcontrollers (cmd.src/set.cc)
4 * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
6 * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
11 This file is part of microcontroller simulator: ucsim.
13 UCSIM is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
18 UCSIM is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with UCSIM; see the file COPYING. If not, write to the Free
25 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
49 *----------------------------------------------------------------------------
53 //cl_set_mem_cmd::do_work(class cl_sim *sim,
54 // class cl_cmdline *cmdline, class cl_console_base *con)
55 COMMAND_DO_WORK_UC(cl_set_mem_cmd)
57 class cl_memory *mem= 0;
58 class cl_cmd_arg *params[4]= { cmdline->param(0),
63 if (cmdline->syntax_match(uc, MEMORY ADDRESS DATALIST)) {
64 mem= params[0]->value.memory.memory;
65 t_addr start= params[1]->value.address;
66 t_mem *array= params[2]->value.data_list.array;
67 int len= params[2]->value.data_list.len;
70 con->dd_printf("Error: no data\n");
71 else if (start < mem->get_start_address())
72 con->dd_printf("Start address less then 0x%"_A_"x\n",
73 mem->get_start_address());
78 for (i= 0, addr= start;
79 i < len && mem->valid_address(addr);
81 mem->write(addr, array[i]);
83 mem->dump(start, start+len-1, 8, con);
87 con->dd_printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
95 *----------------------------------------------------------------------------
99 //cl_set_bit_cmd::do_work(class cl_sim *sim,
100 // class cl_cmdline *cmdline, class cl_console_base *con)
101 COMMAND_DO_WORK_UC(cl_set_bit_cmd)
103 class cl_memory *mem;
106 class cl_cmd_arg *params[4]= { cmdline->param(0),
111 if (cmdline->syntax_match(uc, BIT NUMBER)) {
112 mem= params[0]->value.bit.mem;
113 mem_addr= params[0]->value.bit.mem_address;
114 bit_mask= params[0]->value.bit.mask;
115 if (params[1]->value.number)
116 mem->set_bit1(mem_addr, bit_mask);
118 mem->set_bit0(mem_addr, bit_mask);
119 mem->dump(mem_addr, mem_addr, 1, con);
122 con->dd_printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
130 *----------------------------------------------------------------------------
133 COMMAND_DO_WORK_UC(cl_set_hw_cmd)
136 class cl_cmd_arg *params[1]= { cmdline->param(0)/*,
139 cmdline->param(3)*/ };
141 if (params[0] && /*cmdline->syntax_match(uc, HW)*/params[0]->as_hw(uc)) {
142 hw= params[0]->value.hw;
144 //l= params[1]->value.number;
146 /*else if (cmdline->syntax_match(uc, NUMBER NUMBER)) {
147 pn= params[0]->value.number;
148 l= params[1]->value.number;
149 hw= uc->get_hw(HW_PORT, pn, 0);
152 con->dd_printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
155 con->dd_printf("Error: wrong port\n");
161 hw->set_cmd(cmdline, con);
164 con->dd_printf("Error: no hw\n");
171 * Command: set option
172 *----------------------------------------------------------------------------
176 //cl_set_option_cmd::do_work(class cl_sim *sim,
177 // class cl_cmdline *cmdline, class cl_console_base *con)
178 COMMAND_DO_WORK_APP(cl_set_option_cmd)
182 class cl_cmd_arg *params[4]= { cmdline->param(0),
186 class cl_option *option= 0;
188 if (cmdline->syntax_match(0/*app->get_uc()*/, NUMBER STRING)) {
189 idx= params[0]->value.number;
190 s= params[1]->value.string.string;
191 option= app->options->get_option(idx);
193 else if (cmdline->syntax_match(0, STRING STRING STRING)) {
194 id= params[0]->value.string.string;
195 char *cr= params[1]->value.string.string;
196 s= params[2]->value.string.string;
197 int n= app->options->nuof_options(id, cr);
200 con->dd_printf("Ambiguous option name, use number instead\n");
204 ;//con->dd_printf("Named option does not exist\n");
207 if ((option= app->options->get_option(id, cr)) == 0)
208 option= app->options->get_option(cr, id);
211 else if (cmdline->syntax_match(0/*app->get_uc()*/, STRING STRING)) {
212 id= params[0]->value.string.string;
213 s= params[1]->value.string.string;
214 int n= app->options->nuof_options(id);
217 con->dd_printf("Ambiguous option name, use number instead\n");
221 ;//con->dd_printf("Named option does not exist\n");
223 option= app->options->get_option(id);
226 con->dd_printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
229 con->dd_printf("Option does not exist\n");
233 option->set_value(s);
241 *----------------------------------------------------------------------------
245 //cl_set_option_cmd::do_work(class cl_sim *sim,
246 // class cl_cmdline *cmdline, class cl_console_base *con)
247 COMMAND_DO_WORK_APP(cl_set_error_cmd)
249 class cl_cmd_arg *params[4]= { cmdline->param(0),
253 char *error_name= NIL, *value= NIL;
255 if (cmdline->syntax_match(0/*app->get_uc()*/, STRING STRING)) {
256 error_name= params[0]->value.string.string;
257 value= params[1]->value.string.string;
260 con->dd_printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
262 class cl_list *registered_errors = cl_error_registry::get_list();
268 for (i= 0; i < registered_errors->count; i++)
270 class cl_error_class *e=
271 dynamic_cast<class cl_error_class *>(registered_errors->object_at(i));
272 if (e->is_inamed(error_name))
274 if (strchr("uU-?", *value) != NULL)
275 e->set_on(ERROR_PARENT);
276 else if (strchr("1tTyY", *value) != NULL ||
277 (strlen(value) > 1 &&
278 strchr("nN", value[2]) != NULL))
280 else if (strchr("0fFnN", *value) != NULL ||
281 (strlen(value) > 1 &&
282 strchr("fF", value[2]) != NULL))
283 e->set_on(ERROR_OFF);
285 con->dd_printf("Bad value (%s)\n", value);
290 con->dd_printf("Error %s not found\n", error_name);
296 /* End of cmd.src/set.cc */