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
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
44 *----------------------------------------------------------------------------
48 //cl_set_mem_cmd::do_work(class cl_sim *sim,
49 // class cl_cmdline *cmdline, class cl_console *con)
50 COMMAND_DO_WORK_UC(cl_set_mem_cmd)
53 class cl_cmd_arg *params[4]= { cmdline->param(0),
58 if (cmdline->syntax_match(uc, MEMORY ADDRESS DATALIST)) {
59 mem= params[0]->value.memory;
60 t_addr start= params[1]->value.address;
61 t_mem *array= params[2]->value.data_list.array;
62 int len= params[2]->value.data_list.len;
65 con->dd_printf("Error: no data\n");
70 for (i= 0, addr= start;
71 i < len && addr <= mem->size;
73 mem->set(addr, array[i]);
75 mem->dump(start, start+len-1, 8, con);
79 con->dd_printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
87 *----------------------------------------------------------------------------
91 //cl_set_bit_cmd::do_work(class cl_sim *sim,
92 // class cl_cmdline *cmdline, class cl_console *con)
93 COMMAND_DO_WORK_UC(cl_set_bit_cmd)
98 class cl_cmd_arg *params[4]= { cmdline->param(0),
103 if (cmdline->syntax_match(uc, BIT NUMBER)) {
104 mem= params[0]->value.bit.mem;
105 mem_addr= params[0]->value.bit.mem_address;
106 bit_mask= params[0]->value.bit.mask;
107 if (params[1]->value.number)
108 mem->set_bit1(mem_addr, bit_mask);
110 mem->set_bit0(mem_addr, bit_mask);
111 mem->dump(mem_addr, mem_addr, 1, con);
114 con->dd_printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
122 *----------------------------------------------------------------------------
125 COMMAND_DO_WORK_UC(cl_set_hw_cmd)
128 class cl_cmd_arg *params[1]= { cmdline->param(0)/*,
131 cmdline->param(3)*/ };
133 if (/*cmdline->syntax_match(uc, HW)*/params[0]->as_hw(uc)) {
134 hw= params[0]->value.hw;
136 //l= params[1]->value.number;
138 /*else if (cmdline->syntax_match(uc, NUMBER NUMBER)) {
139 pn= params[0]->value.number;
140 l= params[1]->value.number;
141 hw= uc->get_hw(HW_PORT, pn, 0);
144 con->dd_printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
147 con->dd_printf("Error: wrong port\n");
153 hw->set_cmd(cmdline, con);
156 con->dd_printf("Error: no hw\n");
163 * Command: set option
164 *----------------------------------------------------------------------------
168 //cl_set_option_cmd::do_work(class cl_sim *sim,
169 // class cl_cmdline *cmdline, class cl_console *con)
170 COMMAND_DO_WORK_APP(cl_set_option_cmd)
174 class cl_cmd_arg *params[4]= { cmdline->param(0),
178 class cl_option *option= 0;
180 if (cmdline->syntax_match(0, STRING STRING STRING)) {
181 id= params[0]->value.string.string;
182 char *cr= params[1]->value.string.string;
183 s= params[2]->value.string.string;
184 int n= app->options->nuof_options(id, cr);
187 con->dd_printf("Ambiguous option name, use number instead\n");
191 ;//con->dd_printf("Named option does not exist\n");
194 if ((option= app->options->get_option(id, cr)) == 0)
195 option= app->options->get_option(cr, id);
198 else if (cmdline->syntax_match(0/*app->get_uc()*/, NUMBER STRING)) {
199 idx= params[0]->value.number;
200 s= params[1]->value.string.string;
201 option= app->options->get_option(idx);
203 else if (cmdline->syntax_match(0/*app->get_uc()*/, STRING STRING)) {
204 id= params[0]->value.string.string;
205 s= params[1]->value.string.string;
206 int n= app->options->nuof_options(id);
209 con->dd_printf("Ambiguous option name, use number instead\n");
213 ;//con->dd_printf("Named option does not exist\n");
215 option= app->options->get_option(id);
218 con->dd_printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
221 con->dd_printf("Option does not exist\n");
225 option->set_value(s);
231 /* End of cmd.src/set.cc */