34c995859f85ac6ae2966aa9a3d7cb65d479361f
[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
32 // sim
33 #include "simcl.h"
34 #include "optioncl.h"
35
36 // local
37 #include "cmdsetcl.h"
38 #include "getcl.h"
39 #include "cmdutil.h"
40
41
42 /*
43  * Command: get sfr
44  *----------------------------------------------------------------------------
45  */
46
47 int
48 cl_get_sfr_cmd::do_work(class cl_sim *sim,
49                         class cl_cmdline *cmdline, class cl_console *con)
50 {
51   class cl_mem *mem= sim->uc->mem(MEM_SFR);
52   class cl_cmd_arg *parm;
53   int i;
54
55   if (!mem)
56     {
57       con->printf("Error: No SFR\n");
58       return(DD_FALSE);
59     }
60   for (i= 0, parm= cmdline->param(i);
61        parm;
62        i++, parm= cmdline->param(i))
63     {
64       if (!parm->as_address())
65         con->printf("Warning: Invalid address %s\n",
66                     (char*)cmdline->tokens->at(i+1));
67       else
68         mem->dump(parm->value.address, parm->value.address, 1, con);
69     }
70
71   return(DD_FALSE);;
72 }
73
74
75 /*
76  * Command: get option
77  *----------------------------------------------------------------------------
78  */
79
80 int
81 cl_get_option_cmd::do_work(class cl_sim *sim,
82                            class cl_cmdline *cmdline, class cl_console *con)
83 {
84   class cl_cmd_arg *parm= cmdline->param(0);
85   char *s= 0;
86
87   if (!parm)
88     ;
89   else if (cmdline->syntax_match(sim, STRING)) {
90     s= parm->value.string.string;
91   }
92   else
93     con->printf("%s\n", short_help?short_help:"Error: wrong syntax\n");
94
95   int i;
96   for (i= 0; i < sim->uc->options->count; i++)
97     {
98       class cl_option *o= (class cl_option *)(sim->uc->options->at(i));
99       if (!s ||
100           !strcmp(s, o->id))
101         {
102           con->printf("%s ", o->id);
103           o->print(con);
104           con->printf(" %s\n", o->help);
105         }
106     }
107   
108   return(DD_FALSE);;
109 }
110
111
112 /* End of cmd.src/get.cc */