f070f02f07c78db1924822f28f7896af58cd7fb9
[fw/sdcc] / 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 *con)
54 COMMAND_DO_WORK_UC(cl_get_sfr_cmd)
55 {
56   class cl_mem *mem= uc->mem(MEM_SFR);
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         con->dd_printf("Warning: Invalid address %s\n",
71                        (char*)cmdline->tokens->at(i+1));
72       else
73         mem->dump(parm->value.address, parm->value.address, 1, con);
74     }
75
76   return(DD_FALSE);;
77 }
78
79
80 /*
81  * Command: get option
82  *----------------------------------------------------------------------------
83  */
84
85 //int
86 //cl_get_option_cmd::do_work(class cl_sim *sim,
87 //                         class cl_cmdline *cmdline, class cl_console *con)
88 COMMAND_DO_WORK_APP(cl_get_option_cmd)
89 {
90   class cl_cmd_arg *parm= cmdline->param(0);
91   char *s= 0;
92
93   if (!parm)
94     ;
95   else if (cmdline->syntax_match(0/*app->get_uc()*/, STRING)) {
96     s= parm->value.string.string;
97   }
98   else
99     con->dd_printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
100
101   int i;
102   for (i= 0; i < app->options->count; i++)
103     {
104       class cl_option *o= (class cl_option *)(/*uc*/app->options->at(i));
105       if ((!s ||
106            !strcmp(s, o->get_name())) &&
107           !o->hidden)
108         {
109           con->dd_printf("%2d. %s(by %s): ", i, object_name(o),
110                          object_name(o->get_creator()));
111           o->print(con);
112           con->dd_printf(" - %s\n", o->help);
113         }
114     }
115   
116   return(DD_FALSE);;
117 }
118
119
120 /* End of cmd.src/get.cc */