Mercurial > hg-old > index.cgi
comparison src/parse.c @ 57:035b95a3690f
Added conditional assembly and macros
author | lost |
---|---|
date | Mon, 05 Jan 2009 00:01:21 +0000 |
parents | b9856da2674a |
children | d85ba47b1e8f |
comparison
equal
deleted
inserted
replaced
56:55260a178667 | 57:035b95a3690f |
---|---|
41 | 41 |
42 p = l -> text; | 42 p = l -> text; |
43 | 43 |
44 if (!*p) | 44 if (!*p) |
45 { | 45 { |
46 as -> context += 1; | 46 if (as -> inmacro == 0) |
47 as -> context = lwasm_next_context(as); | |
47 return 0; | 48 return 0; |
48 } | 49 } |
49 | 50 |
50 // for output generation later but only on pass 1 | 51 // for output generation later but only on pass 1 |
51 if (as -> passnum == 1) | 52 if (as -> passnum == 1) |
79 { | 80 { |
80 while (*p && isspace(*p)) | 81 while (*p && isspace(*p)) |
81 p++; | 82 p++; |
82 if (!*p) | 83 if (!*p) |
83 { | 84 { |
84 as -> context += 1; | 85 if (as -> inmacro == 0) |
86 as -> context = lwasm_next_context(as); | |
85 return 0; | 87 return 0; |
86 } | 88 } |
87 } | 89 } |
88 | 90 |
89 // skip white space | 91 // skip white space |
110 | 112 |
111 // skip intervening whitespace if present | 113 // skip intervening whitespace if present |
112 while (*p2 && isspace(*p2)) | 114 while (*p2 && isspace(*p2)) |
113 p2++; | 115 p2++; |
114 | 116 |
115 // check for macro (pass 1) | |
116 | |
117 // look up instruction in insn table | 117 // look up instruction in insn table |
118 for (opnum = 0; instab[opnum].opcode; opnum++) | 118 for (opnum = 0; instab[opnum].opcode; opnum++) |
119 { | 119 { |
120 if (!strcasecmp(instab[opnum].opcode, opc)) | 120 if (!strcasecmp(instab[opnum].opcode, opc)) |
121 break; | 121 break; |
122 } | 122 } |
123 | 123 |
124 if (!(instab[opnum].opcode) || !(instab[opnum].fn)) | 124 if (as -> inmacro && instab[opnum].endm == 0) |
125 { | |
126 add_macro_line(as, l -> text); | |
127 } | |
128 | |
129 if (as -> inmacro == 0 && as -> skipcond == 0) | |
130 { | |
131 if (expand_macro(as, l, &p2, opc) == 0) | |
132 goto done_line; | |
133 } | |
134 | |
135 if (!(instab[opnum].opcode) || !(instab[opnum].fn) && !(as -> skipcond || as -> inmacro)) | |
125 { | 136 { |
126 // invalid operation code, throw error | 137 // invalid operation code, throw error |
127 register_error(as, l, 1, "Invalid operation code '%s'", opc); | 138 register_error(as, l, 1, "Invalid operation code '%s'", opc); |
128 if (sym) | 139 if (sym) |
129 lwasm_free(l -> sym); | 140 lwasm_free(l -> sym); |
130 lwasm_free(opc); | 141 lwasm_free(opc); |
131 return -1; | 142 return -1; |
132 } | 143 } |
133 | 144 |
134 // dispatch handler | 145 // dispatch handler if we're not ignoring items |
135 (instab[opnum].fn)(as, l, &p2, opnum); | 146 if (as -> skipcond == 0 && as -> inmacro == 0 && !(instab[opnum].iscond)) |
136 | 147 (instab[opnum].fn)(as, l, &p2, opnum); |
148 | |
149 done_line: | |
137 lwasm_free(opc); | 150 lwasm_free(opc); |
138 if (sym) | 151 if (sym) |
139 lwasm_free(sym); | 152 lwasm_free(sym); |
140 } | 153 } |