comparison lwasm/pass1.c @ 529:428039e88a0b

Fix macro definition to include all lines This may cause problems if anyone is doing "clever" things with conditionals and the like. However, it does fix the problem that lines without opcodes on them weren't being included in the macros definition. This needs to percolate for a while before being released.
author William Astle <lost@l-w.ca>
date Wed, 09 Feb 2022 21:44:28 -0700
parents 7e41d6123175
children 65c2085e0398
comparison
equal deleted inserted replaced
528:4536f0e61425 529:428039e88a0b
65 int stspace; 65 int stspace;
66 char *tok, *sym = NULL; 66 char *tok, *sym = NULL;
67 int opnum; 67 int opnum;
68 int lc = 1; 68 int lc = 1;
69 int nomacro; 69 int nomacro;
70 int wasmacro;
70 71
71 for (;;) 72 for (;;)
72 { 73 {
73 nomacro = 0; 74 nomacro = 0;
74 if (sym) 75 if (sym)
107 lc = 1; 108 lc = 1;
108 continue; 109 continue;
109 } 110 }
110 debug_message(as, 75, "Read line: %s", line); 111 debug_message(as, 75, "Read line: %s", line);
111 112
113 wasmacro = as -> inmacro;
112 cl = lw_alloc(sizeof(line_t)); 114 cl = lw_alloc(sizeof(line_t));
113 memset(cl, 0, sizeof(line_t)); 115 memset(cl, 0, sizeof(line_t));
114 cl -> outputl = -1; 116 cl -> outputl = -1;
115 cl -> linespec = lw_strdup(input_curspec(as)); 117 cl -> linespec = lw_strdup(input_curspec(as));
116 cl -> prev = as -> line_tail; 118 cl -> prev = as -> line_tail;
310 312
311 // if we're inside a macro definition and not at ENDM, 313 // if we're inside a macro definition and not at ENDM,
312 // add the line to the macro definition and continue 314 // add the line to the macro definition and continue
313 if (as -> inmacro && !(instab[opnum].flags & lwasm_insn_endm)) 315 if (as -> inmacro && !(instab[opnum].flags & lwasm_insn_endm))
314 { 316 {
315 add_macro_line(as, line);
316 goto linedone; 317 goto linedone;
317 } 318 }
318 319
319 // if skipping a condition and the operation code doesn't 320 // if skipping a condition and the operation code doesn't
320 // operate within a condition (not a conditional) 321 // operate within a condition (not a conditional)
418 } 419 }
419 } 420 }
420 } 421 }
421 422
422 linedone: 423 linedone:
424 if (as -> inmacro && wasmacro)
425 add_macro_line(as, line);
423 if (!as -> skipcond && !as -> inmacro) 426 if (!as -> skipcond && !as -> inmacro)
424 { 427 {
425 if (cl -> sym && cl -> symset == 0) 428 if (cl -> sym && cl -> symset == 0)
426 { 429 {
427 debug_message(as, 50, "Register symbol %s: %s", cl -> sym, lw_expr_print(cl -> addr)); 430 debug_message(as, 50, "Register symbol %s: %s", cl -> sym, lw_expr_print(cl -> addr));