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