Deprecate DEF-less definitions (#1193)

This commit is contained in:
Rangi
2023-11-02 05:18:59 -04:00
committed by GitHub
parent 02f06407b1
commit bb7c34db65
79 changed files with 351 additions and 264 deletions

View File

@@ -956,29 +956,58 @@ compoundeq : T_POP_ADDEQ { $$ = RPN_ADD; }
| T_POP_SHREQ { $$ = RPN_SHR; } | T_POP_SHREQ { $$ = RPN_SHR; }
; ;
equ : T_LABEL T_POP_EQU const { sym_AddEqu($1, $3); } equ : T_LABEL T_POP_EQU const {
warning(WARNING_OBSOLETE, "`%s EQU` is deprecated; use `DEF %s EQU`\n", $1, $1);
sym_AddEqu($1, $3);
}
; ;
assignment : T_LABEL T_POP_EQUAL const { sym_AddVar($1, $3); } assignment : T_LABEL T_POP_EQUAL const {
| T_LABEL compoundeq const { compoundAssignment($1, $2, $3); } warning(WARNING_OBSOLETE, "`%s =` is deprecated; use `DEF %s =`\n", $1, $1);
sym_AddVar($1, $3);
}
| T_LABEL compoundeq const {
static const char *compoundEqOperators[] = {
[RPN_ADD] = "+=",
[RPN_SUB] = "-=",
[RPN_MUL] = "*=",
[RPN_DIV] = "/=",
[RPN_MOD] = "%=",
[RPN_XOR] = "^=",
[RPN_OR] = "|=",
[RPN_AND] = "&=",
[RPN_SHL] = "<<=",
[RPN_SHR] = ">>=",
};
warning(WARNING_OBSOLETE, "`%s %s` is deprecated; use `DEF %s %s`\n",
$1, compoundEqOperators[$2], $1, compoundEqOperators[$2]);
compoundAssignment($1, $2, $3);
}
; ;
equs : T_LABEL T_POP_EQUS string { sym_AddString($1, $3); } equs : T_LABEL T_POP_EQUS string {
warning(WARNING_OBSOLETE, "`%s EQUS` is deprecated; use `DEF %s EQUS`\n", $1, $1);
sym_AddString($1, $3);
}
; ;
rb : T_LABEL T_POP_RB rs_uconst { rb : T_LABEL T_POP_RB rs_uconst {
warning(WARNING_OBSOLETE, "`%s RB` is deprecated; use `DEF %s RB`\n", $1, $1);
sym_AddEqu($1, sym_GetConstantValue("_RS")); sym_AddEqu($1, sym_GetConstantValue("_RS"));
sym_AddVar("_RS", sym_GetConstantValue("_RS") + $3); sym_AddVar("_RS", sym_GetConstantValue("_RS") + $3);
} }
; ;
rw : T_LABEL T_POP_RW rs_uconst { rw : T_LABEL T_POP_RW rs_uconst {
warning(WARNING_OBSOLETE, "`%s RW` is deprecated; use `DEF %s RW`\n", $1, $1);
sym_AddEqu($1, sym_GetConstantValue("_RS")); sym_AddEqu($1, sym_GetConstantValue("_RS"));
sym_AddVar("_RS", sym_GetConstantValue("_RS") + 2 * $3); sym_AddVar("_RS", sym_GetConstantValue("_RS") + 2 * $3);
} }
; ;
rl : T_LABEL T_Z80_RL rs_uconst { rl : T_LABEL T_Z80_RL rs_uconst {
warning(WARNING_OBSOLETE, "`%s RL` is deprecated; use `DEF %s RL`\n", $1, $1);
sym_AddEqu($1, sym_GetConstantValue("_RS")); sym_AddEqu($1, sym_GetConstantValue("_RS"));
sym_AddVar("_RS", sym_GetConstantValue("_RS") + 4 * $3); sym_AddVar("_RS", sym_GetConstantValue("_RS") + 4 * $3);
} }

View File

@@ -10,9 +10,9 @@ ENDM
MACRO mac MACRO mac
println \<2__> + \<1_2> + \<\1> println \<2__> + \<1_2> + \<\1>
x = 2 def x = 2
println \<{d:x}> + \<1_{d:x}> + \<\<\<13>>> println \<{d:x}> + \<1_{d:x}> + \<\<\<13>>>
y equs "NARG" def y equs "NARG"
println \<x> + \<1_{d:x}_> + \<\<\<_{y}>>> println \<x> + \<1_{d:x}_> + \<\<\<_{y}>>>
ENDM ENDM

View File

@@ -1,18 +1,18 @@
X = 42 DEF X = 42
PRINTLN "{X}" PRINTLN "{X}"
PRINTLN "{x:X}" PRINTLN "{x:X}"
PRINTLN "{X:X}" PRINTLN "{X:X}"
PRINTLN "{d:X}" PRINTLN "{d:X}"
PRINTLN "{b:X}" PRINTLN "{b:X}"
Y equ 1337 DEF Y EQU 1337
PRINTLN "{b:Y}" PRINTLN "{b:Y}"
rsreset rsreset
R rb 0 DEF R RB 0
PRINTLN "{d:R}" PRINTLN "{d:R}"
S equs "You can't format me!" DEF S EQUS "You can't format me!"
PRINTLN "{X:S}" PRINTLN "{X:S}"
SECTION "Test", ROM0 SECTION "Test", ROM0

View File

@@ -2,17 +2,6 @@ macro tickle
; There once was a bug where overwriting worked only on the second try, so ; There once was a bug where overwriting worked only on the second try, so
; try everything twice for good measure ; try everything twice for good measure
; Skip this syntax for EQUS, as it is invalid
IF \2
\1 = 0
\1 = 0
PRINTLN \1
\1 EQU 0
\1 EQU 0
PRINTLN \1
ENDC
PURGE \1 PURGE \1
PURGE \1 PURGE \1
PRINTLN \1 PRINTLN \1

View File

@@ -1,57 +1,49 @@
error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(7): error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(5):
'__UTC_YEAR__' already defined as constant at <command-line>
error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(8):
'__UTC_YEAR__' already defined as constant at <command-line>
error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(11):
'__UTC_YEAR__' already defined at <command-line>
error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(12):
'__UTC_YEAR__' already defined at <command-line>
error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(16):
Built-in symbol '__UTC_YEAR__' cannot be purged Built-in symbol '__UTC_YEAR__' cannot be purged
error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(17): error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(6):
Built-in symbol '__UTC_YEAR__' cannot be purged Built-in symbol '__UTC_YEAR__' cannot be purged
error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(20): error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(9):
'__UTC_YEAR__' already defined at <command-line> '__UTC_YEAR__' already defined at <command-line>
error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(21): error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(10):
'__UTC_YEAR__' already defined at <command-line> '__UTC_YEAR__' already defined at <command-line>
error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(24): error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(13):
'__UTC_YEAR__' already defined as constant at <command-line> '__UTC_YEAR__' already defined as constant at <command-line>
error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(25): error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(14):
'__UTC_YEAR__' already defined as constant at <command-line> '__UTC_YEAR__' already defined as constant at <command-line>
error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(28): error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(17):
'__UTC_YEAR__' already defined at <command-line> '__UTC_YEAR__' already defined at <command-line>
error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(29): error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(18):
'__UTC_YEAR__' already defined at <command-line> '__UTC_YEAR__' already defined at <command-line>
error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(32): error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(21):
'__UTC_YEAR__' already defined as constant at <command-line> '__UTC_YEAR__' already defined as constant at <command-line>
error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(33): error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(22):
'__UTC_YEAR__' already defined as constant at <command-line> '__UTC_YEAR__' already defined as constant at <command-line>
error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(36): error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(25):
'__UTC_YEAR__' already defined as non-EQUS at <command-line> '__UTC_YEAR__' already defined as non-EQUS at <command-line>
error: builtin-overwrite.asm(43) -> builtin-overwrite.asm::tickle(37): error: builtin-overwrite.asm(32) -> builtin-overwrite.asm::tickle(26):
'__UTC_YEAR__' already defined as non-EQUS at <command-line> '__UTC_YEAR__' already defined as non-EQUS at <command-line>
error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(16): error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(5):
Built-in symbol '__ISO_8601_UTC__' cannot be purged Built-in symbol '__ISO_8601_UTC__' cannot be purged
error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(17): error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(6):
Built-in symbol '__ISO_8601_UTC__' cannot be purged Built-in symbol '__ISO_8601_UTC__' cannot be purged
error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(20): error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(9):
'__ISO_8601_UTC__' already defined at <command-line> '__ISO_8601_UTC__' already defined at <command-line>
error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(21): error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(10):
'__ISO_8601_UTC__' already defined at <command-line> '__ISO_8601_UTC__' already defined at <command-line>
error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(24): error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(13):
'__ISO_8601_UTC__' already defined as constant at <command-line> '__ISO_8601_UTC__' already defined as constant at <command-line>
error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(25): error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(14):
'__ISO_8601_UTC__' already defined as constant at <command-line> '__ISO_8601_UTC__' already defined as constant at <command-line>
error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(28): error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(17):
'__ISO_8601_UTC__' already defined at <command-line> '__ISO_8601_UTC__' already defined at <command-line>
error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(29): error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(18):
'__ISO_8601_UTC__' already defined at <command-line> '__ISO_8601_UTC__' already defined at <command-line>
error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(32): error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(21):
'__ISO_8601_UTC__' already defined as constant at <command-line> '__ISO_8601_UTC__' already defined as constant at <command-line>
error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(33): error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(22):
'__ISO_8601_UTC__' already defined as constant at <command-line> '__ISO_8601_UTC__' already defined as constant at <command-line>
error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(36): error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(25):
Built-in symbol '__ISO_8601_UTC__' cannot be redefined Built-in symbol '__ISO_8601_UTC__' cannot be redefined
error: builtin-overwrite.asm(44) -> builtin-overwrite.asm::tickle(37): error: builtin-overwrite.asm(33) -> builtin-overwrite.asm::tickle(26):
Built-in symbol '__ISO_8601_UTC__' cannot be redefined Built-in symbol '__ISO_8601_UTC__' cannot be redefined
error: Assembly aborted (28 errors)! error: Assembly aborted (24 errors)!

View File

@@ -4,8 +4,6 @@ $7C5
$7C5 $7C5
$7C5 $7C5
$7C5 $7C5
$7C5
$7C5
1989-04-21T12:34:56Z 1989-04-21T12:34:56Z
1989-04-21T12:34:56Z 1989-04-21T12:34:56Z
1989-04-21T12:34:56Z 1989-04-21T12:34:56Z

View File

@@ -7,7 +7,7 @@
SECTION "test", ROM0 SECTION "test", ROM0
S EQUS "XBold<NULL>ABC" DEF S EQUS "XBold<NULL>ABC"
assert CHARLEN("{S}") == 6 assert CHARLEN("{S}") == 6
println CHARSUB("{S}", 2) println CHARSUB("{S}", 2)

View File

@@ -30,8 +30,8 @@ endm
try "def ", q try "def ", q
try "redef ", r try "redef ", r
_RS += 100 def _RS += 100
println _RS println _RS
UnDeFiNeD ^= 300 def UnDeFiNeD ^= 300
println UnDeFiNeD println UnDeFiNeD

View File

@@ -1,3 +1,25 @@
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(36):
Expected constant expression: 'UnDeFiNeD' is not constant at assembly time Expected constant expression: 'UnDeFiNeD' is not constant at assembly time
error: Assembly aborted (1 error)! error: Assembly aborted (1 error)!

View File

@@ -28,3 +28,22 @@ redef string equs "there"
redef constant equ 6*9 redef constant equ 6*9
println constant 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

View File

@@ -1,3 +1,35 @@
error: def.asm(23): error: def.asm(23):
'constant' already defined at def.asm(10) '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)! error: Assembly aborted (1 error)!

View File

@@ -1,8 +1,8 @@
IF 1 IF 1
X = 0 DEF X = 0
INCLUDE "endc-eof-newline.inc" INCLUDE "endc-eof-newline.inc"
INCLUDE "endc-eof-newline-else.inc" INCLUDE "endc-eof-newline-else.inc"
X = 1 DEF X = 1
INCLUDE "endc-eof-newline.inc" INCLUDE "endc-eof-newline.inc"
INCLUDE "endc-eof-newline-else.inc" INCLUDE "endc-eof-newline-else.inc"
ENDC ENDC

View File

@@ -1,4 +1,4 @@
charmap "A", 1 charmap "A", 1
SECTION "sec", ROM0[0] SECTION "sec", ROM0[0]
_A_ EQU "A" DEF _A_ EQU "A"
db _A_ db _A_

View File

@@ -1,3 +1,3 @@
DEFINE equs "MACRO mac\nPRINTLN \"Hello :D\"\nENDM" def DEFINE equs "MACRO mac\nPRINTLN \"Hello :D\"\nENDM"
DEFINE DEFINE
mac mac

View File

@@ -1,4 +1,5 @@
X1 equs "Y1 equs \"\\\"Success!\\\\n\\\"\"" ; the nested EQUS can't use DEF because Y1 would not be expanded
Y1 equs "Z1" def X1 equs "Y1 equs \"\\\"Success!\\\\n\\\"\""
def Y1 equs "Z1"
X1 X1
PRINT Z1 PRINT Z1

View File

@@ -0,0 +1,3 @@
warning: equs-nest.asm(4): [-Wobsolete]
`Z1 EQUS` is deprecated; use `DEF Z1 EQUS`
while expanding symbol "X1"

View File

@@ -1,4 +1,4 @@
ACT equs "WARN \"First\"\nWARN \"Second\"" def ACT equs "WARN \"First\"\nWARN \"Second\""
ACT ACT
WARN "Third" WARN "Third"

View File

@@ -1,2 +1,2 @@
BYE equs "PURGE BYE\nWARN \"Crash?\"\n \n" def BYE equs "PURGE BYE\nWARN \"Crash?\"\n \n"
BYE BYE

View File

@@ -1,2 +1,2 @@
recurse EQUS "recurse" DEF recurse EQUS "recurse"
recurse recurse

View File

@@ -1,6 +1,6 @@
MACRO test MACRO test
v equs "X" def v equs "X"
X equs "" ; should not be expanded def X equs "" ; should not be expanded
\1 \1
ENDM ENDM
test v 0 test v 0

View File

@@ -1,4 +1,4 @@
CONSTANT equ 42 def CONSTANT equ 42
PRINTLN $ff00 + CONSTANT PRINTLN $ff00 + CONSTANT
SECTION "Overreading much?", ROM0[0] SECTION "Overreading much?", ROM0[0]

View File

@@ -1,22 +1,22 @@
f1 = 3.1 def f1 = 3.1
f2 = 5.2 def f2 = 5.2
pm = MUL(f1, f2) def pm = MUL(f1, f2)
pr = 16.12 def pr = 16.12
println "`3.1`: {9.6f:f1} -> ${08x:f1}" println "`3.1`: {9.6f:f1} -> ${08x:f1}"
println "`5.2`: {9.6f:f2} -> ${08x:f2}" println "`5.2`: {9.6f:f2} -> ${08x:f2}"
println "`MUL`: {9.6f:pm} -> ${08x:pm}" println "`MUL`: {9.6f:pm} -> ${08x:pm}"
println "`16.12`: {9.6f:pr} -> ${08x:pr}" println "`16.12`: {9.6f:pr} -> ${08x:pr}"
fl = 6.283185 def fl = 6.283185
println "`6.283185`: {.6f:fl} -> ${08x:fl}" println "`6.283185`: {.6f:fl} -> ${08x:fl}"
fr = MUL(20.0, 0.32) def fr = MUL(20.0, 0.32)
println "32% of 20 = {f:fr} (~{.2f:fr}) (~~{.0f:fr})" println "32% of 20 = {f:fr} (~{.2f:fr}) (~~{.0f:fr})"
q8 = 1.25q8 def q8 = 1.25q8
q16 = 1.25Q16 def q16 = 1.25Q16
q24 = 1.25q.24 def q24 = 1.25q.24
println "Q8 ${x:q8} Q16 ${x:q16} Q24 ${x:q24}" println "Q8 ${x:q8} Q16 ${x:q16} Q24 ${x:q24}"
qerr = 1.25q32 def qerr = 1.25q32
println qerr println qerr

View File

@@ -26,7 +26,7 @@ endr
for v, 10, -1, -1 for v, 10, -1, -1
print "{d:v} " print "{d:v} "
v = 42 def v = 42
endr endr
println "-> {d:v}" println "-> {d:v}"
@@ -36,7 +36,7 @@ purge q
endr endr
println "-> {d:q}" println "-> {d:q}"
s EQUS "x" DEF s EQUS "x"
for {s}, 3, 30, 3 for {s}, 3, 30, 3
print "{d:x} " print "{d:x} "
endr endr
@@ -46,7 +46,7 @@ for v, 10
println "{d:v}" println "{d:v}"
if v == 3 if v == 3
purge v purge v
v equ 42 ; causes a fatal error def v equ 42 ; causes a fatal error
endc endc
endr endr
println "-> {d:v}" println "-> {d:v}"

View File

@@ -1,6 +1,6 @@
num equ 42 def num equ 42
fix equ 123.0 def fix equ 123.0
str equs "hello" def str equs "hello"
println "{#0260x:num}" println "{#0260x:num}"
println "{#-260x:num}" println "{#-260x:num}"

View File

@@ -1,4 +1,4 @@
; It seems that \1 was the easiest way to notice the memory corruption that ; It seems that \1 was the easiest way to notice the memory corruption that
; resulted from this overflow ; resulted from this overflow
x = 0 def x = 0
{.99999999f:x}\1 {.99999999f:x}\1

View File

@@ -1,2 +1,2 @@
recurse EQUS "\{recurse\}" DEF recurse EQUS "\{recurse\}"
{recurse} {recurse}

View File

@@ -1,13 +1,13 @@
SECTION "Test", ROM0 SECTION "Test", ROM0
NAME equs "ITEM" def NAME equs "ITEM"
FMT equs "d" def FMT equs "d"
ZERO_NUM equ 0 def ZERO_NUM equ 0
ZERO_STR equs "0" def ZERO_STR equs "0"
; Defines INDEX as 100 ; Defines INDEX as 100
INDEX = 1{ZERO_STR}{{FMT}:ZERO_NUM} def INDEX = 1{ZERO_STR}{{FMT}:ZERO_NUM}
; Defines ITEM_100 as "\"hundredth\"" ; Defines ITEM_100 as "\"hundredth\""
{NAME}_{d:INDEX} equs "\"hundredth\"" def {NAME}_{d:INDEX} equs "\"hundredth\""
; Prints "ITEM_100 is hundredth" ; Prints "ITEM_100 is hundredth"
PRINTLN STRCAT("{NAME}_{d:INDEX}", " is ", {NAME}_{d:INDEX}) PRINTLN STRCAT("{NAME}_{d:INDEX}", " is ", {NAME}_{d:INDEX})
; Purges ITEM_100 ; Purges ITEM_100

View File

@@ -11,13 +11,13 @@
; 10: invalid bytes 0xE6 0xF0 ; 10: invalid bytes 0xE6 0xF0
; 11: invalid byte 0xA2 ; 11: invalid byte 0xA2
; 12: U+0021 ! ; 12: U+0021 !
invalid EQUS "aäb漢,a<><61>b<EFBFBD><62><EFBFBD>!" DEF invalid EQUS "aäb漢,a<><61>b<EFBFBD><62><EFBFBD>!"
n = STRLEN("{invalid}") DEF n = STRLEN("{invalid}")
copy EQUS STRSUB("{invalid}", 1) DEF copy EQUS STRSUB("{invalid}", 1)
println "\"{invalid}\" == \"{copy}\" ({d:n})" println "\"{invalid}\" == \"{copy}\" ({d:n})"
mid1 EQUS STRSUB("{invalid}", 5, 2) DEF mid1 EQUS STRSUB("{invalid}", 5, 2)
mid2 EQUS STRSUB("{invalid}", 9, 1) DEF mid2 EQUS STRSUB("{invalid}", 9, 1)
println "\"{mid2}{mid1}\"" println "\"{mid2}{mid1}\""

View File

@@ -1,10 +1,10 @@
TEST_NUM = 0 DEF TEST_NUM = 0
MACRO test_expr MACRO test_expr
TEST_NUM = TEST_NUM + 1 DEF TEST_NUM = TEST_NUM + 1
IS_CONST = ISCONST(\1) DEF IS_CONST = ISCONST(\1)
PRINTLN "Test #{d:TEST_NUM}: ISCONST reports {IS_CONST}" PRINTLN "Test #{d:TEST_NUM}: ISCONST reports {IS_CONST}"
IF (\1) || 1 ; Only test if the expression can be evaluated IF (\1) || 1 ; Only test if the expression can be evaluated
WARN "Test #{d:TEST_NUM}: Compile-time constant" WARN "Test #{d:TEST_NUM}: Compile-time constant"

View File

@@ -2,5 +2,5 @@ SECTION "Test", ROM0
Label: Label:
jr Label jr Label
DIFF equ Label - @ def DIFF equ Label - @
PRINTLN "{DIFF}" PRINTLN "{DIFF}"

View File

@@ -1,12 +1,12 @@
MACRO m1 MACRO m1
x\1 def x\1
ENDM ENDM
S EQUS "y" DEF S EQUS "y"
S2 EQUS "yy" DEF S2 EQUS "yy"
MACRO m2 MACRO m2
S\1 S\1 ; can't use DEF, so this will EQUS expand
ENDM ENDM
m1 = 5 m1 = 5
@@ -21,12 +21,12 @@ ENDM
MACRO test_char MACRO test_char
VAR_DEF equs "sizeof_\1something = 0" DEF VAR_DEF equs "DEF sizeof_\1something = 0"
VAR_DEF VAR_DEF
sizeof_\1something = 1 DEF sizeof_\1something = 1
PURGE VAR_DEF PURGE VAR_DEF
VAR_PRINT equs "println \"sizeof_\1something equals {sizeof_\1something}\"" DEF VAR_PRINT equs "println \"sizeof_\1something equals {sizeof_\1something}\""
VAR_PRINT VAR_PRINT
PURGE VAR_PRINT PURGE VAR_PRINT
ENDM ENDM

View File

@@ -1,21 +1,21 @@
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): error: label-macro-arg.asm(38) -> label-macro-arg.asm::test_char(25):
syntax error, unexpected = syntax error, unexpected local identifier, expecting identifier
while expanding symbol "VAR_DEF" while expanding symbol "VAR_DEF"
error: label-macro-arg.asm(38) -> label-macro-arg.asm::test_char(26): error: label-macro-arg.asm(38) -> label-macro-arg.asm::test_char(26):
syntax error, unexpected = syntax error, unexpected local identifier, expecting identifier
error: label-macro-arg.asm(38) -> label-macro-arg.asm::test_char(29): error: label-macro-arg.asm(38) -> label-macro-arg.asm::test_char(29):
Interpolated symbol "sizeof_.something" does not exist Interpolated symbol "sizeof_.something" does not exist
error: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(25): error: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(25):
Label "sizeof_" created outside of a SECTION syntax error, unexpected label, expecting identifier
while expanding symbol "VAR_DEF" while expanding symbol "VAR_DEF"
error: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(25):
Macro "something" not defined
error: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(26): error: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(26):
'sizeof_' already defined at label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(25) syntax error, unexpected label, expecting identifier
error: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(26):
Macro "something" not defined
error: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(29): error: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(29):
Invalid format spec 'sizeof_' Invalid format spec 'sizeof_'
error: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(29): error: label-macro-arg.asm(39) -> label-macro-arg.asm::test_char(29):
Interpolated symbol "something" does not exist Interpolated symbol "something" does not exist
error: Assembly aborted (9 errors)! error: Assembly aborted (7 errors)!

View File

@@ -1,3 +1,7 @@
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): error: label-macro-arg.asm(38) -> label-macro-arg.asm::test_char(25):
Local label 'sizeof_.something' in main scope Local label 'sizeof_.something' in main scope
while expanding symbol "VAR_DEF" while expanding symbol "VAR_DEF"

View File

@@ -1,18 +1,18 @@
SECTION "sec", ROM0 SECTION "sec", ROM0
X0 EQUS "0" DEF X0 EQUS "0"
MACRO m MACRO m
\1 EQUS STRCAT("{X\2}", "+1") DEF \1 EQUS STRCAT("{X\2}", "+1")
ENDM ENDM
FOR n, $7E FOR n, $7E
n1 = n + 1 DEF n1 = n + 1
m X{X:n1}, {X:n} m X{X:n1}, {X:n}
ENDR ENDR
; string of 127 zeros separated by plus signs ; string of 127 zeros separated by plus signs
X EQUS "{X7E}" DEF X EQUS "{X7E}"
db x+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+\ db x+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+\
X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+\ X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+X+\

View File

@@ -17,8 +17,8 @@ MACRO person
ENDM ENDM
MACRO object MACRO object
x = \1 DEF x = \1
y = \2 DEF y = \2
shift 2 shift 2
person y, x, \# person y, x, \#
ENDM ENDM
@@ -30,7 +30,7 @@ MACRO echo
println "\#" println "\#"
ENDM ENDM
R EQUS "S" DEF R EQUS "S"
echo P echo P
echo Q,R, {R}, T echo Q,R, {R}, T

View File

@@ -16,12 +16,12 @@ MACRO iprint
PRINTLN "{\1}" PRINTLN "{\1}"
ENDM ENDM
s EQUS "hello" DEF s EQUS "hello"
iprint s iprint s
MACRO symprint MACRO symprint
PRINTLN {\1} PRINTLN {\1}
ENDM ENDM
hello EQUS "\"goodbye\"" DEF hello EQUS "\"goodbye\""
symprint s symprint s

View File

@@ -1,8 +1,8 @@
MACRO addargs MACRO addargs
sum = 0 def sum = 0
rept _NARG rept _NARG
sum = sum + \1 def sum = sum + \1
shift shift
endr endr
dw sum & $FFFF dw sum & $FFFF
dw (sum >> 16) & $FFFF dw (sum >> 16) & $FFFF

View File

@@ -1,12 +1,12 @@
X equ 0 def X equ 0
MACRO test MACRO test
; Test RGBASM ; Test RGBASM
v equs "X +" def v equs "X +"
static_assert \# static_assert \#
purge v purge v
; Test RGBLINK ; Test RGBLINK
v equs "Y +" def v equs "Y +"
assert \# assert \#
purge v purge v
ENDM ENDM

View File

@@ -1,4 +1,4 @@
m = $8000_0000 def m = $8000_0000
assert m == 1 << 31 assert m == 1 << 31
assert m == -(1 << 31) assert m == -(1 << 31)
assert m == (-2)**31 assert m == (-2)**31

View File

@@ -1,4 +1,4 @@
S EQUS "Hello" DEF S EQUS "Hello"
PRINT "\"\"\"\n" PRINT "\"\"\"\n"
@@ -24,11 +24,11 @@ ENDM
printarg """multi-line printarg """multi-line
string argument""" string argument"""
EMPTY1 EQUS "" DEF EMPTY1 EQUS ""
EMPTY2 EQUS "\ ; comment DEF EMPTY2 EQUS "\ ; comment
" "
EMPTY3 EQUS """""" DEF EMPTY3 EQUS """"""
EMPTY4 EQUS """\ ; comment DEF EMPTY4 EQUS """\ ; comment
""" """
PRINTLN STRCAT("(", "{EMPTY1}", "{EMPTY2}", "{EMPTY3}", "{EMPTY4}", ")") PRINTLN STRCAT("(", "{EMPTY1}", "{EMPTY2}", "{EMPTY3}", "{EMPTY4}", ")")

View File

@@ -26,8 +26,8 @@ MACRO pop_
ENDM ENDM
MACRO print_mapped MACRO print_mapped
x = \1 def x = \1
println "{x}" println "{x}"
ENDM ENDM
println "main charmap" println "main charmap"

View File

@@ -1,5 +1,5 @@
STRING equs "OK" def STRING equs "OK"
WRAPPER equs "TRIN" def WRAPPER equs "TRIN"
PRINTLN "{S{WRAPPER}G}" PRINTLN "{S{WRAPPER}G}"
PRINTLN "{S{WRAPPER}G" PRINTLN "{S{WRAPPER}G"

View File

@@ -1,4 +1,4 @@
n=1 def n=1
rept 10 rept 10
print "A" print "A"
for x, 10 for x, 10
@@ -12,6 +12,6 @@ rept 10
break break
endc endc
println "Z" println "Z"
n=n+1 def n=n+1
endr endr
println "\nn={d:n} x={d:x}" println "\nn={d:n} x={d:x}"

View File

@@ -1,5 +1,5 @@
MACRO outer_ok MACRO outer_ok
definition equs "MACRO inner_ok\nPRINTLN \"Hello!\"\nENDM" def definition equs "MACRO inner_ok\nPRINTLN \"Hello!\"\nENDM"
definition definition
PURGE definition PURGE definition
ENDM ENDM
@@ -9,7 +9,7 @@ ENDM
MACRO outer_arg MACRO outer_arg
definition equs "MACRO inner_arg\nPRINTLN \"outer: \1\\ninner: \\1\"\nENDM" def definition equs "MACRO inner_arg\nPRINTLN \"outer: \1\\ninner: \\1\"\nENDM"
definition definition
PURGE definition PURGE definition
ENDM ENDM

View File

@@ -4,38 +4,38 @@ MACRO print_x
println x println x
ENDM ENDM
x = 2147483647 def x = 2147483647
x = x + 1 def x = x + 1
dl 2147483647+1 dl 2147483647+1
print_x print_x
x = -2147483648 def x = -2147483648
x = x - 1 def x = x - 1
dl -2147483648-1 dl -2147483648-1
print_x print_x
x = -2147483648 def x = -2147483648
x = x * -1 def x = x * -1
dl -2147483648 * -1 dl -2147483648 * -1
print_x print_x
x = -2147483648 def x = -2147483648
x = x / -1 def x = x / -1
dl -2147483648 / -1 dl -2147483648 / -1
print_x print_x
x = -2147483648 def x = -2147483648
x = x % -1 def x = x % -1
dl -2147483648 % -1 dl -2147483648 % -1
print_x print_x
x = -1 def x = -1
x = x << 1 def x = x << 1
dl -1 << 1 dl -1 << 1
print_x print_x
x = 4294967295 def x = 4294967295
x = 4294967296 def x = 4294967296
x = `33333333 def x = `33333333
x = `333333333 def x = `333333333

View File

@@ -1,11 +1,11 @@
SECTION "Fixed bank", ROMX,BANK[42] SECTION "Fixed bank", ROMX,BANK[42]
ldh a, [BANK(@) * 256] ; This should be complained about at assembly time ldh a, [BANK(@) * 256] ; This should be complained about at assembly time
X = BANK(@) DEF X = BANK(@)
SECTION "Something else", ROMX SECTION "Something else", ROMX
Y = BANK("Fixed bank") DEF Y = BANK("Fixed bank")
PRINTLN "@: {X}\nStr: {Y}" PRINTLN "@: {X}\nStr: {Y}"
ERR = BANK(@) DEF ERR = BANK(@)

View File

@@ -12,8 +12,8 @@ MACRO printlit
endr endr
ENDM ENDM
NUM EQU 42 DEF NUM EQU 42
STR EQUS "str\"ing" DEF STR EQUS "str\"ing"
printargs NUM printargs NUM
printargs "{d:NUM}" printargs "{d:NUM}"

View File

@@ -4,7 +4,7 @@ REDEF n EQU 1
PRINTLN n PRINTLN n
MACRO list MACRO list
LIST_NAME EQUS "\1" DEF LIST_NAME EQUS "\1"
DEF LENGTH_{LIST_NAME} EQU 0 DEF LENGTH_{LIST_NAME} EQU 0
ENDM ENDM
@@ -19,5 +19,5 @@ ENDM
item 9 item 9
println LENGTH_SQUARES, SQUARES_1, SQUARES_2, SQUARES_3 println LENGTH_SQUARES, SQUARES_1, SQUARES_2, SQUARES_3
N EQUS "X" DEF N EQUS "X"
REDEF N EQU 42 REDEF N EQU 42

View File

@@ -1,10 +1,10 @@
s EQUS "Hello, " DEF s EQUS "Hello, "
REDEF s EQUS "{s}world!" REDEF s EQUS "{s}world!"
; prints "Hello, world!" ; prints "Hello, world!"
PRINTLN "{s}" PRINTLN "{s}"
MACRO list MACRO list
LIST_NAME EQUS "\1" DEF LIST_NAME EQUS "\1"
REDEF {LIST_NAME} EQUS "[" REDEF {LIST_NAME} EQUS "["
REPT _NARG - 1 REPT _NARG - 1
REDEF {LIST_NAME} EQUS "{{LIST_NAME}}\2;" REDEF {LIST_NAME} EQUS "{{LIST_NAME}}\2;"
@@ -19,5 +19,5 @@ ENDM
list FOO, 1, A, 2, B list FOO, 1, A, 2, B
PRINTLN "{FOO}" PRINTLN "{FOO}"
N EQU 42 DEF N EQU 42
REDEF N EQUS "X" REDEF N EQUS "X"

View File

@@ -2,10 +2,10 @@
SECTION "Bad!", ROM0 SECTION "Bad!", ROM0
db W db W
W equ 0 ; OK def W equ 0 ; OK
db X db X
X equs "0" ; Not OK def X equs "0" ; Not OK
db Y db Y
macro Y ; Not ok macro Y ; Not ok

View File

@@ -1,4 +1,4 @@
SECTION "Test", ROM0[0] SECTION "Test", ROM0[0]
db CONSTANT db CONSTANT
CONSTANT equ 42 def CONSTANT equ 42

View File

@@ -1,7 +1,7 @@
a1 rb 1 def a1 rb 1
a2 rw 1 def a2 rw 1
a3 rl 1 def a3 rl 1
PRINTLN "a1 = ", a1 PRINTLN "a1 = ", a1
PRINTLN "a2 = ", a2 PRINTLN "a2 = ", a2
@@ -9,9 +9,9 @@ PRINTLN "a3 = ", a3
PRINTLN "_RS = ", _RS PRINTLN "_RS = ", _RS
b1 rb 1 def b1 rb 1
b2 rw 1 def b2 rw 1
b3 rl 1 def b3 rl 1
PRINTLN "b1 = ", b1 PRINTLN "b1 = ", b1
PRINTLN "b2 = ", b2 PRINTLN "b2 = ", b2
@@ -20,9 +20,9 @@ PRINTLN "_RS = ", _RS
rsset 42 rsset 42
c1 rb 1 def c1 rb 1
c2 rw 1 def c2 rw 1
c3 rl 1 def c3 rl 1
PRINTLN "c1 = ", c1 PRINTLN "c1 = ", c1
PRINTLN "c2 = ", c2 PRINTLN "c2 = ", c2
@@ -31,13 +31,11 @@ PRINTLN "_RS = ", _RS
rsreset rsreset
d1 rb 1 def d1 rb 1
d2 rw 1 def d2 rw 1
d3 rl 1 def d3 rl 1
PRINTLN "d1 = ", d1 PRINTLN "d1 = ", d1
PRINTLN "d2 = ", d2 PRINTLN "d2 = ", d2
PRINTLN "d3 = ", d3 PRINTLN "d3 = ", d3
PRINTLN "_RS = ", _RS PRINTLN "_RS = ", _RS

View File

@@ -1,33 +1,33 @@
SECTION "sect", ROMX[$4567], BANK[$23] SECTION "sect", ROMX[$4567], BANK[$23]
ds 42 ds 42
W = BANK("sect") DEF W = BANK("sect")
X = SIZEOF("sect") ; unknown DEF X = SIZEOF("sect") ; unknown
Y = STARTOF("sect") DEF Y = STARTOF("sect")
println "sect1: {W} {X} {Y}" println "sect1: {W} {X} {Y}"
SECTION "sect2", ROMX SECTION "sect2", ROMX
W = BANK("sect") DEF W = BANK("sect")
X = SIZEOF("sect") DEF X = SIZEOF("sect")
Y = STARTOF("sect") DEF Y = STARTOF("sect")
println "sect1: {W} {X} {Y}" println "sect1: {W} {X} {Y}"
PUSHS PUSHS
SECTION FRAGMENT "sect3", ROMX[$4567], BANK[$12] SECTION FRAGMENT "sect3", ROMX[$4567], BANK[$12]
W = BANK("sect2") ; unknown DEF W = BANK("sect2") ; unknown
X = SIZEOF("sect2") ; unknown DEF X = SIZEOF("sect2") ; unknown
Y = STARTOF("sect2") ; unknown DEF Y = STARTOF("sect2") ; unknown
println "sect2: {W} {X} {Y}" println "sect2: {W} {X} {Y}"
POPS POPS
W = BANK("sect3") DEF W = BANK("sect3")
X = SIZEOF("sect3") ; unknown DEF X = SIZEOF("sect3") ; unknown
Y = STARTOF("sect3") DEF Y = STARTOF("sect3")
println "sect3: {W} {X} {Y}" println "sect3: {W} {X} {Y}"

View File

@@ -17,11 +17,11 @@ SECTION UNION "test", WRAM0,ALIGN[9]
MACRO check_label MACRO check_label
EXPECTED equ \2 def EXPECTED equ \2
IF \1 == EXPECTED IF \1 == EXPECTED
RESULT equs "OK!" def RESULT equs "OK!"
ELSE ELSE
RESULT equs "expected {EXPECTED}" def RESULT equs "expected {EXPECTED}"
ENDC ENDC
PURGE EXPECTED PURGE EXPECTED

View File

@@ -1,6 +1,6 @@
MACRO reverse MACRO reverse
for i, _NARG for i, _NARG
i = _NARG - i - 1 def i = _NARG - i - 1
shift i shift i
println \1 println \1
shift -i shift -i

View File

@@ -1,14 +1,14 @@
VAL EQUS STRFMT("Hello %s! I am %d years old today!", "world", $f) DEF VAL EQUS STRFMT("Hello %s! I am %d years old today!", "world", $f)
PRINTLN "{VAL}" PRINTLN "{VAL}"
N = -42 DEF N = -42
PRINTLN STRFMT("signed %010d == unsigned %010u", N, N) PRINTLN STRFMT("signed %010d == unsigned %010u", N, N)
N = 112 DEF N = 112
FMT EQUS "X" DEF FMT EQUS "X"
PRINTLN STRFMT("\tdb %#03{s:FMT} %% 26\t; %#03{FMT}", N, N % 26) PRINTLN STRFMT("\tdb %#03{s:FMT} %% 26\t; %#03{FMT}", N, N % 26)
TEMPLATE EQUS "\"%s are %s\\n\"" DEF TEMPLATE EQUS "\"%s are %s\\n\""
PRINT STRFMT(TEMPLATE, "roses", "red") PRINT STRFMT(TEMPLATE, "roses", "red")
PRINT STRFMT(TEMPLATE, "violets", "blue") PRINT STRFMT(TEMPLATE, "violets", "blue")
PRINT STRFMT(TEMPLATE, "void", 0, "extra") PRINT STRFMT(TEMPLATE, "void", 0, "extra")
@@ -16,7 +16,7 @@ PRINT STRFMT(TEMPLATE, "void", 0, "extra")
PRINTLN STRCAT(STRFMT(STRFMT("%%%s.%d%s", "", 9, "f"), 3.14159), \ PRINTLN STRCAT(STRFMT(STRFMT("%%%s.%d%s", "", 9, "f"), 3.14159), \
STRFMT(" ~ %s", STRFMT("%s%x", "thr", 238))) STRFMT(" ~ %s", STRFMT("%s%x", "thr", 238)))
N = 1.23456 DEF N = 1.23456
PRINTLN STRFMT("%.f -> %.3f -> %f", N, N, N) PRINTLN STRFMT("%.f -> %.3f -> %f", N, N, N)
PRINTLN STRFMT("%d eol %", 1) PRINTLN STRFMT("%d eol %", 1)

View File

@@ -1,8 +1,8 @@
n equ 300 def n equ 300
m equ -42 def m equ -42
f equ -123.0456 def f equ -123.0456
pi equ 3.14159 def pi equ 3.14159
s equs "hello" def s equs "hello"
println "<{ -6d:n}> <{+06u:n}> <{5x:n}> <{#16b:n}>" println "<{ -6d:n}> <{+06u:n}> <{5x:n}> <{#16b:n}>"
println "<{u:m}> <{+3d:m}> <{#016o:m}>" println "<{u:m}> <{+3d:m}> <{#016o:m}>"

View File

@@ -1,4 +1,4 @@
foo equs strupr("xii") def foo equs strupr("xii")
bar equs strlwr("LOL") def bar equs strlwr("LOL")
println "foo={foo} bar={bar}" println "foo={foo} bar={bar}"

View File

@@ -1,2 +1,2 @@
x\0 = 10 def x\0 = 10
println x println x

View File

@@ -1,14 +1,14 @@
V = 0 def V = 0
V = 1 def V = 1
PRINTLN "V={V}" PRINTLN "V={V}"
W equ 1 def W equ 1
W = 0 def W = 0
rsset 1 rsset 1
X rb 0 def X rb 0
X = 0 def X = 0
SECTION "Test", ROM0[1] SECTION "Test", ROM0[1]
Y: Y:
Y = 0 def Y = 0

View File

@@ -1,4 +1,4 @@
newline equs "\n" def newline equs "\n"
def x = 1 newline def y = 2 def x = 1 newline def y = 2
println "x={d:x}, y={d:y}" println "x={d:x}, y={d:y}"

View File

@@ -1,4 +1,4 @@
warn_unique EQUS "WARN \"\\@!\"" DEF warn_unique EQUS "WARN \"\\@!\""
macro m macro m
warn_unique warn_unique

View File

@@ -9,6 +9,6 @@ ENDM
between 0, __UTC_MINUTE__, 59 between 0, __UTC_MINUTE__, 59
between 0, __UTC_SECOND__, 60 ; leap seconds! between 0, __UTC_SECOND__, 60 ; leap seconds!
UTC_TIME EQUS STRCAT("{04d:__UTC_YEAR__}-{02d:__UTC_MONTH__}-{02d:__UTC_DAY__}T", \ DEF UTC_TIME EQUS STRCAT("{04d:__UTC_YEAR__}-{02d:__UTC_MONTH__}-{02d:__UTC_DAY__}T", \
"{02d:__UTC_HOUR__}:{02d:__UTC_MINUTE__}:{02d:__UTC_SECOND__}Z") "{02d:__UTC_HOUR__}:{02d:__UTC_MINUTE__}:{02d:__UTC_SECOND__}Z")
assert !STRCMP("{UTC_TIME}", __ISO_8601_UTC__) assert !STRCMP("{UTC_TIME}", __ISO_8601_UTC__)

View File

@@ -1,5 +1,5 @@
FOO_F EQU 5 DEF FOO_F EQU 5
BAR_F EQU 7 DEF BAR_F EQU 7
SECTION "RAM", WRAMX[$d500] SECTION "RAM", WRAMX[$d500]

View File

@@ -57,7 +57,7 @@ ENDM
; Bit Operations Instructions ; Bit Operations Instructions
MACRO bitop_u3_instruction_list MACRO bitop_u3_instruction_list
NBIT = 0 DEF NBIT = 0
REPT 8 REPT 8
\1 NBIT,a \1 NBIT,a
\1 NBIT,b \1 NBIT,b
@@ -67,7 +67,7 @@ NBIT = 0
\1 NBIT,h \1 NBIT,h
\1 NBIT,[hl] \1 NBIT,[hl]
\1 NBIT,l \1 NBIT,l
NBIT = NBIT + 1 DEF NBIT = NBIT + 1
ENDR ENDR
ENDM ENDM

View File

@@ -1,2 +1,2 @@
CONSTANT equ 0 def CONSTANT equ 0
EXPORT CONSTANT EXPORT CONSTANT

View File

@@ -1,7 +1,7 @@
IF !DEF(SECOND) IF !DEF(SECOND)
ATTRS equs ",ALIGN[2]" def ATTRS equs ",ALIGN[2]"
ELSE ELSE
ATTRS equs "[$CAFE]" def ATTRS equs "[$CAFE]"
ENDC ENDC
SECTION UNION "conflicting alignment", WRAM0 ATTRS SECTION UNION "conflicting alignment", WRAM0 ATTRS

View File

@@ -1,7 +1,7 @@
IF !DEF(SECOND) IF !DEF(SECOND)
ATTRS equs ",ALIGN[3,7]" def ATTRS equs ",ALIGN[3,7]"
ELSE ELSE
ATTRS equs ",ALIGN[4,14]" def ATTRS equs ",ALIGN[4,14]"
ENDC ENDC
SECTION UNION "conflicting alignment", WRAM0 ATTRS SECTION UNION "conflicting alignment", WRAM0 ATTRS

View File

@@ -1,10 +1,10 @@
IF !DEF(SECOND) IF !DEF(SECOND)
OFS = 42 def OFS = 42
ELSE ELSE
OFS = 69 def OFS = 69
ENDC ENDC
BASE = $C0DE def BASE = $C0DE
SECTION UNION "assertions in unions", WRAM0 SECTION UNION "assertions in unions", WRAM0
IF DEF(SECOND) IF DEF(SECOND)

View File

@@ -1,7 +1,7 @@
IF !DEF(SECOND) IF !DEF(SECOND)
TYPE equs "HRAM" def TYPE equs "HRAM"
ELSE ELSE
TYPE equs "WRAM0" def TYPE equs "WRAM0"
ENDC ENDC
SECTION UNION "conflicting types", TYPE SECTION UNION "conflicting types", TYPE

View File

@@ -1,5 +1,5 @@
IF !DEF(SECOND) IF !DEF(SECOND)
SECOND equs "4" def SECOND equs "4"
ENDC ENDC
SECTION UNION "conflicting banks", WRAMX, BANK[SECOND] SECTION UNION "conflicting banks", WRAMX, BANK[SECOND]

View File

@@ -1,7 +1,7 @@
IF !DEF(SECOND) IF !DEF(SECOND)
DATA equs "ds 4" def DATA equs "ds 4"
ELSE ELSE
DATA equs "db $aa, $bb, $cc, $dd" def DATA equs "db $aa, $bb, $cc, $dd"
ENDC ENDC
SECTION UNION "overlaid data", ROM0 SECTION UNION "overlaid data", ROM0

View File

@@ -1,7 +1,7 @@
IF !DEF(SECOND) IF !DEF(SECOND)
DATA = 1 def DATA = 1
ELSE ELSE
DATA = 2 def DATA = 2
ENDC ENDC
SECTION UNION "different data", ROM0 SECTION UNION "different data", ROM0

View File

@@ -1,7 +1,7 @@
IF !DEF(SECOND) IF !DEF(SECOND)
ATTRS equs ",ALIGN[3,7]" def ATTRS equs ",ALIGN[3,7]"
ELSE ELSE
ATTRS equs ",ALIGN[3,6]" def ATTRS equs ",ALIGN[3,6]"
ENDC ENDC
SECTION UNION "conflicting alignment", WRAM0 ATTRS SECTION UNION "conflicting alignment", WRAM0 ATTRS

View File

@@ -1,7 +1,7 @@
IF !DEF(SECOND) IF !DEF(SECOND)
SIZE = 69 def SIZE = 69
ELSE ELSE
SIZE = 420 def SIZE = 420
ENDC ENDC
SECTION UNION "different section sizes", ROM0 SECTION UNION "different section sizes", ROM0

View File

@@ -1,7 +1,7 @@
IF !DEF(SECOND) IF !DEF(SECOND)
INSTR equs "sbc a" def INSTR equs "sbc a"
ELSE ELSE
INSTR equs "db $9f" def INSTR equs "db $9f"
ENDC ENDC
SECTION UNION "different syntaxes", ROM0 SECTION UNION "different syntaxes", ROM0

View File

@@ -1,7 +1,7 @@
IF !DEF(SECOND) IF !DEF(SECOND)
ADDR = $BEEF def ADDR = $BEEF
ELSE ELSE
ADDR = $BABE def ADDR = $BABE
ENDC ENDC
SECTION UNION "conflicting address", SRAM[ADDR] SECTION UNION "conflicting address", SRAM[ADDR]

View File

@@ -1,7 +1,7 @@
IF !DEF(SECOND) IF !DEF(SECOND)
DATA equs "ds 1\ndb $aa" def DATA equs "ds 1\ndb $aa"
ELSE ELSE
DATA equs "db $bb\nds 1" def DATA equs "db $bb\nds 1"
ENDC ENDC
SECTION UNION "mutually-overlaid data", ROM0 SECTION UNION "mutually-overlaid data", ROM0

View File

@@ -177,7 +177,7 @@ for i in section-union/*.asm; do
fi fi
echo --- >> $outtemp echo --- >> $outtemp
# Ensure RGBASM also errors out # Ensure RGBASM also errors out
cat $i - $i <<<'SECOND equs "1"' | $RGBASM - 2>> $outtemp cat $i - $i <<<'def SECOND equs "1"' | $RGBASM - 2>> $outtemp
tryDiff ${i%.asm}.out $outtemp tryDiff ${i%.asm}.out $outtemp
rc=$(($? || $rc)) rc=$(($? || $rc))
done done