mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Remove deprecated DEF-less definitions
This commit is contained in:
34
man/rgbasm.5
34
man/rgbasm.5
@@ -1216,40 +1216,6 @@ See the
|
||||
command-line option in
|
||||
.Xr rgbasm 1 .
|
||||
The same problem can occur if the expansion of a macro invokes another macro, recursively.
|
||||
.Pp
|
||||
The examples above for
|
||||
.Ql EQU ,
|
||||
.Ql = ,
|
||||
.Ql RB ,
|
||||
.Ql RW ,
|
||||
.Ql RL ,
|
||||
and
|
||||
.Ql EQUS
|
||||
all start with
|
||||
.Ql DEF .
|
||||
(A variable definition may start with
|
||||
.Ql REDEF
|
||||
instead, since they are redefinable.)
|
||||
You may use the older syntax without
|
||||
.Ql DEF ,
|
||||
but then the name being defined
|
||||
.Em must not
|
||||
have any whitespace before it;
|
||||
otherwise
|
||||
.Nm
|
||||
will treat it as a macro invocation.
|
||||
Furthermore, without the
|
||||
.Ql DEF
|
||||
keyword,
|
||||
string constants may be expanded for the name.
|
||||
This can lead to surprising results:
|
||||
.Bd -literal -offset indent
|
||||
X EQUS "Y"
|
||||
; this defines Y, not X!
|
||||
X EQU 42
|
||||
; prints "Y $2A"
|
||||
PRINTLN "{X} {Y}"
|
||||
.Ed
|
||||
.Ss Macros
|
||||
One of the best features of an assembler is the ability to write macros for it.
|
||||
Macros can be called with arguments, and can react depending on input using
|
||||
|
||||
103
src/asm/parser.y
103
src/asm/parser.y
@@ -429,7 +429,6 @@ plain_directive:
|
||||
| label cpu_commands
|
||||
| label macro
|
||||
| label directive
|
||||
| assignment_directive
|
||||
;
|
||||
|
||||
endc:
|
||||
@@ -522,9 +521,6 @@ macro_args:
|
||||
}
|
||||
;
|
||||
|
||||
// These commands start with a LABEL.
|
||||
assignment_directive: equ | assignment | rb | rw | rl | equs;
|
||||
|
||||
directive:
|
||||
endc
|
||||
| print
|
||||
@@ -604,105 +600,6 @@ compound_eq:
|
||||
}
|
||||
;
|
||||
|
||||
equ:
|
||||
LABEL POP_EQU const {
|
||||
warning(
|
||||
WARNING_OBSOLETE,
|
||||
"`%s EQU` is deprecated; use `DEF %s EQU`\n",
|
||||
$1.c_str(),
|
||||
$1.c_str()
|
||||
);
|
||||
sym_AddEqu($1, $3);
|
||||
}
|
||||
;
|
||||
|
||||
assignment:
|
||||
LABEL POP_EQUAL const {
|
||||
warning(WARNING_OBSOLETE, "`%s =` is deprecated; use `DEF %s =`\n", $1.c_str(), $1.c_str());
|
||||
sym_AddVar($1, $3);
|
||||
}
|
||||
| LABEL compound_eq const {
|
||||
char const *compoundEqOperator = nullptr;
|
||||
switch ($2) {
|
||||
case RPN_ADD: compoundEqOperator = "+="; break;
|
||||
case RPN_SUB: compoundEqOperator = "-="; break;
|
||||
case RPN_MUL: compoundEqOperator = "*="; break;
|
||||
case RPN_DIV: compoundEqOperator = "/="; break;
|
||||
case RPN_MOD: compoundEqOperator = "%="; break;
|
||||
case RPN_XOR: compoundEqOperator = "^="; break;
|
||||
case RPN_OR: compoundEqOperator = "|="; break;
|
||||
case RPN_AND: compoundEqOperator = "&="; break;
|
||||
case RPN_SHL: compoundEqOperator = "<<="; break;
|
||||
case RPN_SHR: compoundEqOperator = ">>="; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
warning(
|
||||
WARNING_OBSOLETE,
|
||||
"`%s %s` is deprecated; use `DEF %s %s`\n",
|
||||
$1.c_str(),
|
||||
compoundEqOperator,
|
||||
$1.c_str(),
|
||||
compoundEqOperator
|
||||
);
|
||||
compoundAssignment($1, $2, $3);
|
||||
}
|
||||
;
|
||||
|
||||
equs:
|
||||
LABEL POP_EQUS string {
|
||||
warning(
|
||||
WARNING_OBSOLETE,
|
||||
"`%s EQUS` is deprecated; use `DEF %s EQUS`\n",
|
||||
$1.c_str(),
|
||||
$1.c_str()
|
||||
);
|
||||
sym_AddString($1, std::make_shared<std::string>($3));
|
||||
}
|
||||
;
|
||||
|
||||
rb:
|
||||
LABEL POP_RB rs_uconst {
|
||||
warning(
|
||||
WARNING_OBSOLETE,
|
||||
"`%s RB` is deprecated; use `DEF %s RB`\n",
|
||||
$1.c_str(),
|
||||
$1.c_str()
|
||||
);
|
||||
uint32_t rs = sym_GetRSValue();
|
||||
sym_AddEqu($1, rs);
|
||||
sym_SetRSValue(rs + $3);
|
||||
}
|
||||
;
|
||||
|
||||
rw:
|
||||
LABEL POP_RW rs_uconst {
|
||||
warning(
|
||||
WARNING_OBSOLETE,
|
||||
"`%s RW` is deprecated; use `DEF %s RW`\n",
|
||||
$1.c_str(),
|
||||
$1.c_str()
|
||||
);
|
||||
uint32_t rs = sym_GetRSValue();
|
||||
sym_AddEqu($1, rs);
|
||||
sym_SetRSValue(rs + 2 * $3);
|
||||
}
|
||||
;
|
||||
|
||||
rl:
|
||||
LABEL Z80_RL rs_uconst {
|
||||
warning(
|
||||
WARNING_OBSOLETE,
|
||||
"`%s RL` is deprecated; use `DEF %s RL`\n",
|
||||
$1.c_str(),
|
||||
$1.c_str()
|
||||
);
|
||||
uint32_t rs = sym_GetRSValue();
|
||||
sym_AddEqu($1, rs);
|
||||
sym_SetRSValue(rs + 4 * $3);
|
||||
}
|
||||
;
|
||||
|
||||
align:
|
||||
OP_ALIGN align_spec {
|
||||
sect_AlignPC($2.alignment, $2.alignOfs);
|
||||
|
||||
@@ -26,7 +26,6 @@ println \2 ; 10
|
||||
purge prefix
|
||||
endm
|
||||
|
||||
try "", p
|
||||
try "def ", q
|
||||
try "redef ", r
|
||||
|
||||
|
||||
@@ -1,25 +1,3 @@
|
||||
warning: compound-assignment.asm(29) -> compound-assignment.asm::try(4): [-Wobsolete]
|
||||
`p =` is deprecated; use `DEF p =`
|
||||
warning: compound-assignment.asm(29) -> compound-assignment.asm::try(6): [-Wobsolete]
|
||||
`p +=` is deprecated; use `DEF p +=`
|
||||
warning: compound-assignment.asm(29) -> compound-assignment.asm::try(8): [-Wobsolete]
|
||||
`p -=` is deprecated; use `DEF p -=`
|
||||
warning: compound-assignment.asm(29) -> compound-assignment.asm::try(10): [-Wobsolete]
|
||||
`p *=` is deprecated; use `DEF p *=`
|
||||
warning: compound-assignment.asm(29) -> compound-assignment.asm::try(12): [-Wobsolete]
|
||||
`p /=` is deprecated; use `DEF p /=`
|
||||
warning: compound-assignment.asm(29) -> compound-assignment.asm::try(14): [-Wobsolete]
|
||||
`p %=` is deprecated; use `DEF p %=`
|
||||
warning: compound-assignment.asm(29) -> compound-assignment.asm::try(16): [-Wobsolete]
|
||||
`p |=` is deprecated; use `DEF p |=`
|
||||
warning: compound-assignment.asm(29) -> compound-assignment.asm::try(18): [-Wobsolete]
|
||||
`p ^=` is deprecated; use `DEF p ^=`
|
||||
warning: compound-assignment.asm(29) -> compound-assignment.asm::try(20): [-Wobsolete]
|
||||
`p &=` is deprecated; use `DEF p &=`
|
||||
warning: compound-assignment.asm(29) -> compound-assignment.asm::try(22): [-Wobsolete]
|
||||
`p <<=` is deprecated; use `DEF p <<=`
|
||||
warning: compound-assignment.asm(29) -> compound-assignment.asm::try(24): [-Wobsolete]
|
||||
`p >>=` is deprecated; use `DEF p >>=`
|
||||
error: compound-assignment.asm(36):
|
||||
error: compound-assignment.asm(35):
|
||||
Expected constant expression: 'UnDeFiNeD' is not constant at assembly time
|
||||
error: Assembly aborted (1 error)!
|
||||
|
||||
@@ -1,15 +1,3 @@
|
||||
p:
|
||||
$A
|
||||
$F
|
||||
$E
|
||||
$1C
|
||||
$7
|
||||
$1
|
||||
$B
|
||||
$7
|
||||
$5
|
||||
$14
|
||||
$A
|
||||
def q:
|
||||
$A
|
||||
$F
|
||||
|
||||
@@ -28,22 +28,3 @@ redef string equs "there"
|
||||
|
||||
redef constant equ 6*9
|
||||
println constant
|
||||
|
||||
old_constant EQU 42
|
||||
old_string EQUS "hello"
|
||||
|
||||
old_variable = 2 + 2
|
||||
old_variable += 3
|
||||
old_variable *= 4
|
||||
old_variable -= 1
|
||||
old_variable /= 5
|
||||
old_variable %= 7
|
||||
old_variable &= $ffff
|
||||
old_variable |= %1010
|
||||
old_variable ^= &123
|
||||
old_variable <<= 2
|
||||
old_variable >>= 1
|
||||
|
||||
old_byte rb
|
||||
old_word rw
|
||||
old_long rl
|
||||
|
||||
@@ -1,35 +1,3 @@
|
||||
error: def.asm(23):
|
||||
'constant' already defined at def.asm(10)
|
||||
warning: def.asm(32): [-Wobsolete]
|
||||
`old_constant EQU` is deprecated; use `DEF old_constant EQU`
|
||||
warning: def.asm(33): [-Wobsolete]
|
||||
`old_string EQUS` is deprecated; use `DEF old_string EQUS`
|
||||
warning: def.asm(35): [-Wobsolete]
|
||||
`old_variable =` is deprecated; use `DEF old_variable =`
|
||||
warning: def.asm(36): [-Wobsolete]
|
||||
`old_variable +=` is deprecated; use `DEF old_variable +=`
|
||||
warning: def.asm(37): [-Wobsolete]
|
||||
`old_variable *=` is deprecated; use `DEF old_variable *=`
|
||||
warning: def.asm(38): [-Wobsolete]
|
||||
`old_variable -=` is deprecated; use `DEF old_variable -=`
|
||||
warning: def.asm(39): [-Wobsolete]
|
||||
`old_variable /=` is deprecated; use `DEF old_variable /=`
|
||||
warning: def.asm(40): [-Wobsolete]
|
||||
`old_variable %=` is deprecated; use `DEF old_variable %=`
|
||||
warning: def.asm(41): [-Wobsolete]
|
||||
`old_variable &=` is deprecated; use `DEF old_variable &=`
|
||||
warning: def.asm(42): [-Wobsolete]
|
||||
`old_variable |=` is deprecated; use `DEF old_variable |=`
|
||||
warning: def.asm(43): [-Wobsolete]
|
||||
`old_variable ^=` is deprecated; use `DEF old_variable ^=`
|
||||
warning: def.asm(44): [-Wobsolete]
|
||||
`old_variable <<=` is deprecated; use `DEF old_variable <<=`
|
||||
warning: def.asm(45): [-Wobsolete]
|
||||
`old_variable >>=` is deprecated; use `DEF old_variable >>=`
|
||||
warning: def.asm(47): [-Wobsolete]
|
||||
`old_byte RB` is deprecated; use `DEF old_byte RB`
|
||||
warning: def.asm(48): [-Wobsolete]
|
||||
`old_word RW` is deprecated; use `DEF old_word RW`
|
||||
warning: def.asm(49): [-Wobsolete]
|
||||
`old_long RL` is deprecated; use `DEF old_long RL`
|
||||
error: Assembly aborted (1 error)!
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
; the nested EQUS can't use DEF because Y1 would not be expanded
|
||||
def X1 equs "Y1 equs \"\\\"Success!\\\\n\\\"\""
|
||||
def Y1 equs "Z1"
|
||||
X1
|
||||
PRINT Z1
|
||||
def X equs "redef X equs \"\\\"Success!\\\\n\\\"\""
|
||||
X
|
||||
print X
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
warning: equs-nest.asm(4): [-Wobsolete]
|
||||
`Z1 EQUS` is deprecated; use `DEF Z1 EQUS`
|
||||
while expanding symbol "X1"
|
||||
@@ -6,7 +6,7 @@ DEF S EQUS "y"
|
||||
DEF S2 EQUS "yy"
|
||||
|
||||
MACRO m2
|
||||
S\1 ; can't use DEF, so this will EQUS expand
|
||||
def {S}\1
|
||||
ENDM
|
||||
|
||||
m1 = 5
|
||||
@@ -17,7 +17,7 @@ ENDM
|
||||
println x
|
||||
println y
|
||||
println xx
|
||||
println yy
|
||||
println y2
|
||||
|
||||
|
||||
MACRO test_char
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
warning: label-macro-arg.asm(13) -> label-macro-arg.asm::m2(9): [-Wobsolete]
|
||||
`y =` is deprecated; use `DEF y =`
|
||||
warning: label-macro-arg.asm(15) -> label-macro-arg.asm::m2(9): [-Wobsolete]
|
||||
`yy =` is deprecated; use `DEF yy =`
|
||||
error: label-macro-arg.asm(38) -> label-macro-arg.asm::test_char(25):
|
||||
syntax error, unexpected local identifier, expecting identifier
|
||||
while expanding symbol "VAR_DEF"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
error: syntax-error-after-syntax-error.asm(6):
|
||||
syntax error, unexpected newline
|
||||
syntax error, unexpected newline, expecting : or ::
|
||||
error: syntax-error-after-syntax-error.asm(7):
|
||||
syntax error, unexpected newline
|
||||
syntax error, unexpected newline, expecting : or ::
|
||||
To invoke `mac` as a macro it must be indented
|
||||
error: syntax-error-after-syntax-error.asm(8):
|
||||
syntax error, unexpected number
|
||||
syntax error, unexpected number, expecting : or ::
|
||||
To invoke `mac` as a macro it must be indented
|
||||
error: syntax-error-after-syntax-error.asm(9):
|
||||
'mac' already defined at syntax-error-after-syntax-error.asm(1)
|
||||
|
||||
Reference in New Issue
Block a user