From: David Given Date: Sun, 1 Jan 2017 23:28:41 +0000 (+0000) Subject: Jump tables for switch now go in ROM (required by the EM spec). Forward gotos X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=62bc2ab97a2628bca6c6c812c94e7b4e0bbbfd20;p=ack.git Jump tables for switch now go in ROM (required by the EM spec). Forward gotos now work. --- diff --git a/lang/b/compiler/b0.c b/lang/b/compiler/b0.c index a668724ce..7ae35239b 100644 --- a/lang/b/compiler/b0.c +++ b/lang/b/compiler/b0.c @@ -759,13 +759,13 @@ pswitch(void) deflab = brklab; C_df_dlb(swlab); - C_con_ilb(deflab); - C_con_cst(swp - sswp); + C_rom_ilb(deflab); + C_rom_cst(swp - sswp); while (swp > sswp && swp > swtab) { --swp; - C_con_cst(swp->swval); - C_con_ilb(swp->swlab); + C_rom_cst(swp->swval); + C_rom_ilb(swp->swlab); } C_df_ilb(brklab); @@ -812,6 +812,8 @@ stmt: case GOTO: if ((o = symbol()) != NAME) goto syntax; + if (bsym->offset == 0) + bsym->offset = isn++; jump(bsym->offset); goto semi; @@ -913,7 +915,8 @@ stmt: goto stmt; } bsym->class = INTERN; - bsym->offset = isn++; + if (bsym->offset == 0) + bsym->offset = isn++; fnlabel(bsym->offset); goto stmt; }