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
43 *----------------------------------------------------------------------------
47 cl_set_mem_cmd::do_work(class cl_sim *sim,
48 class cl_cmdline *cmdline, class cl_console *con)
51 class cl_cmd_arg *params[4]= { cmdline->param(0),
56 if (cmdline->syntax_match(sim, MEMORY ADDRESS DATALIST)) {
57 mem= params[0]->value.memory;
58 t_addr start= params[1]->value.address;
59 t_mem *array= params[2]->value.data_list.array;
60 int len= params[2]->value.data_list.len;
63 con->printf("Error: no data\n");
68 for (i= 0, addr= start;
69 i < len && addr < mem->size;
71 mem->write(addr, &(array[i]));
72 mem->dump(start, start+len-1, 8, con);
76 con->printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
84 *----------------------------------------------------------------------------
88 cl_set_bit_cmd::do_work(class cl_sim *sim,
89 class cl_cmdline *cmdline, class cl_console *con)
94 class cl_cmd_arg *params[4]= { cmdline->param(0),
99 if (cmdline->syntax_match(sim, BIT NUMBER)) {
100 mem= params[0]->value.bit.mem;
101 mem_addr= params[0]->value.bit.mem_address;
102 bit_mask= params[0]->value.bit.mask;
103 if (params[1]->value.number)
104 mem->set_bit1(mem_addr, bit_mask);
106 mem->set_bit0(mem_addr, bit_mask);
107 mem->dump(mem_addr, mem_addr, 1, con);
110 con->printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
118 *----------------------------------------------------------------------------
122 cl_set_port_cmd::do_work(class cl_sim *sim,
123 class cl_cmdline *cmdline, class cl_console *con)
127 class cl_cmd_arg *params[4]= { cmdline->param(0),
132 if (cmdline->syntax_match(sim, HW NUMBER)) {
133 hw= params[0]->value.hw;
135 l= params[1]->value.number;
137 else if (cmdline->syntax_match(sim, NUMBER NUMBER)) {
138 pn= params[0]->value.number;
139 l= params[1]->value.number;
142 con->printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
145 con->printf("Error: wrong port\n");
147 sim->uc->port_pins[pn]= l;
153 * Command: set option
154 *----------------------------------------------------------------------------
158 cl_set_option_cmd::do_work(class cl_sim *sim,
159 class cl_cmdline *cmdline, class cl_console *con)
162 class cl_cmd_arg *params[4]= { cmdline->param(0),
167 if (cmdline->syntax_match(sim, STRING STRING)) {
168 id= params[0]->value.string.string;
169 s= params[1]->value.string.string;
172 con->printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
176 con->printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
181 for (i= 0; i < sim->uc->options->count; i++)
183 class cl_option *o= (class cl_option *)(sim->uc->options->at(i));
184 if (!strcmp(id, o->id))
194 /* End of cmd.src/set.cc */