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