version 0.5.2
[fw/sdcc] / sim / ucsim / s51.src / sim51.cc
1 /*
2  * Simulator of microcontrollers (sim51.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 <stdio.h>
31 #include <stdlib.h>
32 #include <ctype.h>
33 #include <errno.h>
34 #include "i_string.h"
35
36 #include "globals.h"
37 #include "utils.h"
38 #include "cmdutil.h"
39
40 #include "sim51cl.h"
41 //#include "cmd51cl.h"
42 #include "uc51cl.h"
43 #include "uc52cl.h"
44 #include "uc51rcl.h"
45 #include "uc89c51rcl.h"
46 #include "uc251cl.h"
47 #include "uc390cl.h"
48 #include "glob.h"
49
50
51 cl_sim51::cl_sim51(class cl_app *the_app):
52   cl_sim(the_app)
53 {}
54
55
56 class cl_uc *
57 cl_sim51::mk_controller(void)
58 {
59   int i;
60   char *typ= NIL;
61   class cl_optref type_option(this);
62
63   type_option.init();
64   type_option.use("cpu_type");
65   i= 0;
66   if ((typ= type_option.get_value(typ)) == NIL)
67     typ= "C51";
68   while ((cpus_51[i].type_str != NULL) &&
69          (strcmp(typ, cpus_51[i].type_str) != 0))
70     i++;
71   if (cpus_51[i].type_str == NULL)
72     {
73       fprintf(stderr, "Unknown processor type. "
74               "Use -H option to see known types.\n");
75       return(NULL);
76     }
77   switch (cpus_51[i].type)
78     {
79     case CPU_51: case CPU_31:
80       return(new cl_51core(cpus_51[i].type, cpus_51[i].technology, this));
81     case CPU_52: case CPU_32:
82       return(new cl_uc52(cpus_51[i].type, cpus_51[i].technology, this));
83     case CPU_51R:
84       return(new cl_uc51r(cpus_51[i].type, cpus_51[i].technology, this));
85     case CPU_89C51R:
86       return(new cl_uc89c51r(cpus_51[i].type, cpus_51[i].technology, this));
87     case CPU_251:
88       return(new cl_uc251(cpus_51[i].type, cpus_51[i].technology, this));
89     case CPU_DS390: case CPU_DS390F:
90       return(new cl_uc390(cpus_51[i].type, cpus_51[i].technology, this));
91     }
92   return(NULL);
93 }
94
95
96 /* End of s51.src/sim51.cc */