diff src/main.c @ 13:05d4115b4860

Started work on new expression evaluator system and major code re-work for next release
author lost
date Wed, 22 Oct 2008 04:51:16 +0000
parents 287a6905a63c
children 925105ccf22f
line wrap: on
line diff
--- a/src/main.c	Sat Oct 04 03:20:36 2008 +0000
+++ b/src/main.c	Wed Oct 22 04:51:16 2008 +0000
@@ -22,7 +22,9 @@
 
 */
 
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
 
 #include <argp.h>
 #include <errno.h>
@@ -32,10 +34,8 @@
 #include "lwasm.h"
 
 // external declarations
-extern void resolve_phasing(asmstate_t *as);
-extern void generate_code(asmstate_t *as);
-extern void list_code(asmstate_t *as);
-extern void write_code(asmstate_t *as);
+extern void lwasm_pass1(asmstate_t *as);
+extern void lwasm_pass2(asmstate_t *as);
 
 
 // command line option handling
@@ -78,7 +78,11 @@
 		// raw binary output
 		as -> outformat = OUTPUT_RAW;
 		break;
-		
+	
+	case 0x100:
+		// proprietary object format
+		as -> outformat = OUTPUT_OBJ;
+	
 	case ARGP_KEY_END:
 		// done; sanity check
 		if (!as -> outfile)
@@ -112,6 +116,8 @@
 				"Generate raw binary format output"},
 	{ "rawrel",		0,		0,		0,
 				"Generate raw binary respecing ORG statements as offsets from the start of the file"},
+	{ "obj",		0,		0,		0,
+				"Generate proprietary object file format for later linking" },
 	{ 0 }
 };
 
@@ -133,23 +139,21 @@
 	argp_parse(&argp, argc, argv, 0, 0, &asmstate);
 	if (!asmstate.listfile)
 		asmstate.listfile = "-";
-	
-//	printf("Assembling %s to %s; list to %s\n", asmstate.infile, asmstate.outfile, asmstate.listfile);
 
 	/* pass 1 - collect the symbols and assign addresses where possible */
 	/* pass 1 also resolves included files, etc. */
 	/* that means files are read exactly once unless included multiple times */
-	lwasm_read_file(&asmstate, (char *)(asmstate.infile));
+	lwasm_pass1(&asmstate);
 	
 	// pass 2: actually generate the code; if any phasing errors appear
 	// at this stage, we have a bug
-	generate_code(&asmstate);
+	lwasm_pass2(&asmstate);
 
 	// now make a pretty listing
-	list_code(&asmstate);
+//	lwasm_list(&asmstate);
 
 	// now write the code out to the output file
-	write_code(&asmstate);
+//	lwasm_output(&asmstate);
 
 	if (asmstate.errorcount > 0)
 		exit(1);