Version 0.3.0
[fw/sdcc] / sim / ucsim / avr.src / simavr.cc
1 /*
2  * Simulator of microcontrollers (simavr.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
29 #include <ctype.h>
30
31 // sim.src
32 #include "appcl.h"
33
34 // local
35 #include "simavrcl.h"
36 #include "avrcl.h"
37
38
39 cl_simavr::cl_simavr(class cl_app *the_app, int iargc, char *iargv[]):
40   cl_sim(the_app, "h", iargc, iargv)
41 {}
42
43
44 static void
45 print_help(char *name)
46 {
47   printf("%s: %s\n", name, VERSIONSTR);
48   printf("Usage: %s [-hHVvP] [-p prompt] [-t CPU] [-X freq[k|M]]\n"
49          "       [-c file] [-s file] [-S optionlist]"
50 #ifdef SOCKET_AVAIL
51          " [-Z portnum]"
52 #endif
53          "\n"
54          "       [files...]\n", name);
55   printf
56     (
57      "Options:\n"
58      "  -t CPU       Type of CPU: etc.\n"
59      "  -X freq[k|M] XTAL frequency\n"
60      "  -c file      Open command console on `file'\n"
61 #ifdef SOCKET_AVAIL
62      "  -Z portnum   Use localhost:portnumber for command console\n"
63 #endif
64      "  -s file      Connect serial interface to `file'\n"
65      "  -S options   `options' is a comma separated list of options\n"
66      "               according to serial interface. Know options are:\n"
67      "                  in=file   serial input will be read from file named `file'\n"
68      "                  out=file  serial output will be written to `file'\n"
69      "  -p prompt    Specify string for prompt\n"
70      "  -P           Prompt is a null ('\\0') character\n"
71      "  -V           Verbose mode\n"
72      "  -v           Print out version number\n"
73      "  -H           Print out types of known CPUs\n"
74      "  -h           Print out this help\n"
75      );
76 }
77
78
79 int
80 cl_simavr::proc_arg(char optopt, char *optarg)
81 {
82   switch (optopt)
83     {
84     
85     case 'h':
86       
87       print_help("savr");
88       exit(0);
89       break;
90     
91     case '?':
92
93       if (isprint(optopt))
94         fprintf(stderr, "Unknown option `-%c'.\n", optopt);
95       else
96         fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
97       return(1);
98       break;
99       
100     default:
101       // should never happen...
102       abort();
103     }
104 }
105
106
107 class cl_uc *
108 cl_simavr::mk_controller(void)
109 {
110   return(new cl_avr(this));
111 }
112
113
114 /* End of avr.src/simavr.cc */