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=(
[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"

View File

@@ -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]'

View File

@@ -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

View File

@@ -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

View File

@@ -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] <file>\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);

View File

@@ -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;