diff --git a/src/asm/opt.c b/src/asm/opt.c index 02177441..9207d841 100644 --- a/src/asm/opt.c +++ b/src/asm/opt.c @@ -14,6 +14,7 @@ struct OptStackEntry { char binary[2]; char gbgfx[4]; int32_t fillByte; + bool haltnop; bool optimizeLoads; bool warningsAreErrors; enum WarningState warningStates[NB_WARNINGS]; @@ -37,6 +38,11 @@ void opt_P(uint8_t fill) fillByte = fill; } +void opt_h(bool halt) +{ + haltnop = halt; +} + void opt_L(bool optimize) { optimizeLoads = optimize; @@ -79,6 +85,13 @@ void opt_Parse(char *s) } break; + case 'h': + if (s[1] == '\0') + opt_h(false); + else + error("Option 'h' does not take an argument\n"); + break; + case 'L': if (s[1] == '\0') opt_L(false); @@ -95,6 +108,13 @@ void opt_Parse(char *s) case '!': // negates flag options that do not take an argument switch (s[1]) { + case 'h': + if (s[2] == '\0') + opt_h(true); + else + error("Option '!h' does not take an argument\n"); + break; + case 'L': if (s[2] == '\0') opt_L(true); @@ -132,6 +152,8 @@ void opt_Push(void) entry->fillByte = fillByte; // Pulled from section.h + entry->haltnop = haltnop; // Pulled from main.h + entry->optimizeLoads = optimizeLoads; // Pulled from main.h // Both of these pulled from warning.h @@ -154,6 +176,7 @@ void opt_Pop(void) opt_B(entry->binary); opt_G(entry->gbgfx); opt_P(entry->fillByte); + opt_h(entry->haltnop); opt_L(entry->optimizeLoads); // opt_W does not apply a whole warning state; it processes one flag string diff --git a/src/asm/rgbasm.5 b/src/asm/rgbasm.5 index d38b5353..55bc9359 100644 --- a/src/asm/rgbasm.5 +++ b/src/asm/rgbasm.5 @@ -1957,15 +1957,18 @@ POPO .Ed .Pp The options that OPT can modify are currently: -.Cm b , g , p , L , +.Cm b , g , p , h , L , and .Cm W . -The Boolean flag option +The Boolean flag options +.Cm h +and .Cm L -can be specified as -.Ql OPT L -or -.Ql OPT !L . +can be negated as +.Ql OPT !h +and +.Ql OPT !L +to act like omitting them from the command-line. .Pp .Ic POPO and diff --git a/test/asm/opt.asm b/test/asm/opt.asm index 0dfdfd75..7962407d 100644 --- a/test/asm/opt.asm +++ b/test/asm/opt.asm @@ -1,14 +1,16 @@ SECTION "test", ROM0 - opt !L ; already the default, but tests parsing "!L" + opt !h, !L ; already the default, but tests parsing "!" pusho - opt p42, L, Wno-div + opt p42, h, L, Wno-div ds 1 ld [$ff88], a + halt println $8000_0000 / -1 popo ds 1 ld [$ff88], a + halt println $8000_0000 / -1 diff --git a/test/asm/opt.err b/test/asm/opt.err index 46551a45..3945fa07 100644 --- a/test/asm/opt.err +++ b/test/asm/opt.err @@ -1,2 +1,2 @@ -warning: opt.asm(14): [-Wdiv] +warning: opt.asm(16): [-Wdiv] Division of -2147483648 by -1 yields -2147483648 diff --git a/test/asm/opt.out.bin b/test/asm/opt.out.bin index f659eb00..913d60d4 100644 Binary files a/test/asm/opt.out.bin and b/test/asm/opt.out.bin differ