diff lwasm/pass1.c @ 337:04c80c51b16a

Checkpoint development
author lost
date Fri, 12 Mar 2010 06:01:38 +0000
parents 67224d8d1024
children 1a6fc6ebb31c
line wrap: on
line diff
--- a/lwasm/pass1.c	Fri Mar 05 02:34:16 2010 +0000
+++ b/lwasm/pass1.c	Fri Mar 12 06:01:38 2010 +0000
@@ -28,16 +28,46 @@
 #include "lwasm.h"
 #include "input.h"
 
+/*
+pass 1: parse the lines
+*/
 void do_pass1(asmstate_t *as)
 {
 	char *line;
-	
+	line_t *cl;
+
 	for (;;)
 	{
 		line = input_readline(as);
 		if (!line)
 			break;
 		printf("%s\n", line);
+		
+		cl = lw_alloc(sizeof(line_t));
+		cl -> next = NULL;
+		cl -> prev = as -> line_tail;
+		cl -> len = -1;
+		cl -> insn = -1;
+		if (!as -> line_tail)
+		{
+			as -> line_head = cl;
+			cl -> addr = lw_expr_build(lw_expr_type_int, 0);
+		}
+		else
+		{
+			lw_expr_t te;
+			as -> line_tail -> next = cl;
+			te = lw_expr_build(lw_expr_type_special, lwasm_expr_linelen, cl -> prev);
+			cl -> addr = lw_expr_build(lw_expr_type_oper, lw_expr_oper_plus, cl -> prev -> addr, te);
+			lw_expr_destroy(te);
+			lw_expr_simplify(cl -> addr);
+		}
+		as -> line_tail = cl;
+
+		lw_expr_print(cl -> addr);
+		printf("\n");
+		// now parse the line
+		
 		lw_free(line);
 	}
 }