X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=sim%2Fucsim%2Fcmd.src%2Fset.cc;h=07d0134c12a2eaa65e625512c9bce1ae17a20c3c;hb=f27da39dbcab5678aca6d8462f1cc37a643f37e9;hp=2c1387eb6036736d1e5da260dacc647f0a679ee2;hpb=7fe573ea83f6e0762dc73bc493f15fa2a8f6273d;p=fw%2Fsdcc diff --git a/sim/ucsim/cmd.src/set.cc b/sim/ucsim/cmd.src/set.cc index 2c1387eb..07d0134c 100644 --- a/sim/ucsim/cmd.src/set.cc +++ b/sim/ucsim/cmd.src/set.cc @@ -7,22 +7,24 @@ * */ -/* This file is part of microcontroller simulator: ucsim. - -UCSIM is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -UCSIM is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with UCSIM; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. */ +/* + This file is part of microcontroller simulator: ucsim. + + UCSIM is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + UCSIM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with UCSIM; see the file COPYING. If not, write to the Free + Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ /*@1@*/ #include "ddconfig.h" @@ -30,6 +32,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include "i_string.h" +// prj +#include "errorcl.h" + // sim #include "simcl.h" #include "optioncl.h" @@ -49,28 +54,31 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA // class cl_cmdline *cmdline, class cl_console *con) COMMAND_DO_WORK_UC(cl_set_mem_cmd) { - class cl_mem *mem= 0; + class cl_memory *mem= 0; class cl_cmd_arg *params[4]= { cmdline->param(0), cmdline->param(1), cmdline->param(2), cmdline->param(3) }; if (cmdline->syntax_match(uc, MEMORY ADDRESS DATALIST)) { - mem= params[0]->value.memory; + mem= params[0]->value.memory.memory; t_addr start= params[1]->value.address; t_mem *array= params[2]->value.data_list.array; int len= params[2]->value.data_list.len; if (len == 0) con->dd_printf("Error: no data\n"); + else if (start < mem->get_start_address()) + con->dd_printf("Start address less then 0x%"_A_"x\n", + mem->get_start_address()); else { int i; t_addr addr; for (i= 0, addr= start; - i < len && addr <= mem->size; + i < len && mem->valid_address(addr); i++, addr++) - mem->set(addr, array[i]); + mem->write(addr, array[i]); uc->check_errors(); mem->dump(start, start+len-1, 8, con); } @@ -92,7 +100,7 @@ COMMAND_DO_WORK_UC(cl_set_mem_cmd) // class cl_cmdline *cmdline, class cl_console *con) COMMAND_DO_WORK_UC(cl_set_bit_cmd) { - class cl_mem *mem; + class cl_memory *mem; t_addr mem_addr= 0; t_mem bit_mask= 0; class cl_cmd_arg *params[4]= { cmdline->param(0), @@ -130,7 +138,7 @@ COMMAND_DO_WORK_UC(cl_set_hw_cmd) cmdline->param(2), cmdline->param(3)*/ }; - if (/*cmdline->syntax_match(uc, HW)*/params[0]->as_hw(uc)) { + if (params[0] && /*cmdline->syntax_match(uc, HW)*/params[0]->as_hw(uc)) { hw= params[0]->value.hw; //pn= hw->id; //l= params[1]->value.number; @@ -177,7 +185,12 @@ COMMAND_DO_WORK_APP(cl_set_option_cmd) cmdline->param(3) }; class cl_option *option= 0; - if (cmdline->syntax_match(0, STRING STRING STRING)) { + if (cmdline->syntax_match(0/*app->get_uc()*/, NUMBER STRING)) { + idx= params[0]->value.number; + s= params[1]->value.string.string; + option= app->options->get_option(idx); + } + else if (cmdline->syntax_match(0, STRING STRING STRING)) { id= params[0]->value.string.string; char *cr= params[1]->value.string.string; s= params[2]->value.string.string; @@ -195,11 +208,6 @@ COMMAND_DO_WORK_APP(cl_set_option_cmd) option= app->options->get_option(cr, id); } } - else if (cmdline->syntax_match(0/*app->get_uc()*/, NUMBER STRING)) { - idx= params[0]->value.number; - s= params[1]->value.string.string; - option= app->options->get_option(idx); - } else if (cmdline->syntax_match(0/*app->get_uc()*/, STRING STRING)) { id= params[0]->value.string.string; s= params[1]->value.string.string; @@ -224,7 +232,63 @@ COMMAND_DO_WORK_APP(cl_set_option_cmd) option->set_value(s); - return(DD_FALSE);; + return(DD_FALSE); +} + + +/* + * Command: set error + *---------------------------------------------------------------------------- + */ + +//int +//cl_set_option_cmd::do_work(class cl_sim *sim, +// class cl_cmdline *cmdline, class cl_console *con) +COMMAND_DO_WORK_APP(cl_set_error_cmd) +{ + class cl_cmd_arg *params[4]= { cmdline->param(0), + cmdline->param(1), + cmdline->param(2), + cmdline->param(3) }; + char *error_name= NIL, *value= NIL; + + if (cmdline->syntax_match(0/*app->get_uc()*/, STRING STRING)) { + error_name= params[0]->value.string.string; + value= params[1]->value.string.string; + } + else + con->dd_printf("%s\n", short_help?short_help:"Error: wrong syntax\n"); + + if (error_name && + value && + registered_errors) + { + int i; + for (i= 0; i < registered_errors->count; i++) + { + class cl_error_class *e= + dynamic_cast(registered_errors->object_at(i)); + if (e->is_inamed(error_name)) + { + if (strchr("uU-?", *value) != NULL) + e->set_on(ERROR_PARENT); + else if (strchr("1tTyY", *value) != NULL || + (strlen(value) > 1 && + strchr("nN", value[2]) != NULL)) + e->set_on(ERROR_ON); + else if (strchr("0fFnN", *value) != NULL || + (strlen(value) > 1 && + strchr("fF", value[2]) != NULL)) + e->set_on(ERROR_OFF); + else + con->dd_printf("Bad value (%s)\n", value); + return(DD_FALSE); + } + } + } + con->dd_printf("Error %s not found\n", error_name); + + return(DD_FALSE); }