cfb91214598f38e50ec6c62e74ca439d10840959
[fw/sdcc] / sim / ucsim / xa.src / inst.cc
1 /*
2  * Simulator of microcontrollers (inst.cc)
3  *
4  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
5  *
6  * Written by Karl Bongers karl@turbobit.com
7  * 
8  * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
9  *
10  */
11
12 /* This file is part of microcontroller simulator: ucsim.
13
14 UCSIM is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
18
19 UCSIM is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 GNU General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with UCSIM; see the file COPYING.  If not, write to the Free
26 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
27 02111-1307, USA. */
28 /*@1@*/
29
30 #include "ddconfig.h"
31
32 // local
33 #include "glob.h"
34 #include "xacl.h"
35 #include "regsxa.h"
36
37 int
38 cl_xa::get_reg(int word_flag, unsigned int index)
39 {
40   //if (index < 3) { /* banked */
41   //  if (word_flag)
42   //    return get_word_direct(0x400+index);
43   //  else
44   //    return mem_direct[0x400+index];
45   //} else { /* non-banked */
46     if (word_flag)
47       return get_word_direct(0x400+index);
48     else
49       return mem_direct[0x400+index];
50   //}
51 }
52
53 int
54 cl_xa::inst_NOP(uint code, int operands)
55 {
56   return(resGO);
57 }
58
59 #define RI_F0 ((code >> 4) & 0xf)
60 #define RI_70 ((code >> 4) & 0x7)
61 #define RI_0F (code & 0xf)
62 #define RI_07 (code & 0x7)
63
64 int
65 cl_xa::inst_ADD(uint code, int operands)
66 {
67 #undef FUNC1
68 #define FUNC1 add1
69 #undef FUNC2
70 #define FUNC2 add2
71 #include "inst_gen.cc"
72
73   return(resGO);
74 }
75
76 int
77 cl_xa::inst_ADDC(uint code, int operands)
78 {
79 #undef FUNC1
80 #define FUNC1 addc1
81 #undef FUNC2
82 #define FUNC2 addc2
83 #include "inst_gen.cc"
84
85   return(resGO);
86 }
87
88 int
89 cl_xa::inst_SUB(uint code, int operands)
90 {
91 #undef FUNC1
92 #define FUNC1 sub1
93 #undef FUNC2
94 #define FUNC2 sub2
95 #include "inst_gen.cc"
96   return(resGO);
97 }
98
99 int
100 cl_xa::inst_SUBB(uint code, int operands)
101 {
102 #undef FUNC1
103 #define FUNC1 subb1
104 #undef FUNC2
105 #define FUNC2 subb2
106 #include "inst_gen.cc"
107   return(resGO);
108 }
109
110 int
111 cl_xa::inst_CMP(uint code, int operands)
112 {
113 #undef FUNC1
114 #define FUNC1 cmp1
115 #undef FUNC2
116 #define FUNC2 cmp2
117 #include "inst_gen.cc"
118   return(resGO);
119 }
120 int
121 cl_xa::inst_AND(uint code, int operands)
122 {
123 #undef FUNC1
124 #define FUNC1 and1
125 #undef FUNC2
126 #define FUNC2 and2
127 #include "inst_gen.cc"
128   return(resGO);
129 }
130 int
131 cl_xa::inst_OR(uint code, int operands)
132 {
133 #undef FUNC1
134 #define FUNC1 or1
135 #undef FUNC2
136 #define FUNC2 or2
137 #include "inst_gen.cc"
138   return(resGO);
139 }
140 int
141 cl_xa::inst_XOR(uint code, int operands)
142 {
143 #undef FUNC1
144 #define FUNC1 xor1
145 #undef FUNC2
146 #define FUNC2 xor2
147 #include "inst_gen.cc"
148   return(resGO);
149 }
150 int
151 cl_xa::inst_ADDS(uint code, int operands)
152 {
153   return(resGO);
154 }
155 int
156 cl_xa::inst_NEG(uint code, int operands)
157 {
158   return(resGO);
159 }
160 int
161 cl_xa::inst_SEXT(uint code, int operands)
162 {
163   return(resGO);
164 }
165 int
166 cl_xa::inst_MUL(uint code, int operands)
167 {
168   return(resGO);
169 }
170 int
171 cl_xa::inst_DIV(uint code, int operands)
172 {
173   return(resGO);
174 }
175 int
176 cl_xa::inst_DA(uint code, int operands)
177 {
178   return(resGO);
179 }
180 int
181 cl_xa::inst_ASL(uint code, int operands)
182 {
183   return(resGO);
184 }
185 int
186 cl_xa::inst_ASR(uint code, int operands)
187 {
188   return(resGO);
189 }
190 int
191 cl_xa::inst_LEA(uint code, int operands)
192 {
193   return(resGO);
194 }
195 int
196 cl_xa::inst_CPL(uint code, int operands)
197 {
198   return(resGO);
199 }
200 int
201 cl_xa::inst_LSR(uint code, int operands)
202 {
203   return(resGO);
204 }
205 int
206 cl_xa::inst_NORM(uint code, int operands)
207 {
208   return(resGO);
209 }
210 int
211 cl_xa::inst_RL(uint code, int operands)
212 {
213   return(resGO);
214 }
215 int
216 cl_xa::inst_RLC(uint code, int operands)
217 {
218   return(resGO);
219 }
220 int
221 cl_xa::inst_RR(uint code, int operands)
222 {
223   return(resGO);
224 }
225 int
226 cl_xa::inst_RRC(uint code, int operands)
227 {
228   return(resGO);
229 }
230 int
231 cl_xa::inst_MOVS(uint code, int operands)
232 {
233   return(resGO);
234 }
235 int
236 cl_xa::inst_MOVC(uint code, int operands)
237 {
238   return(resGO);
239 }
240 int
241 cl_xa::inst_MOVX(uint code, int operands)
242 {
243   return(resGO);
244 }
245 int
246 cl_xa::inst_PUSH(uint code, int operands)
247 {
248   return(resGO);
249 }
250 int
251 cl_xa::inst_POP(uint code, int operands)
252 {
253   return(resGO);
254 }
255 int
256 cl_xa::inst_XCH(uint code, int operands)
257 {
258   return(resGO);
259 }
260 int
261 cl_xa::inst_SETB(uint code, int operands)
262 {
263   return(resGO);
264 }
265 int
266 cl_xa::inst_CLR(uint code, int operands)
267 {
268   return(resGO);
269 }
270 int
271 cl_xa::inst_MOV(uint code, int operands)
272 {
273 #undef FUNC1
274 #define FUNC1 mov1
275 #undef FUNC2
276 #define FUNC2 mov2
277 #include "inst_gen.cc"
278   return(resGO);
279 }
280 int
281 cl_xa::inst_ANL(uint code, int operands)
282 {
283   return(resGO);
284 }
285 int
286 cl_xa::inst_ORL(uint code, int operands)
287 {
288   return(resGO);
289 }
290 int
291 cl_xa::inst_BR(uint code, int operands)
292 {
293   return(resGO);
294 }
295 int
296 cl_xa::inst_JMP(uint code, int operands)
297 {
298   unsigned int jmpaddr;
299   short saddr;
300
301   switch(operands) {
302     case REL16:
303     {
304       saddr = fetch2();
305       jmpaddr = saddr;
306       jmpaddr *= 2;
307       PC = (PC + 3) + jmpaddr;
308     }
309     break;
310     case IREG:
311       PC = reg2(RI_07) & 0xfffe;  /* word aligned */
312     break;
313     /* fixme 2 more... */
314   }
315   return(resGO);
316 }
317 int
318 cl_xa::inst_CALL(uint code, int operands)
319 {
320   return(resGO);
321 }
322 int
323 cl_xa::inst_RET(uint code, int operands)
324 {
325   return(resGO);
326 }
327 int
328 cl_xa::inst_Bcc(uint code, int operands)
329 {
330   return(resGO);
331 }
332 int
333 cl_xa::inst_JB(uint code, int operands)
334 {
335   return(resGO);
336 }
337 int
338 cl_xa::inst_JNB(uint code, int operands)
339 {
340   return(resGO);
341 }
342 int
343 cl_xa::inst_CJNE(uint code, int operands)
344 {
345   return(resGO);
346 }
347 int
348 cl_xa::inst_DJNZ(uint code, int operands)
349 {
350   return(resGO);
351 }
352 int
353 cl_xa::inst_JZ(uint code, int operands)
354 {
355   return(resGO);
356 }
357 int
358 cl_xa::inst_JNZ(uint code, int operands)
359 {
360   return(resGO);
361 }
362 int
363 cl_xa::inst_BKPT(uint code, int operands)
364 {
365   return(resGO);
366 }
367 int
368 cl_xa::inst_TRAP(uint code, int operands)
369 {
370   return(resGO);
371 }
372 int
373 cl_xa::inst_RESET(uint code, int operands)
374 {
375   return(resGO);
376 }
377
378
379 /* End of xa.src/inst.cc */