mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Remove deprecated RGBASM features (#1215)
- Escaped commas "\," inside strings - `name: MACRO` syntax - `__FILE__` and `__LINE__` - `-H/--nop-after-halt` and `-l/--auto-ldh` on by default
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "helpers.h"
|
||||
|
||||
extern bool haltnop;
|
||||
extern bool haltNop;
|
||||
extern bool warnOnHaltNop;
|
||||
extern bool optimizeLoads;
|
||||
extern bool warnOnLdOpt;
|
||||
|
||||
30
man/rgbasm.1
30
man/rgbasm.1
@@ -71,24 +71,14 @@ Export all labels, including unreferenced and local labels.
|
||||
Change the four characters used for gfx constants.
|
||||
The defaults are 0123.
|
||||
.It Fl H , Fl Fl nop-after-halt
|
||||
By default,
|
||||
.Nm
|
||||
inserts a
|
||||
.Ic nop
|
||||
instruction immediately after any
|
||||
.Ic halt
|
||||
instruction,
|
||||
but this has been deprecated and prints a warning message the first time it occurs.
|
||||
The
|
||||
.Fl H
|
||||
option opts into this insertion,
|
||||
so no warning will be printed.
|
||||
.It Fl h , Fl Fl halt-without-nop
|
||||
Disables inserting a
|
||||
Inserts a
|
||||
.Ic nop
|
||||
instruction immediately after any
|
||||
.Ic halt
|
||||
instruction.
|
||||
This option is deprecated and will be removed in the next version.
|
||||
.It Fl h , Fl Fl halt-without-nop
|
||||
This option is redundant and will be removed in the next version.
|
||||
.It Fl I Ar path , Fl Fl include Ar path
|
||||
Add a new
|
||||
.Dq include path ;
|
||||
@@ -105,21 +95,13 @@ first looks up the provided path from its working directory; if this fails, it t
|
||||
.Dq include path
|
||||
directories, in the order they were provided.
|
||||
.It Fl L , Fl Fl preserve-ld
|
||||
By default,
|
||||
.Nm
|
||||
optimizes loads of the form
|
||||
.Ic LD [$FF00+n8],A
|
||||
into the opcode
|
||||
.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.
|
||||
This option is redundant and will be removed in the next version.
|
||||
.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 .
|
||||
This option is deprecated and will be removed in the next version.
|
||||
.It Fl M Ar depend_file , Fl Fl dependfile Ar depend_file
|
||||
Print
|
||||
.Xr make 1
|
||||
|
||||
10
man/rgbasm.5
10
man/rgbasm.5
@@ -1249,16 +1249,6 @@ The example above defines
|
||||
as a new macro.
|
||||
String constants are not expanded within the name of the macro.
|
||||
.Pp
|
||||
(Using the
|
||||
.Em deprecated
|
||||
older syntax
|
||||
.Ql MyMacro: MACRO
|
||||
instead of
|
||||
.Ql MACRO MyMacro ,
|
||||
with a single colon
|
||||
.Ql \&:
|
||||
following the macro's name, string constants may be expanded for the name.)
|
||||
.Pp
|
||||
Macros can't be exported or imported.
|
||||
.Pp
|
||||
Plainly nesting macro definitions is not allowed, but this can be worked around using
|
||||
|
||||
@@ -1722,12 +1722,6 @@ static size_t appendStringLiteral(size_t i)
|
||||
c = '\\';
|
||||
break;
|
||||
|
||||
case ',': // `\,` inside a macro arg string literal
|
||||
warning(WARNING_OBSOLETE,
|
||||
"`\\,` is deprecated inside strings\n");
|
||||
shiftChar();
|
||||
break;
|
||||
|
||||
default:
|
||||
error("Illegal character escape %s\n", printChar(c));
|
||||
shiftChar();
|
||||
|
||||
@@ -59,7 +59,7 @@ bool failedOnMissingInclude = false;
|
||||
bool generatePhonyDeps = false;
|
||||
char *targetFileName = NULL;
|
||||
|
||||
bool haltnop;
|
||||
bool haltNop;
|
||||
bool warnOnHaltNop;
|
||||
bool optimizeLoads;
|
||||
bool warnOnLdOpt;
|
||||
@@ -164,9 +164,9 @@ int main(int argc, char *argv[])
|
||||
opt_G("0123");
|
||||
opt_P(0);
|
||||
opt_Q(16);
|
||||
haltnop = true;
|
||||
haltNop = false;
|
||||
warnOnHaltNop = true;
|
||||
optimizeLoads = true;
|
||||
optimizeLoads = false;
|
||||
warnOnLdOpt = true;
|
||||
verbose = false;
|
||||
warnings = true;
|
||||
@@ -209,32 +209,39 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'H':
|
||||
if (!haltnop)
|
||||
if (warnOnHaltNop)
|
||||
warning(WARNING_OBSOLETE,
|
||||
"Automatic `nop` after `halt` is deprecated\n");
|
||||
else
|
||||
errx("`-H` and `-h` don't make sense together");
|
||||
haltNop = true;
|
||||
warnOnHaltNop = false;
|
||||
break;
|
||||
case 'h':
|
||||
if (!warnOnHaltNop)
|
||||
if (haltNop)
|
||||
errx("`-H` and `-h` don't make sense together");
|
||||
haltnop = false;
|
||||
break;
|
||||
|
||||
// `-i` was the only short option for `--include` until `-I` was
|
||||
// introduced to better match the `-I dir` option of gcc and clang.
|
||||
// `-i` is now undocumented but still supported for now.
|
||||
case 'I':
|
||||
case 'i':
|
||||
warning(WARNING_OBSOLETE, "`-i` is deprecated; use `-I`\n");
|
||||
// fallthrough
|
||||
case 'I':
|
||||
fstk_AddIncludePath(musl_optarg);
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
if (!warnOnLdOpt)
|
||||
if (optimizeLoads)
|
||||
errx("`-L` and `-l` don't make sense together");
|
||||
optimizeLoads = false;
|
||||
break;
|
||||
case 'l':
|
||||
if (!optimizeLoads)
|
||||
if (warnOnLdOpt)
|
||||
warning(WARNING_OBSOLETE,
|
||||
"Automatic `ld` to `ldh` optimization is deprecated\n");
|
||||
else
|
||||
errx("`-L` and `-l` don't make sense together");
|
||||
optimizeLoads = true;
|
||||
warnOnLdOpt = false;
|
||||
break;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ struct OptStackEntry {
|
||||
char gbgfx[4];
|
||||
uint8_t fixPrecision;
|
||||
uint8_t fillByte;
|
||||
bool haltnop;
|
||||
bool haltNop;
|
||||
bool warnOnHaltNop;
|
||||
bool optimizeLoads;
|
||||
bool warnOnLdOpt;
|
||||
@@ -72,7 +72,7 @@ void opt_H(bool warn)
|
||||
|
||||
void opt_h(bool halt)
|
||||
{
|
||||
haltnop = halt;
|
||||
haltNop = halt;
|
||||
}
|
||||
|
||||
void opt_L(bool optimize)
|
||||
@@ -265,7 +265,7 @@ void opt_Push(void)
|
||||
|
||||
entry->fillByte = fillByte; // Pulled from section.h
|
||||
|
||||
entry->haltnop = haltnop; // Pulled from main.h
|
||||
entry->haltNop = haltNop; // Pulled from main.h
|
||||
entry->warnOnHaltNop = warnOnHaltNop;
|
||||
|
||||
entry->optimizeLoads = optimizeLoads; // Pulled from main.h
|
||||
@@ -295,7 +295,7 @@ void opt_Pop(void)
|
||||
opt_P(entry->fillByte);
|
||||
opt_Q(entry->fixPrecision);
|
||||
opt_H(entry->warnOnHaltNop);
|
||||
opt_h(entry->haltnop);
|
||||
opt_h(entry->haltNop);
|
||||
opt_L(entry->optimizeLoads);
|
||||
opt_l(entry->warnOnLdOpt);
|
||||
opt_R(entry->maxRecursionDepth);
|
||||
|
||||
@@ -1165,14 +1165,6 @@ macrodef : T_POP_MACRO {
|
||||
sym_AddMacro($3, captureBody.lineNo, captureBody.body,
|
||||
captureBody.size);
|
||||
}
|
||||
| T_LABEL T_COLON T_POP_MACRO T_NEWLINE {
|
||||
warning(WARNING_OBSOLETE, "`%s: MACRO` is deprecated; use `MACRO %s`\n", $1, $1);
|
||||
$<captureTerminated>$ = lexer_CaptureMacroBody(&captureBody);
|
||||
} endofline {
|
||||
if ($<captureTerminated>5)
|
||||
sym_AddMacro($1, captureBody.lineNo, captureBody.body,
|
||||
captureBody.size);
|
||||
}
|
||||
;
|
||||
|
||||
rsset : T_POP_RSSET uconst { sym_AddVar("_RS", $2); }
|
||||
@@ -1905,10 +1897,11 @@ z80_ei : T_Z80_EI { sect_AbsByte(0xFB); }
|
||||
|
||||
z80_halt : T_Z80_HALT {
|
||||
sect_AbsByte(0x76);
|
||||
if (haltnop) {
|
||||
if (haltNop) {
|
||||
if (warnOnHaltNop) {
|
||||
warnOnHaltNop = false;
|
||||
warning(WARNING_OBSOLETE, "`nop` after `halt` will stop being the default; pass `-H` to opt into it\n");
|
||||
warning(WARNING_OBSOLETE,
|
||||
"Automatic `nop` after `halt` is deprecated\n");
|
||||
}
|
||||
sect_AbsByte(0x00);
|
||||
}
|
||||
@@ -2021,7 +2014,8 @@ z80_ld_mem : T_Z80_LD op_mem_ind T_COMMA T_MODE_SP {
|
||||
&& $2.val >= 0xFF00) {
|
||||
if (warnOnLdOpt) {
|
||||
warnOnLdOpt = false;
|
||||
warning(WARNING_OBSOLETE, "ld optimization will stop being the default; pass `-l` to opt into it\n");
|
||||
warning(WARNING_OBSOLETE,
|
||||
"Automatic `ld` to `ldh` optimization is deprecated\n");
|
||||
}
|
||||
sect_AbsByte(0xE0);
|
||||
sect_AbsByte($2.val & 0xFF);
|
||||
@@ -2073,7 +2067,8 @@ z80_ld_a : T_Z80_LD reg_r T_COMMA c_ind {
|
||||
&& $4.val >= 0xFF00) {
|
||||
if (warnOnLdOpt) {
|
||||
warnOnLdOpt = false;
|
||||
warning(WARNING_OBSOLETE, "ld optimization will stop being the default; pass `-l` to opt into it\n");
|
||||
warning(WARNING_OBSOLETE,
|
||||
"Automatic `ld` to `ldh` optimization is deprecated\n");
|
||||
}
|
||||
sect_AbsByte(0xF0);
|
||||
sect_AbsByte($4.val & 0xFF);
|
||||
|
||||
@@ -77,50 +77,6 @@ static int32_t Callback_NARG(void)
|
||||
return macro_NbArgs();
|
||||
}
|
||||
|
||||
static int32_t Callback__LINE__(void)
|
||||
{
|
||||
warning(WARNING_OBSOLETE, "`__LINE__` is deprecated\n");
|
||||
|
||||
return lexer_GetLineNo();
|
||||
}
|
||||
|
||||
static char const *Callback__FILE__(void)
|
||||
{
|
||||
warning(WARNING_OBSOLETE, "`__FILE__` is deprecated\n");
|
||||
|
||||
// There are only two call sites for this; one copies the contents directly, the other is
|
||||
// EQUS expansions, which cannot straddle file boundaries. So this should be fine.
|
||||
static char *buf = NULL;
|
||||
static size_t bufsize = 0;
|
||||
char const *fileName = fstk_GetFileName();
|
||||
size_t j = 1;
|
||||
|
||||
assert(fileName[0]);
|
||||
// The assertion above ensures the loop runs at least once
|
||||
for (size_t i = 0; fileName[i]; i++, j++) {
|
||||
// Account for the extra backslash inserted below
|
||||
if (fileName[i] == '"')
|
||||
j++;
|
||||
// Ensure there will be enough room; DO NOT PRINT ANYTHING ABOVE THIS!
|
||||
if (j + 2 >= bufsize) { // Always keep room for 2 tail chars
|
||||
bufsize = bufsize ? bufsize * 2 : 64;
|
||||
buf = realloc(buf, bufsize);
|
||||
if (!buf)
|
||||
fatalerror("Failed to grow buffer for file name: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
// Escape quotes, since we're returning a string
|
||||
if (fileName[i] == '"')
|
||||
buf[j - 1] = '\\';
|
||||
buf[j] = fileName[i];
|
||||
}
|
||||
// Write everything after the loop, to ensure the buffer has been allocated
|
||||
buf[0] = '"';
|
||||
buf[j++] = '"';
|
||||
buf[j] = '\0';
|
||||
return buf;
|
||||
}
|
||||
|
||||
static int32_t CallbackPC(void)
|
||||
{
|
||||
struct Section const *section = sect_GetSymbolSection();
|
||||
@@ -687,21 +643,13 @@ static struct Symbol *createBuiltinSymbol(char const *symName)
|
||||
void sym_Init(time_t now)
|
||||
{
|
||||
PCSymbol = createBuiltinSymbol("@");
|
||||
_NARGSymbol = createBuiltinSymbol("_NARG");
|
||||
// __LINE__ is deprecated
|
||||
struct Symbol *__LINE__Symbol = createBuiltinSymbol("__LINE__");
|
||||
// __FILE__ is deprecated
|
||||
struct Symbol *__FILE__Symbol = createBuiltinSymbol("__FILE__");
|
||||
|
||||
PCSymbol->type = SYM_LABEL;
|
||||
PCSymbol->section = NULL;
|
||||
PCSymbol->numCallback = CallbackPC;
|
||||
|
||||
_NARGSymbol = createBuiltinSymbol("_NARG");
|
||||
_NARGSymbol->type = SYM_EQU;
|
||||
_NARGSymbol->numCallback = Callback_NARG;
|
||||
__LINE__Symbol->type = SYM_EQU;
|
||||
__LINE__Symbol->numCallback = Callback__LINE__;
|
||||
__FILE__Symbol->type = SYM_EQUS;
|
||||
__FILE__Symbol->strCallback = Callback__FILE__;
|
||||
|
||||
sym_AddVar("_RS", 0)->isBuiltin = true;
|
||||
|
||||
@@ -758,4 +706,5 @@ void sym_Init(time_t now)
|
||||
#undef addSym
|
||||
|
||||
sym_SetCurrentSymbolScope(NULL);
|
||||
anonLabelID = 0;}
|
||||
anonLabelID = 0;
|
||||
}
|
||||
|
||||
1
test/asm/.gitignore
vendored
1
test/asm/.gitignore
vendored
@@ -1,3 +1,2 @@
|
||||
/quote\"file.*
|
||||
/version.asm
|
||||
/version.out
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
PRINTLN "{__FILE__}"
|
||||
@@ -1,2 +0,0 @@
|
||||
warning: file-sym.asm(1): [-Wobsolete]
|
||||
`__FILE__` is deprecated
|
||||
@@ -1 +0,0 @@
|
||||
"file-sym.asm"
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
SECTION "Label testing", WRAMX
|
||||
|
||||
Lab:
|
||||
@@ -7,7 +6,7 @@ SECTION "Label testing", WRAMX
|
||||
|
||||
: ; anonymous
|
||||
|
||||
mac: MACRO
|
||||
MACRO mac
|
||||
println "\1"
|
||||
ENDM
|
||||
mac :
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
warning: label-indent.asm(10): [-Wobsolete]
|
||||
`mac: MACRO` is deprecated; use `MACRO mac`
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
MACRO new ; comment
|
||||
println "in with the ", \1
|
||||
ENDM ; comment
|
||||
|
||||
new 2
|
||||
|
||||
old: MACRO ; comment
|
||||
println "out with the ", \1
|
||||
ENDM ; comment
|
||||
|
||||
MACRO new ; comment
|
||||
println "in with the ", \1
|
||||
ENDM ; comment
|
||||
|
||||
old 1
|
||||
new 2
|
||||
|
||||
bad1: MACRO bad2 ; comment
|
||||
println "which?"
|
||||
ENDM ; comment
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
warning: macro-syntax.asm(2): [-Wobsolete]
|
||||
`old: MACRO` is deprecated; use `MACRO old`
|
||||
error: macro-syntax.asm(13):
|
||||
syntax error, unexpected identifier, expecting newline
|
||||
error: macro-syntax.asm(15):
|
||||
error: macro-syntax.asm(7):
|
||||
syntax error, unexpected MACRO
|
||||
error: macro-syntax.asm(8):
|
||||
Macro argument '\1' not defined
|
||||
error: macro-syntax.asm(9):
|
||||
syntax error, unexpected ENDM
|
||||
error: Assembly aborted (2 errors)!
|
||||
error: Assembly aborted (3 errors)!
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
out with the $1
|
||||
in with the $2
|
||||
which?
|
||||
out with the
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
error: macro-syntax.asm(13):
|
||||
error: macro-syntax.asm(7):
|
||||
syntax error
|
||||
error: macro-syntax.asm(15):
|
||||
error: macro-syntax.asm(8):
|
||||
Macro argument '\1' not defined
|
||||
error: macro-syntax.asm(9):
|
||||
syntax error
|
||||
error: Assembly aborted (2 errors)!
|
||||
error: Assembly aborted (3 errors)!
|
||||
|
||||
@@ -242,6 +242,7 @@ jrlabel:
|
||||
ei
|
||||
halt
|
||||
nop
|
||||
nop
|
||||
scf
|
||||
stop
|
||||
FOR BYTE, 256
|
||||
|
||||
Reference in New Issue
Block a user