comparison lwasm/pseudo.c @ 229:59a138df0401

Fixed additional parsing problems with pseudo ops
author lost
date Fri, 12 Jun 2009 01:31:18 +0000
parents 058f18119025
children aa0056ca7319
comparison
equal deleted inserted replaced
228:560843a951f7 229:59a138df0401
32 32
33 extern int lwasm_read_file(asmstate_t *as, const char *filename); 33 extern int lwasm_read_file(asmstate_t *as, const char *filename);
34 34
35 OPFUNC(pseudo_noop) 35 OPFUNC(pseudo_noop)
36 { 36 {
37 37 skip_operand(p);
38 } 38 }
39 39
40 OPFUNC(pseudo_org) 40 OPFUNC(pseudo_org)
41 { 41 {
42 int v, r; 42 int v, r;
52 // org is not needed to be processed on pass 2 52 // org is not needed to be processed on pass 2
53 // this will prevent phasing errors for forward references that 53 // this will prevent phasing errors for forward references that
54 // resolve on the second pass 54 // resolve on the second pass
55 // we saved the org address in l -> codeaddr on pass 1 55 // we saved the org address in l -> codeaddr on pass 1
56 as -> addr = l -> codeaddr; 56 as -> addr = l -> codeaddr;
57 skip_operand(p);
57 return; 58 return;
58 } 59 }
59 60
60 if (l -> sym) 61 if (l -> sym)
61 { 62 {
82 // but make sure local include context is right 83 // but make sure local include context is right
83 // for the next line... 84 // for the next line...
84 if (as -> passnum != 1) 85 if (as -> passnum != 1)
85 { 86 {
86 as -> context = lwasm_next_context(as); 87 as -> context = lwasm_next_context(as);
88 skip_operand(p);
87 return; 89 return;
88 } 90 }
89 91
90 while (**p && isspace(**p)) 92 while (**p && isspace(**p))
91 (*p)++; 93 (*p)++;
206 int r, v; 208 int r, v;
207 209
208 if (as -> passnum == 2) 210 if (as -> passnum == 2)
209 { 211 {
210 as -> addr += l -> nocodelen; 212 as -> addr += l -> nocodelen;
213 skip_operand(p);
211 return; 214 return;
212 } 215 }
213 r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, -1); 216 r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, -1);
214 if (r != 0) 217 if (r != 0)
215 return; 218 return;
222 int r, v; 225 int r, v;
223 226
224 if (as -> passnum == 2) 227 if (as -> passnum == 2)
225 { 228 {
226 as -> addr += l -> nocodelen; 229 as -> addr += l -> nocodelen;
230 skip_operand(p);
227 return; 231 return;
228 } 232 }
229 r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, 0); 233 r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, 0);
230 if (r != 0) 234 if (r != 0)
231 return; 235 return;
239 int r, v; 243 int r, v;
240 244
241 if (as -> passnum == 2) 245 if (as -> passnum == 2)
242 { 246 {
243 as -> addr += l -> nocodelen; 247 as -> addr += l -> nocodelen;
248 skip_operand(p);
244 return; 249 return;
245 } 250 }
246 r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, 0); 251 r = lwasm_expr_result2(as, l, p, EXPR_SECTCONST | EXPR_PASS1CONST, &v, 0);
247 if (r != 0) 252 if (r != 0)
248 return; 253 return;
294 299
295 as -> endseen = 1; 300 as -> endseen = 1;
296 301
297 // address only matters for DECB output 302 // address only matters for DECB output
298 if (as -> outformat != OUTPUT_DECB) 303 if (as -> outformat != OUTPUT_DECB)
299 return; 304 {
305 skip_operand(p);
306 return;
307 }
300 308
301 r = lwasm_expr_result2(as, l, p, 0, &v, 0); 309 r = lwasm_expr_result2(as, l, p, 0, &v, 0);
302 if (r != 0) 310 if (r != 0)
303 { 311 {
304 register_error(as, l, 2, "Bad operand"); 312 register_error(as, l, 2, "Bad operand");
319 int cn; 327 int cn;
320 int r, v; 328 int r, v;
321 329
322 if (as -> passnum == 2) 330 if (as -> passnum == 2)
323 { 331 {
332 skip_operand(p);
324 while (as -> addr < l -> symaddr) 333 while (as -> addr < l -> symaddr)
325 lwasm_emit(as, l, 0); 334 lwasm_emit(as, l, 0);
326 return; 335 return;
327 } 336 }
328 337
760 return; 769 return;
761 } 770 }
762 771
763 if (as -> passnum != 1) 772 if (as -> passnum != 1)
764 { 773 {
774 skip_operand(p);
765 if (!(l -> fsize)) 775 if (!(l -> fsize))
766 { 776 {
767 as -> skipcond = 1; 777 as -> skipcond = 1;
768 as -> skipcount = 1; 778 as -> skipcount = 1;
769 } 779 }
815 return; 825 return;
816 } 826 }
817 827
818 if (as -> passnum != 1) 828 if (as -> passnum != 1)
819 { 829 {
830 skip_operand(p);
820 if (l -> fsize) 831 if (l -> fsize)
821 { 832 {
822 as -> skipcond = 1; 833 as -> skipcond = 1;
823 as -> skipcount = 1; 834 as -> skipcount = 1;
824 } 835 }
1085 1096
1086 as -> csect -> offset = as -> addr; 1097 as -> csect -> offset = as -> addr;
1087 as -> addr = 0; 1098 as -> addr = 0;
1088 as -> csect = 0; 1099 as -> csect = 0;
1089 as -> context = lwasm_next_context(as); 1100 as -> context = lwasm_next_context(as);
1101 skip_operand(p);
1090 } 1102 }
1091 1103
1092 OPFUNC(pseudo_extern) 1104 OPFUNC(pseudo_extern)
1093 { 1105 {
1094 if (as -> passnum != 1) 1106 if (as -> passnum != 1)
1107 } 1119 }
1108 1120
1109 if (l -> sym) 1121 if (l -> sym)
1110 { 1122 {
1111 lwasm_register_symbol(as, l, l -> sym, 0, SYMBOL_EXTERN); 1123 lwasm_register_symbol(as, l, l -> sym, 0, SYMBOL_EXTERN);
1124 for ( ; **p; (*p)++) ;
1112 return; 1125 return;
1113 } 1126 }
1114 1127
1115 while (**p) 1128 while (**p)
1116 { 1129 {
1152 register_error(as, l, 1, "Symbol exports only supported for obj target"); 1165 register_error(as, l, 1, "Symbol exports only supported for obj target");
1153 return; 1166 return;
1154 } 1167 }
1155 1168
1156 if (as -> passnum == 1) 1169 if (as -> passnum == 1)
1157 return; 1170 {
1171 skip_operand(p);
1172 return;
1173 }
1174
1175 if (l -> sym)
1176 {
1177 for ( ; **p; (*p)++) ;
1178 }
1158 1179
1159 again: 1180 again:
1160 if (!(l -> sym) || after == 1) 1181 if (!(l -> sym) || after == 1)
1161 { 1182 {
1162 1183