X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rmac;a=blobdiff_plain;f=sect.c;h=16a802577dcb2d8ba903e52b9aaeb5ce38bde7f4;hp=b5bd6ecfb04673eccb44fa7cb768da51735f90eb;hb=0c583009c5819e1774b24ef3cb59dde468fd3f60;hpb=03dd34951a331e0b8971195ccef1600fffaea2e6 diff --git a/sect.c b/sect.c index b5bd6ec..16a8025 100644 --- a/sect.c +++ b/sect.c @@ -308,9 +308,11 @@ int AddFixup(uint16_t attr, uint32_t loc, TOKEN * fexpr) // Count the # of tokens in the expression for(len=0; fexpr[len]!=ENDEXPR; len++) { - // Add one to len for 2X tokens - if (fexpr[len] == CONST || fexpr[len] == SYMBOL) + // Add one to len for 2X tokens, two for 3X tokens + if (fexpr[len] == SYMBOL) len++; + else if (fexpr[len] == CONST) + len += 2; } // Add 1 for ENDEXPR @@ -388,7 +390,7 @@ int AddFixup(uint16_t attr, uint32_t loc, TOKEN * fexpr) int ResolveFixups(int sno) { PTR fup; // Current fixup - VALUE eval; // Expression value + uint64_t eval; // Expression value SYM * sy; // (Temp) pointer to a symbol uint16_t i; // (Temp) word int reg2; @@ -514,7 +516,7 @@ int ResolveFixups(int sno) if (eattr & DEFINED) { if (tdb == sno) - eval -= (VALUE)loc; + eval -= (uint32_t)loc; else if (tdb) { error("PC-relative expr across sections"); @@ -525,7 +527,7 @@ int ResolveFixups(int sno) warn("unoptimized short branch"); } else if (obj_format == MWC) - eval -= (VALUE)loc; + eval -= (uint32_t)loc; tdb = 0; eattr &= ~TDB; @@ -549,10 +551,19 @@ int ResolveFixups(int sno) if (eval == 0) { - error("illegal bra.s with zero offset"); - continue; + if (CHECK_OPTS(OPT_NULL_BRA)) + { + // just output a nop + *locp++ = 0x4E; + *locp = 0x71; + continue; + } + else + { + error("illegal bra.s with zero offset"); + continue; + } } - *++locp = (uint8_t)eval; break; // Fixup one-byte value at locp + 1.