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)
49 COMMAND_DO_WORK_UC(cl_set_mem_cmd)
52 class cl_cmd_arg *params[4]= { cmdline->param(0),
57 if (cmdline->syntax_match(uc, MEMORY ADDRESS DATALIST)) {
58 mem= params[0]->value.memory;
59 t_addr start= params[1]->value.address;
60 t_mem *array= params[2]->value.data_list.array;
61 int len= params[2]->value.data_list.len;
64 con->printf("Error: no data\n");
69 for (i= 0, addr= start;
70 i < len && addr < mem->size;
72 mem->write(addr, &(array[i]));
73 mem->dump(start, start+len-1, 8, con);
77 con->printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
85 *----------------------------------------------------------------------------
89 //cl_set_bit_cmd::do_work(class cl_sim *sim,
90 // class cl_cmdline *cmdline, class cl_console *con)
91 COMMAND_DO_WORK_UC(cl_set_bit_cmd)
96 class cl_cmd_arg *params[4]= { cmdline->param(0),
101 if (cmdline->syntax_match(uc, BIT NUMBER)) {
102 mem= params[0]->value.bit.mem;
103 mem_addr= params[0]->value.bit.mem_address;
104 bit_mask= params[0]->value.bit.mask;
105 if (params[1]->value.number)
106 mem->set_bit1(mem_addr, bit_mask);
108 mem->set_bit0(mem_addr, bit_mask);
109 mem->dump(mem_addr, mem_addr, 1, con);
112 con->printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
120 *----------------------------------------------------------------------------
124 //cl_set_port_cmd::do_work(class cl_sim *sim,
125 // class cl_cmdline *cmdline, class cl_console *con)
126 COMMAND_DO_WORK_UC(cl_set_port_cmd)
130 class cl_cmd_arg *params[4]= { cmdline->param(0),
135 if (cmdline->syntax_match(uc, HW NUMBER)) {
136 hw= params[0]->value.hw;
138 l= params[1]->value.number;
140 else if (cmdline->syntax_match(uc, NUMBER NUMBER)) {
141 pn= params[0]->value.number;
142 l= params[1]->value.number;
145 con->printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
148 con->printf("Error: wrong port\n");
150 uc->port_pins[pn]= l;
156 * Command: set option
157 *----------------------------------------------------------------------------
161 //cl_set_option_cmd::do_work(class cl_sim *sim,
162 // class cl_cmdline *cmdline, class cl_console *con)
163 COMMAND_DO_WORK_UC(cl_set_option_cmd)
166 class cl_cmd_arg *params[4]= { cmdline->param(0),
171 if (cmdline->syntax_match(uc, STRING STRING)) {
172 id= params[0]->value.string.string;
173 s= params[1]->value.string.string;
176 con->printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
180 con->printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
185 for (i= 0; i < uc->options->count; i++)
187 class cl_option *o= (class cl_option *)(uc->options->at(i));
188 if (!strcmp(id, o->id))
198 /* End of cmd.src/set.cc */