version 0.2.39: fix of arith insts and start of re-structure
[fw/sdcc] / sim / ucsim / sim.src / argcl.h
1 /*
2  * Simulator of microcontrollers (sim.src/argcl.h)
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 #ifndef SIM_ARGCL_HEADER
29 #define SIM_ARGCL_HEADER
30
31 #include "pobjcl.h"
32
33
34 /*
35  * Base type of arguments/parameters
36  */
37
38 class cl_arg: public cl_base
39 {
40 public:
41   union {
42     long i_value;
43     double f_value;
44     void *p_value;
45   };
46   char *s_value;
47
48 public:  
49   cl_arg(long lv);
50   cl_arg(char *lv);
51   cl_arg(double fv);
52   cl_arg(void *pv);
53   ~cl_arg(void);
54
55   virtual bool get_ivalue(long *value);
56   virtual char *get_svalue(void);
57   virtual double get_fvalue(void);
58   virtual void *get_pvalue(void);
59   virtual bool get_bit_address(class cl_uc *uc, // input
60                                class cl_mem **mem, // outputs
61                                t_addr *mem_addr,
62                                t_mem *bit_mask) { return(DD_FALSE); }
63 };
64
65
66 /*
67  * Command parameters
68  */
69
70 class cl_cmd_arg: public cl_arg
71 {
72 public:
73   class cl_uc *uc;
74
75   bool interpreted_as_string;
76   union {
77     long number;
78     t_addr address;
79     t_mem data;
80     class cl_mem *memory;
81     class cl_hw *hw;
82     struct {
83       int len;
84       char *string;
85     } string;
86     struct {
87       t_mem *array;
88       int len;
89     } data_list;
90     struct {
91       class cl_mem *mem;
92       t_addr mem_address;
93       t_mem mask;
94     } bit;
95   } value;
96
97 public:
98   cl_cmd_arg(class cl_uc *iuc, long i): cl_arg(i)
99   { uc= iuc; interpreted_as_string= DD_FALSE; }
100   cl_cmd_arg(class cl_uc *iuc, char *s): cl_arg(s)
101   { uc= iuc; interpreted_as_string= DD_FALSE; }
102   ~cl_cmd_arg(void);
103
104   virtual int is_string(void) { return(DD_FALSE); }
105   virtual bool get_address(t_addr *addr) { return(DD_FALSE); }
106   virtual bool as_address(void);
107   virtual bool as_number(void);
108   virtual bool as_data(void);
109   virtual bool as_string(void);
110   virtual bool as_memory(void);
111   virtual bool as_hw(class cl_uc *uc);
112   virtual bool as_bit(class cl_uc *uc);
113 };
114
115 class cl_cmd_int_arg: public cl_cmd_arg
116 {
117 public:
118   cl_cmd_int_arg(class cl_uc *iuc, long addr);
119
120   virtual bool get_address(t_addr *addr);
121   virtual bool get_bit_address(class cl_uc *uc, // input
122                                class cl_mem **mem, // outputs
123                                t_addr *mem_addr,
124                                t_mem *bit_mask);
125   virtual bool as_string(void);
126 };
127
128 class cl_cmd_sym_arg: public cl_cmd_arg
129 {
130 public:
131   cl_cmd_sym_arg(class cl_uc *iuc, char *sym);
132
133   virtual bool get_address(t_addr *addr);
134   virtual bool get_bit_address(class cl_uc *uc, // input
135                                class cl_mem **mem, // outputs
136                                t_addr *mem_addr,
137                                t_mem *bit_mask);
138   virtual bool as_address(void);
139   virtual bool as_string(void);
140   virtual bool as_hw(class cl_uc *uc);
141 };
142
143 class cl_cmd_str_arg: public cl_cmd_arg
144 {
145 public:
146   cl_cmd_str_arg(class cl_uc *iuc, char *str);
147
148   virtual int is_string(void) { return(1); }
149 };
150
151 class cl_cmd_bit_arg: public cl_cmd_arg
152 {
153 public:
154   class cl_cmd_arg *sfr, *bit;
155
156 public:
157   cl_cmd_bit_arg(class cl_uc *iuc,
158                  class cl_cmd_arg *asfr, class cl_cmd_arg *abit);
159   ~cl_cmd_bit_arg(void);
160
161   virtual bool get_address(t_addr *addr);
162   virtual bool get_bit_address(class cl_uc *uc, // input
163                                class cl_mem **mem, // outputs
164                                t_addr *mem_addr,
165                                t_mem *bit_mask);
166 };
167
168 class cl_cmd_array_arg: public cl_cmd_arg
169 {
170 public:
171   class cl_cmd_arg *name, *index;
172
173 public:
174   cl_cmd_array_arg(class cl_uc *iuc,
175                    class cl_cmd_arg *aname, class cl_cmd_arg *aindex);
176   ~cl_cmd_array_arg(void);
177   virtual bool as_hw(class cl_uc *uc);
178 };
179
180
181 /*
182  * Program arguments
183  */
184
185 class cl_prg_arg: public cl_arg
186 {
187 public:
188   char short_name;
189   char *long_name;
190
191 public:
192   cl_prg_arg(char sn, char *ln, long lv);
193   cl_prg_arg(char sn, char *ln, char *lv);
194   cl_prg_arg(char sn, char *ln, double fv);
195   cl_prg_arg(char sn, char *ln, void *pv);
196   ~cl_prg_arg(void);
197 };
198
199
200 #endif
201
202 /* End of argcl.h */