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->printf("Error: no data\n");
70 for (i= 0, addr= start;
71 i < len && addr < mem->size;
73 mem->write(addr, &(array[i]));
74 mem->dump(start, start+len-1, 8, con);
78 con->printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
86 *----------------------------------------------------------------------------
90 //cl_set_bit_cmd::do_work(class cl_sim *sim,
91 // class cl_cmdline *cmdline, class cl_console *con)
92 COMMAND_DO_WORK_UC(cl_set_bit_cmd)
97 class cl_cmd_arg *params[4]= { cmdline->param(0),
102 if (cmdline->syntax_match(uc, BIT NUMBER)) {
103 mem= params[0]->value.bit.mem;
104 mem_addr= params[0]->value.bit.mem_address;
105 bit_mask= params[0]->value.bit.mask;
106 if (params[1]->value.number)
107 mem->set_bit1(mem_addr, bit_mask);
109 mem->set_bit0(mem_addr, bit_mask);
110 mem->dump(mem_addr, mem_addr, 1, con);
113 con->printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
121 *----------------------------------------------------------------------------
125 //cl_set_port_cmd::do_work(class cl_sim *sim,
126 // class cl_cmdline *cmdline, class cl_console *con)
127 COMMAND_DO_WORK_UC(cl_set_port_cmd)
131 class cl_cmd_arg *params[4]= { cmdline->param(0),
136 if (cmdline->syntax_match(uc, HW NUMBER)) {
137 hw= params[0]->value.hw;
139 l= params[1]->value.number;
141 else if (cmdline->syntax_match(uc, NUMBER NUMBER)) {
142 pn= params[0]->value.number;
143 l= params[1]->value.number;
146 con->printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
149 con->printf("Error: wrong port\n");
151 uc->port_pins[pn]= l;
157 * Command: set option
158 *----------------------------------------------------------------------------
162 //cl_set_option_cmd::do_work(class cl_sim *sim,
163 // class cl_cmdline *cmdline, class cl_console *con)
164 COMMAND_DO_WORK_UC(cl_set_option_cmd)
167 class cl_cmd_arg *params[4]= { cmdline->param(0),
172 if (cmdline->syntax_match(uc, STRING STRING)) {
173 id= params[0]->value.string.string;
174 s= params[1]->value.string.string;
177 con->printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
181 con->printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
186 for (i= 0; i < uc->options->count; i++)
188 class cl_option *o= (class cl_option *)(uc->options->at(i));
189 if (!strcmp(id, o->id))
199 /* End of cmd.src/set.cc */