Imported Upstream version 2.9.0
[debian/cc1111] / sim / ucsim / cmd.src / get.cc
1 /*
2  * Simulator of microcontrollers (cmd.src/get.cc)
3  *
4  * Copyright (C) 1999,99 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 #include "ddconfig.h"
29
30 #include <ctype.h>
31 #include "i_string.h"
32
33 // prj
34 #include "utils.h"
35
36 // sim
37 #include "simcl.h"
38 #include "optioncl.h"
39
40 // local
41 #include "cmdsetcl.h"
42 #include "getcl.h"
43 #include "cmdutil.h"
44
45
46 /*
47  * Command: get sfr
48  *----------------------------------------------------------------------------
49  */
50
51 //int
52 //cl_get_sfr_cmd::do_work(class cl_sim *sim,
53 //                      class cl_cmdline *cmdline, class cl_console_base *con)
54 COMMAND_DO_WORK_UC(cl_get_sfr_cmd)
55 {
56   class cl_address_space *mem= uc->address_space(MEM_SFR_ID);
57   class cl_cmd_arg *parm;
58   int i;
59
60   if (!mem)
61     {
62       con->dd_printf("Error: No SFR\n");
63       return(DD_FALSE);
64     }
65   for (i= 0, parm= cmdline->param(i);
66        parm;
67        i++, parm= cmdline->param(i))
68     {
69       if (!parm->as_address(uc) ||
70           !mem->valid_address(parm->value.address))
71         con->dd_printf("Warning: Invalid address %s\n",
72                        (char*)cmdline->tokens->at(i+1));
73       else
74         mem->dump(parm->value.address, parm->value.address, 1, con);
75     }
76
77   return(DD_FALSE);;
78 }
79
80
81 /*
82  * Command: get option
83  *----------------------------------------------------------------------------
84  */
85
86 //int
87 //cl_get_option_cmd::do_work(class cl_sim *sim,
88 //                         class cl_cmdline *cmdline, class cl_console_base *con)
89 COMMAND_DO_WORK_APP(cl_get_option_cmd)
90 {
91   class cl_cmd_arg *parm= cmdline->param(0);
92   char *s= 0;
93
94   if (!parm)
95     ;
96   else if (cmdline->syntax_match(0/*app->get_uc()*/, STRING)) {
97     s= parm->value.string.string;
98   }
99   else
100     con->dd_printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
101
102   int i;
103   for (i= 0; i < app->options->count; i++)
104     {
105       class cl_option *o= (class cl_option *)(/*uc*/app->options->at(i));
106       if ((!s ||
107            !strcmp(s, o->get_name())))
108         {
109           if (!o->hidden)
110             {
111               con->dd_printf("%2d. %s(by %s): ", i, object_name(o),
112                              object_name(o->get_creator()));
113               o->print(con);
114               con->dd_printf(" - %s\n", o->help);
115             }
116           else
117             {
118               /*
119               con->dd_printf("%2d. %s(by %s) is hidden!\n", i, object_name(o),
120                            object_name(o->get_creator()));
121               */
122             }
123         }
124     }
125
126   return(DD_FALSE);;
127 }
128
129
130 /* End of cmd.src/get.cc */