Permalink
Browse files

ensure that labels are > 0. only write them if != 0

  • Loading branch information...
1 parent 78f5442 commit 04f1e6f4df477d4168a8dc56c7cf9de6d346ac4b @kjs kjs committed Jun 23, 2012
Showing with 5 additions and 3 deletions.
  1. +1 −1 src/gencode.c
  2. +4 −2 src/instr.c
View
@@ -157,7 +157,7 @@ Generate label identifiers.
static int
gen_label(M1_compiler *comp) {
assert(comp != NULL);
- return comp->label++;
+ return ++comp->label;
}
View
@@ -79,7 +79,9 @@ static const char regs[REG_TYPE_NUM + 2] = {'I', 'N', 'S', 'P', ' ', 'L'};
static void
write_instr(M1_compiler *comp, m0_instr *i) {
-
+ if (i->label != 0)
+ fprintf(OUT, "L%d:\n", i->label);
+
switch (i->numops) {
case 0:
fprintf(OUT, " %s\n", m0_instr_names[(int)i->opcode]);
@@ -213,7 +215,7 @@ mk_instr(M1_compiler *comp, m0_opcode opcode, char const * const format, ...) {
comp->lastgenerated = ins;
-// write_instr(comp, ins);
+ // write_instr(comp, ins);
return ins;
}

0 comments on commit 04f1e6f

Please sign in to comment.