Mercurial > hg-old > index.cgi
comparison lwasm/pass1.c @ 337:04c80c51b16a
Checkpoint development
author | lost |
---|---|
date | Fri, 12 Mar 2010 06:01:38 +0000 |
parents | 67224d8d1024 |
children | 1a6fc6ebb31c |
comparison
equal
deleted
inserted
replaced
336:401587ab6a09 | 337:04c80c51b16a |
---|---|
26 #include <lw_alloc.h> | 26 #include <lw_alloc.h> |
27 | 27 |
28 #include "lwasm.h" | 28 #include "lwasm.h" |
29 #include "input.h" | 29 #include "input.h" |
30 | 30 |
31 /* | |
32 pass 1: parse the lines | |
33 */ | |
31 void do_pass1(asmstate_t *as) | 34 void do_pass1(asmstate_t *as) |
32 { | 35 { |
33 char *line; | 36 char *line; |
34 | 37 line_t *cl; |
38 | |
35 for (;;) | 39 for (;;) |
36 { | 40 { |
37 line = input_readline(as); | 41 line = input_readline(as); |
38 if (!line) | 42 if (!line) |
39 break; | 43 break; |
40 printf("%s\n", line); | 44 printf("%s\n", line); |
45 | |
46 cl = lw_alloc(sizeof(line_t)); | |
47 cl -> next = NULL; | |
48 cl -> prev = as -> line_tail; | |
49 cl -> len = -1; | |
50 cl -> insn = -1; | |
51 if (!as -> line_tail) | |
52 { | |
53 as -> line_head = cl; | |
54 cl -> addr = lw_expr_build(lw_expr_type_int, 0); | |
55 } | |
56 else | |
57 { | |
58 lw_expr_t te; | |
59 as -> line_tail -> next = cl; | |
60 te = lw_expr_build(lw_expr_type_special, lwasm_expr_linelen, cl -> prev); | |
61 cl -> addr = lw_expr_build(lw_expr_type_oper, lw_expr_oper_plus, cl -> prev -> addr, te); | |
62 lw_expr_destroy(te); | |
63 lw_expr_simplify(cl -> addr); | |
64 } | |
65 as -> line_tail = cl; | |
66 | |
67 lw_expr_print(cl -> addr); | |
68 printf("\n"); | |
69 // now parse the line | |
70 | |
41 lw_free(line); | 71 lw_free(line); |
42 } | 72 } |
43 } | 73 } |