Mercurial > hg-old > index.cgi
comparison src/main.c @ 19:925105ccf22f
small reworking of command arguments
author | lost |
---|---|
date | Fri, 02 Jan 2009 00:41:58 +0000 |
parents | 05d4115b4860 |
children | 39d750ee8d34 |
comparison
equal
deleted
inserted
replaced
18:218aabbc3b1a | 19:925105ccf22f |
---|---|
80 break; | 80 break; |
81 | 81 |
82 case 0x100: | 82 case 0x100: |
83 // proprietary object format | 83 // proprietary object format |
84 as -> outformat = OUTPUT_OBJ; | 84 as -> outformat = OUTPUT_OBJ; |
85 | 85 break; |
86 | |
87 case 'f': | |
88 // output format | |
89 if (!strcasecmp(arg, "decb")) | |
90 as -> outformat = OUTPUT_DECB; | |
91 else if (!strcasecmp(arg, "raw")) | |
92 as -> outformat = OUTPUT_RAW; | |
93 else if (!strcasecmp(arg, "obj")) | |
94 as -> outformat = OUTPUT_OBJ; | |
95 else | |
96 { | |
97 fprintf(stderr, "Invalid output format: %s\n", arg); | |
98 exit(1); | |
99 } | |
100 break; | |
86 case ARGP_KEY_END: | 101 case ARGP_KEY_END: |
87 // done; sanity check | 102 // done; sanity check |
88 if (!as -> outfile) | 103 if (!as -> outfile) |
89 as -> outfile = "a.out"; | 104 as -> outfile = "a.out"; |
90 break; | 105 break; |
106 { | 121 { |
107 { "output", 'o', "FILE", 0, | 122 { "output", 'o', "FILE", 0, |
108 "Output to FILE"}, | 123 "Output to FILE"}, |
109 { "debug", 'd', 0, 0, | 124 { "debug", 'd', 0, 0, |
110 "Set debug mode"}, | 125 "Set debug mode"}, |
126 { "format", 'f', "TYPE", 0, | |
127 "Select output format: decb, raw, obj"}, | |
111 { "list", 'l', "FILE", OPTION_ARG_OPTIONAL, | 128 { "list", 'l', "FILE", OPTION_ARG_OPTIONAL, |
112 "Generate list [to FILE]"}, | 129 "Generate list [to FILE]"}, |
113 { "decb", 'b', 0, 0, | 130 { "decb", 'b', 0, 0, |
114 "Generate DECB .bin format output"}, | 131 "Generate DECB .bin format output, equivalent of --format=decb"}, |
115 { "raw", 'r', 0, 0, | 132 { "raw", 'r', 0, 0, |
116 "Generate raw binary format output"}, | 133 "Generate raw binary format output, equivalent of --format=raw"}, |
117 { "rawrel", 0, 0, 0, | |
118 "Generate raw binary respecing ORG statements as offsets from the start of the file"}, | |
119 { "obj", 0, 0, 0, | 134 { "obj", 0, 0, 0, |
120 "Generate proprietary object file format for later linking" }, | 135 "Generate proprietary object file format for later linking, equivalent of --format=obj" }, |
121 { 0 } | 136 { 0 } |
122 }; | 137 }; |
123 | 138 |
124 static struct argp argp = | 139 static struct argp argp = |
125 { | 140 { |
138 | 153 |
139 argp_parse(&argp, argc, argv, 0, 0, &asmstate); | 154 argp_parse(&argp, argc, argv, 0, 0, &asmstate); |
140 if (!asmstate.listfile) | 155 if (!asmstate.listfile) |
141 asmstate.listfile = "-"; | 156 asmstate.listfile = "-"; |
142 | 157 |
158 if (!asmstate.infile) | |
159 { | |
160 fprintf(stderr, "No input files specified.\n"); | |
161 exit(1); | |
162 } | |
163 | |
143 /* pass 1 - collect the symbols and assign addresses where possible */ | 164 /* pass 1 - collect the symbols and assign addresses where possible */ |
144 /* pass 1 also resolves included files, etc. */ | 165 /* pass 1 also resolves included files, etc. */ |
145 /* that means files are read exactly once unless included multiple times */ | 166 /* that means files are read exactly once unless included multiple times */ |
146 lwasm_pass1(&asmstate); | 167 lwasm_pass1(&asmstate); |
147 | 168 |