shithub: rgbds

Download patch

ref: 889302a9e227be63beb434e8d57c430d496b2511
parent: c01317e08dd94002f497f9a3ec65760ae3e1cddc
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Thu Sep 1 19:50:58 EDT 2022

Document the `-H` and `-l` flags

Fixes #1042

--- a/contrib/bash_compl/_rgbasm.bash
+++ b/contrib/bash_compl/_rgbasm.bash
@@ -26,8 +26,10 @@
 	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"
--- a/contrib/zsh_compl/_rgbasm
+++ b/contrib/zsh_compl/_rgbasm
@@ -38,8 +38,10 @@
 	'(- : * 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]'
 
--- 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,7 +66,7 @@
 .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
@@ -73,18 +73,36 @@
 .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
--- a/man/rgbasm.5
+++ b/man/rgbasm.5
@@ -2038,13 +2038,11 @@
 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
--- a/src/asm/main.c
+++ b/src/asm/main.c
@@ -126,7 +126,7 @@
 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 @@
 		case 'V':
 			printf("rgbasm %s\n", get_package_version_string());
 			exit(0);
+
 		case 'v':
 			verbose = true;
 			break;
@@ -351,7 +352,7 @@
 
 	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);
 
--- a/src/asm/opt.c
+++ b/src/asm/opt.c
@@ -175,6 +175,13 @@
 
 	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);
@@ -187,6 +194,13 @@
 				opt_L(true);
 			else
 				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: