-
-
-/*
- * Command: conf
- *----------------------------------------------------------------------------
- */
-
-int
-cl_conf_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con)
-{
- int i;
-
- con->printf("ucsim version %s\n", VERSIONSTR);
- con->printf("Type of microcontroller: %s\n", sim->uc->id_string());
- con->printf("Controller has %d hardware element(s).\n",
- sim->uc->hws->count);
- for (i= 0; i < sim->uc->hws->count; i++)
- {
- class cl_hw *hw= (class cl_hw *)(sim->uc->hws->at(i));
- con->printf(" %s[%d]\n", hw->id_string, hw->id);
- }
- con->printf("Memories:\n");
- for (i= MEM_ROM; i < MEM_TYPES; i++)
- {
- class cl_mem *mem= (class cl_mem *)(sim->uc->mems->at(i));
- if (mem)
- con->printf(" %s size= 0x%06x %d\n",
- mem->id_string(), mem->size, mem->size);
- }
- return(0);
-}
-
-
-/*
- * Command: state
- *----------------------------------------------------------------------------
- */
-
-int
-cl_state_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con)
-{
- //con->printf("sim state= %d\n", sim->state);
- con->printf("CPU state= %s PC= 0x%06x XTAL= %g\n",
- get_id_string(cpu_states, sim->uc->state),
- sim->uc->PC,
- sim->uc->xtal);
- con->printf("Total time since last reset= %g sec (%lu clks)\n",
- sim->uc->get_rtime(), sim->uc->ticks->ticks);
- con->printf("Time in isr = %g sec (%lu clks) %3.2g%%\n",
- sim->uc->isr_ticks->get_rtime(sim->uc->xtal),
- sim->uc->isr_ticks->ticks,
- (sim->uc->ticks->ticks == 0)?0.0:
- (100.0*((double)(sim->uc->isr_ticks->ticks)/
- (double)(sim->uc->ticks->ticks))));
- con->printf("Time in idle= %g sec (%lu clks) %3.2g%%\n",
- sim->uc->idle_ticks->get_rtime(sim->uc->xtal),
- sim->uc->idle_ticks->ticks,
- (sim->uc->ticks->ticks == 0)?0.0:
- (100.0*((double)(sim->uc->idle_ticks->ticks)/
- (double)(sim->uc->ticks->ticks))));
- con->printf("Max value of stack pointer= 0x%06x, avg= 0x%06x\n",
- sim->uc->sp_max, sim->uc->sp_avg);
- return(0);
-}
-
-
-/*
- * Command: file
- *----------------------------------------------------------------------------
- */
-
-int
-cl_file_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con)
-{
- char *fname= 0;
- long l;
-
- if ((cmdline->param(0) == 0) ||
- ((fname= cmdline->param(0)->get_svalue()) == NULL))
- {
- con->printf("File name is missing.\n");
- return(0);
- }
- if ((l= sim->uc->read_hex_file(fname)) >= 0)
- con->printf("%ld words read from %s\n", l, fname);
-
- return(0);
-}
-
-
-/*
- * Command: download
- *----------------------------------------------------------------------------
- */
-
-int
-cl_dl_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con)
-{
- long l;
-
- if ((l= sim->uc->read_hex_file(NULL)) >= 0)
- con->printf("%ld words loaded\n", l);
-
- return(0);
-}
-
-
-/*
- * Command: get
- *----------------------------------------------------------------------------
- */
-
-int
-cl_get_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con)
-{
- char *s;
-
- if (cmdline->param(0) == 0)
- {
- con->printf("Get what?\n");
- return(0);
- }
- if ((s= cmdline->param(0)->get_svalue()))
- {
- if (strstr(s, "t") == s)
- return(timer(cmdline, con));
- else
- con->printf("Unknow keyword of get command\n");
- }
- return(0);
-}
-
-
-/*
- * Command: set
- *----------------------------------------------------------------------------
- */
-
-
-int
-cl_set_cmd::do_work(class cl_cmdline *cmdline, class cl_console *con)
-{
- char *s;
-
- if (cmdline->param(0) == 0)
- {
- con->printf("Set what?\n");
- return(0);
- }
- if ((s= cmdline->param(0)->get_svalue()))
- {
- if (strstr(s, "t") == s)
- return(timer(cmdline, con));
- else
- con->printf("Unknow keyword of set command\n");
- }
- return(0);
-}