Mercurial > hg > index.cgi
comparison lwasm/pass1.c @ 336:30b2bad9b5eb
Factor some code for simplifying lines so it can be reused
author | William Astle <lost@l-w.ca> |
---|---|
date | Thu, 31 Jul 2014 17:20:11 -0600 |
parents | 507f442dc71e |
children | 98f3e016cfd8 |
comparison
equal
deleted
inserted
replaced
335:af78bad4922c | 336:30b2bad9b5eb |
---|---|
336 if ((as -> target != TARGET_6309) && (instab[opnum].flags & lwasm_insn_is6309)) | 336 if ((as -> target != TARGET_6309) && (instab[opnum].flags & lwasm_insn_is6309)) |
337 lwasm_register_error(as, cl, "Illegal use of 6309 instruction in 6809 mode (%s)", sym); | 337 lwasm_register_error(as, cl, "Illegal use of 6309 instruction in 6809 mode (%s)", sym); |
338 | 338 |
339 if (as -> instruct == 0 || instab[opnum].flags & lwasm_insn_struct) | 339 if (as -> instruct == 0 || instab[opnum].flags & lwasm_insn_struct) |
340 { | 340 { |
341 struct line_expr_s *le; | |
342 | |
343 cl -> len = -1; | 341 cl -> len = -1; |
344 // call parse function | 342 // call parse function |
345 debug_message(as, 100, "len = %d, dlen = %d", cl -> len, cl -> dlen); | 343 debug_message(as, 100, "len = %d, dlen = %d", cl -> len, cl -> dlen); |
346 (instab[opnum].parse)(as, cl, &p1); | 344 (instab[opnum].parse)(as, cl, &p1); |
347 if ((cl -> inmod == 0) && cl -> len >= 0 && cl -> dlen >= 0) | 345 if ((cl -> inmod == 0) && cl -> len >= 0 && cl -> dlen >= 0) |
357 // flag bad operand error | 355 // flag bad operand error |
358 lwasm_register_error(as, cl, "Bad operand (%s)", p1); | 356 lwasm_register_error(as, cl, "Bad operand (%s)", p1); |
359 } | 357 } |
360 | 358 |
361 /* do a reduction on the line expressions to avoid carrying excessive expression baggage if not needed */ | 359 /* do a reduction on the line expressions to avoid carrying excessive expression baggage if not needed */ |
362 as -> cl = cl; | 360 lwasm_reduce_line_exprs(cl); |
363 | |
364 // simplify address | |
365 lwasm_reduce_expr(as, cl -> addr); | |
366 | |
367 // simplify each expression | |
368 for (le = cl -> exprs; le; le = le -> next) | |
369 lwasm_reduce_expr(as, le -> expr); | |
370 | |
371 /* try resolving the instruction as well */ | |
372 if (cl -> insn >= 0 && instab[cl -> insn].resolve) | |
373 { | |
374 (instab[cl -> insn].resolve)(as, cl, 0); | |
375 if ((cl -> inmod == 0) && cl -> len >= 0 && cl -> dlen >= 0) | |
376 { | |
377 if (cl -> len == 0) | |
378 cl -> len = cl -> dlen; | |
379 else | |
380 cl -> dlen = cl -> len; | |
381 } | |
382 } | |
383 | |
384 } | 361 } |
385 else if (as -> instruct == 1) | 362 else if (as -> instruct == 1) |
386 { | 363 { |
387 lwasm_register_error(as, cl, "Bad operand (%s)", p1); | 364 lwasm_register_error(as, cl, "Bad operand (%s)", p1); |
388 } | 365 } |