diff --git a/contrib/bash_compl/_rgbasm.bash b/contrib/bash_compl/_rgbasm.bash index 4a70fabd..892fe4c0 100755 --- a/contrib/bash_compl/_rgbasm.bash +++ b/contrib/bash_compl/_rgbasm.bash @@ -26,8 +26,10 @@ _rgbasm_completions() { declare -A opts=( [V]="version:normal" [E]="export-all:normal" + [H]="nop-after-halt:normal" [h]="halt-without-nop:normal" [L]="preserve-ld:normal" + [l]="auto-ldh:normal" [v]="verbose:normal" [w]=":normal" [b]="binary-digits:unk" diff --git a/contrib/zsh_compl/_rgbasm b/contrib/zsh_compl/_rgbasm index a27fe46c..11ad0a78 100644 --- a/contrib/zsh_compl/_rgbasm +++ b/contrib/zsh_compl/_rgbasm @@ -38,8 +38,10 @@ local args=( '(- : * options)'{-V,--version}'[Print version number]' '(-E --export-all)'{-E,--export-all}'[Export all symbols]' - '(-h --halt-without-nop)'{-h,--halt-without-nop}'[Avoid outputting a `nop` after `halt`]' - '(-L ---preserve-ld)'{-L,--preserve-ld}'[Prevent auto-optimizing `ld` into `ldh`]' + '(-H --nop-after-halt)'{-H,--nop-after-halt}'[Output a `nop` after `halt`]' + '(-h --halt-without-nop)'{-h,--halt-without-nop}'[Prevent outputting a `nop` after `halt`]' + '(-L --preserve-ld)'{-L,--preserve-ld}'[Prevent optimizing `ld` into `ldh`]' + '(-l --auto-ldh)'{-l,--auto-ldh}'[Optimize `ld` into `ldh`]' '(-v --verbose)'{-v,--verbose}'[Print additional messages regarding progression]' -w'[Disable all warnings]' diff --git a/man/rgbasm.1 b/man/rgbasm.1 index 84a26185..390aef17 100644 --- a/man/rgbasm.1 +++ b/man/rgbasm.1 @@ -13,7 +13,7 @@ .Nd Game Boy assembler .Sh SYNOPSIS .Nm -.Op Fl EhLVvw +.Op Fl EHhLlVvw .Op Fl b Ar chars .Op Fl D Ar name Ns Op = Ns Ar value .Op Fl g Ar chars @@ -66,25 +66,43 @@ Export all labels, including unreferenced and local labels. .It Fl g Ar chars , Fl Fl gfx-chars Ar chars Change the four characters used for gfx constants. The defaults are 0123. -.It Fl h , Fl Fl halt-without-nop +.It Fl H , Fl Fl nop-after-halt By default, .Nm inserts a .Ic nop instruction immediately after any .Ic halt -instruction. +instruction, +but this has been deprecated and prints a warning message the first time it occurs. The -.Fl h -option disables this behavior. +.Fl H +option opts into this insertion, +so no warning will be printed. +.It Fl h , Fl Fl halt-without-nop +Disables inserting a +.Ic nop +instruction immediately after any +.Ic halt +instruction. .It Fl i Ar path , Fl Fl include Ar path Add an include path. .It Fl L , Fl Fl preserve-ld -Disable the optimization that turns loads of the form +By default, +.Nm +optimizes loads of the form .Ic LD [$FF00+n8],A into the opcode -.Ic LDH [$FF00+n8],A -in order to have full control of the result in the final ROM. +.Ic LDH [$FF00+n8],A , +but this has been deprecated and prints a warning message the first time it occurs. +The +.Fl L +option disables this optimization. +.It Fl l , Fl Fl auto-ldh +Optimize loads of the form +.Ic LD [$FF00+n8],A +into the opcode +.Ic LDH [$FF00+n8],A . .It Fl M Ar depend_file , Fl Fl dependfile Ar depend_file Print .Xr make 1 diff --git a/man/rgbasm.5 b/man/rgbasm.5 index 45366290..08a1f8c6 100644 --- a/man/rgbasm.5 +++ b/man/rgbasm.5 @@ -2038,13 +2038,11 @@ can modify are currently: and .Cm W . The Boolean flag options -.Cm h +.Cm H , h , L , and -.Cm L -can be negated as -.Ql OPT !h -and -.Ql OPT !L +.Cm l +can be negated like +.Ql OPT !H to act like omitting them from the command-line. .Pp .Ic POPO diff --git a/src/asm/main.c b/src/asm/main.c index 0a06f6df..c9e825a8 100644 --- a/src/asm/main.c +++ b/src/asm/main.c @@ -126,7 +126,7 @@ static struct option const longopts[] = { static void print_usage(void) { fputs( -"Usage: rgbasm [-EhLVvw] [-b chars] [-D name[=value]] [-g chars] [-i path]\n" +"Usage: rgbasm [-EHhLlVvw] [-b chars] [-D name[=value]] [-g chars] [-i path]\n" " [-M depend_file] [-MG] [-MP] [-MT target_file] [-MQ target_file]\n" " [-o out_file] [-p pad_value] [-r depth] [-W warning] \n" "Useful options:\n" @@ -273,6 +273,7 @@ int main(int argc, char *argv[]) case 'V': printf("rgbasm %s\n", get_package_version_string()); exit(0); + case 'v': verbose = true; break; @@ -351,7 +352,7 @@ int main(int argc, char *argv[]) charmap_New("main", NULL); - // Init lexer and file stack, prodiving file info + // Init lexer and file stack, providing file info lexer_Init(); fstk_Init(mainFileName, maxDepth); diff --git a/src/asm/opt.c b/src/asm/opt.c index c5e32a2f..b406b54a 100644 --- a/src/asm/opt.c +++ b/src/asm/opt.c @@ -175,6 +175,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 'h': if (s[2] == '\0') opt_h(true); @@ -189,6 +196,13 @@ void opt_Parse(char *s) error("Option '!L' does not take an argument\n"); break; + case 'l': + if (s[2] == '\0') + opt_l(true); + else + error("Option '!l' does not take an argument\n"); + break; + default: error("Unknown option '!%c'\n", s[1]); break;