Document the -H and -l flags

Fixes #1042
This commit is contained in:
Rangi
2022-09-01 23:50:58 -04:00
committed by Eldred Habert
parent c01317e08d
commit 889302a9e2
6 changed files with 53 additions and 18 deletions

View File

@@ -26,8 +26,10 @@ _rgbasm_completions() {
declare -A opts=( declare -A opts=(
[V]="version:normal" [V]="version:normal"
[E]="export-all:normal" [E]="export-all:normal"
[H]="nop-after-halt:normal"
[h]="halt-without-nop:normal" [h]="halt-without-nop:normal"
[L]="preserve-ld:normal" [L]="preserve-ld:normal"
[l]="auto-ldh:normal"
[v]="verbose:normal" [v]="verbose:normal"
[w]=":normal" [w]=":normal"
[b]="binary-digits:unk" [b]="binary-digits:unk"

View File

@@ -38,8 +38,10 @@ local args=(
'(- : * options)'{-V,--version}'[Print version number]' '(- : * options)'{-V,--version}'[Print version number]'
'(-E --export-all)'{-E,--export-all}'[Export all symbols]' '(-E --export-all)'{-E,--export-all}'[Export all symbols]'
'(-h --halt-without-nop)'{-h,--halt-without-nop}'[Avoid outputting a `nop` after `halt`]' '(-H --nop-after-halt)'{-H,--nop-after-halt}'[Output a `nop` after `halt`]'
'(-L ---preserve-ld)'{-L,--preserve-ld}'[Prevent auto-optimizing `ld` into `ldh`]' '(-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]' '(-v --verbose)'{-v,--verbose}'[Print additional messages regarding progression]'
-w'[Disable all warnings]' -w'[Disable all warnings]'

View File

@@ -13,7 +13,7 @@
.Nd Game Boy assembler .Nd Game Boy assembler
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl EhLVvw .Op Fl EHhLlVvw
.Op Fl b Ar chars .Op Fl b Ar chars
.Op Fl D Ar name Ns Op = Ns Ar value .Op Fl D Ar name Ns Op = Ns Ar value
.Op Fl g Ar chars .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 .It Fl g Ar chars , Fl Fl gfx-chars Ar chars
Change the four characters used for gfx constants. Change the four characters used for gfx constants.
The defaults are 0123. The defaults are 0123.
.It Fl h , Fl Fl halt-without-nop .It Fl H , Fl Fl nop-after-halt
By default, By default,
.Nm .Nm
inserts a inserts a
.Ic nop .Ic nop
instruction immediately after any instruction immediately after any
.Ic halt .Ic halt
instruction. instruction,
but this has been deprecated and prints a warning message the first time it occurs.
The The
.Fl h .Fl H
option disables this behavior. 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 .It Fl i Ar path , Fl Fl include Ar path
Add an include path. Add an include path.
.It Fl L , Fl Fl preserve-ld .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 .Ic LD [$FF00+n8],A
into the opcode into the opcode
.Ic LDH [$FF00+n8],A .Ic LDH [$FF00+n8],A ,
in order to have full control of the result in the final ROM. 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 .It Fl M Ar depend_file , Fl Fl dependfile Ar depend_file
Print Print
.Xr make 1 .Xr make 1

View File

@@ -2038,13 +2038,11 @@ can modify are currently:
and and
.Cm W . .Cm W .
The Boolean flag options The Boolean flag options
.Cm h .Cm H , h , L ,
and and
.Cm L .Cm l
can be negated as can be negated like
.Ql OPT !h .Ql OPT !H
and
.Ql OPT !L
to act like omitting them from the command-line. to act like omitting them from the command-line.
.Pp .Pp
.Ic POPO .Ic POPO

View File

@@ -126,7 +126,7 @@ static struct option const longopts[] = {
static void print_usage(void) static void print_usage(void)
{ {
fputs( 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" " [-M depend_file] [-MG] [-MP] [-MT target_file] [-MQ target_file]\n"
" [-o out_file] [-p pad_value] [-r depth] [-W warning] <file>\n" " [-o out_file] [-p pad_value] [-r depth] [-W warning] <file>\n"
"Useful options:\n" "Useful options:\n"
@@ -273,6 +273,7 @@ int main(int argc, char *argv[])
case 'V': case 'V':
printf("rgbasm %s\n", get_package_version_string()); printf("rgbasm %s\n", get_package_version_string());
exit(0); exit(0);
case 'v': case 'v':
verbose = true; verbose = true;
break; break;
@@ -351,7 +352,7 @@ int main(int argc, char *argv[])
charmap_New("main", NULL); charmap_New("main", NULL);
// Init lexer and file stack, prodiving file info // Init lexer and file stack, providing file info
lexer_Init(); lexer_Init();
fstk_Init(mainFileName, maxDepth); fstk_Init(mainFileName, maxDepth);

View File

@@ -175,6 +175,13 @@ void opt_Parse(char *s)
case '!': // negates flag options that do not take an argument case '!': // negates flag options that do not take an argument
switch (s[1]) { 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': case 'h':
if (s[2] == '\0') if (s[2] == '\0')
opt_h(true); opt_h(true);
@@ -189,6 +196,13 @@ void opt_Parse(char *s)
error("Option '!L' does not take an argument\n"); error("Option '!L' does not take an argument\n");
break; break;
case 'l':
if (s[2] == '\0')
opt_l(true);
else
error("Option '!l' does not take an argument\n");
break;
default: default:
error("Unknown option '!%c'\n", s[1]); error("Unknown option '!%c'\n", s[1]);
break; break;