fix printf is a macro in gcc 3
[fw/sdcc] / sim / ucsim / cmd.src / cmdconf.cc
1 /*
2  * Simulator of microcontrollers (cmd.src/cmdconf.cc)
3  *
4  * Copyright (C) 2001,01 Drotos Daniel, Talker Bt.
5  * 
6  * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
7  *
8  */
9
10 /* This file is part of microcontroller simulator: ucsim.
11
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.
16
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.
21
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
25 02111-1307, USA. */
26 /*@1@*/
27
28 // prj
29 #include "globals.h"
30 #include "utils.h"
31
32 // sim
33 #include "simcl.h"
34
35 // local
36 #include "cmdconfcl.h"
37
38
39 /*
40  * Command: conf
41  *----------------------------------------------------------------------------
42  */
43
44 //int
45 //cl_conf_cmd::do_work(class cl_sim *sim,
46 //                   class cl_cmdline *cmdline, class cl_console *con)
47 COMMAND_DO_WORK_UC(cl_conf_cmd)
48 {
49   int i;
50
51   con->dd_printf("ucsim version %s\n", VERSIONSTR);
52   con->dd_printf("Type of microcontroller: %s\n", uc->id_string());
53   con->dd_printf("Controller has %d hardware element(s).\n", uc->hws->count);
54   for (i= 0; i < uc->hws->count; i++)
55     {
56       class cl_hw *hw= (class cl_hw *)(uc->hws->at(i));
57       con->dd_printf("  %s[%d]\n", hw->id_string, hw->id);
58     }
59   con->dd_printf("Memories:\n");
60   for (i= MEM_ROM; i < MEM_TYPES; i++)
61     {
62       class cl_mem *mem= (class cl_mem *)(uc->mems->at(i));
63       if (mem)
64         con->dd_printf("  %s size= 0x%06x %6d width= %2d class= \"%s\"\n",
65                        mem->id_string(), mem->size, mem->size, mem->width,
66                        (mem->class_name)?(mem->class_name):"unknown");
67     }
68   return(0);
69 }
70
71 /*
72  * Command: conf addmem
73  *----------------------------------------------------------------------------
74  */
75
76 //int
77 //cl_conf_addmem_cmd::do_work(class cl_sim *sim,
78 //                          class cl_cmdline *cmdline, class cl_console *con)
79 COMMAND_DO_WORK_UC(cl_conf_addmem_cmd)
80 {
81   class cl_mem *mem= 0;
82   class cl_cmd_arg *params[4]= { cmdline->param(0),
83                                  cmdline->param(1),
84                                  cmdline->param(2),
85                                  cmdline->param(3) };
86   char *mem_class;
87
88   if (cmdline->syntax_match(uc, STRING)) {
89     mem_class= params[0]->value.string.string;
90     enum mem_class type;
91     type= (enum mem_class)get_string_id(mem_classes, mem_class, -1);
92     mem= uc->mk_mem(type, mem_class);
93     if (mem)
94       {
95         class cl_mem *m= uc->mem(type);
96         if (m)
97           delete m;
98         uc->mems->put_at(type, mem);
99       }
100     else
101       con->dd_printf("Can not make memory \"%s\"\n", mem_class);
102   }
103   return(DD_FALSE);
104 }
105
106
107 /* End of cmd.src/cmdconf.cc */