1 /* ----------------------------------------------------------------------
3 * PACKAGE: as31 - 8031/8051 Assembler.
6 * The file contains main(). It handles the arguments and makes
7 * sure that pass 1 is done before pass 2 etc...
10 * Jan. 19, 1990 - Created. (Ken Stauffer)
11 * March, 2001, Paul Stoffregen: see ChangeLog for details
12 * July, 2003, Bernd Porr: added ".inc" to include asm files.
13 * March, 23, 2004, Alexander 'E-Razor' Krause: see ChangeLog for details
14 * May, 6, 2004, Alexander 'E-Razor' Krause: see ChangeLog for details
15 * May, 18, 2004, Martin Langer: see ChangeLog for details
18 * All code in this file written by Ken Stauffer (University of Calgary).
19 * January, 1990. "Written by: Ken Stauffer"
30 int main(int argc, char **argv)
32 char *dashF=NULL, *dashA=NULL, *dashO=NULL;
33 int use_stdout=0, do_lst=0;
41 for (i=1; i<argc; i++ ) {
42 if( argv[i][0] != '-' ) break;
43 if( argv[i][1] == 'l' )
45 else if( argv[i][1] == 'h' ) {
49 else if( argv[i][1] == 's' )
51 else if( argv[i][1] == 'v' ) {
52 fprintf(stderr, "%s\n", VERSION);
55 else if( dashF == NULL && argv[i][1] == 'F' )
57 else if( dashA == NULL && argv[i][1] == 'A' )
59 else if( dashO == NULL && argv[i][1] == 'O' )
62 fprintf(stderr,"Duplicate or unknown flag.\n");
67 fprintf(stderr,"Missing input file.\n");
71 r = run_as31(argv[i], do_lst, use_stdout, dashF, dashA, dashO);
75 /* print list with command options */
77 void showhelp(const char *cmd)
79 fprintf(stderr, "AS31 %s\n", VERSION);
81 "Usage: %s [-h] [-l] [-s] [-v] [-Aarg] [-Ffmt] [-Ofile] file.asm\n\n",
83 fprintf(stderr, " -h shows this help\n");
84 fprintf(stderr, " -l create list file\n");
85 fprintf(stderr, " -s send output to stdout\n");
86 fprintf(stderr, " -v print version number\n");
87 fprintf(stderr, " -Aarg optional output format argument\n");
88 fprintf(stderr, " -Ffmt output format ");
90 fprintf(stderr, " (default=hex)\n");
91 fprintf(stderr, " -Ofile send output to file\n\n");
92 fprintf(stderr, "Look at the manpage for more details.\n");
95 /* the assembler calls here to display any messages */
97 void mesg(const char *str)
99 if (str == NULL) str = "(null)";
100 fprintf(stderr, "%s", str);