mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Implement compound assignment operators for mutable constants
Fixes #943
This commit is contained in:
40
test/asm/compound-assignment.asm
Normal file
40
test/asm/compound-assignment.asm
Normal file
@@ -0,0 +1,40 @@
|
||||
macro try
|
||||
println \1, "\2:"
|
||||
def prefix equs \1
|
||||
{prefix}\2 = 10
|
||||
println \2 ; 10
|
||||
{prefix}\2 += 5
|
||||
println \2 ; 15
|
||||
{prefix}\2 -= 1
|
||||
println \2 ; 14
|
||||
{prefix}\2 *= 2
|
||||
println \2 ; 28
|
||||
{prefix}\2 /= 4
|
||||
println \2 ; 7
|
||||
{prefix}\2 %= 3
|
||||
println \2 ; 1
|
||||
{prefix}\2 |= 11
|
||||
println \2 ; 11
|
||||
{prefix}\2 ^= 12
|
||||
println \2 ; 7
|
||||
{prefix}\2 &= 21
|
||||
println \2 ; 5
|
||||
{prefix}\2 <<= 2
|
||||
println \2 ; 20
|
||||
{prefix}\2 >>= 1
|
||||
println \2 ; 10
|
||||
purge prefix
|
||||
endm
|
||||
|
||||
try "", p
|
||||
try "def ", q
|
||||
try "redef ", r
|
||||
|
||||
_RS += 100
|
||||
println _RS
|
||||
|
||||
__LINE__ *= 200
|
||||
println __LINE__
|
||||
|
||||
UnDeFiNeD ^= 300
|
||||
println UnDeFiNeD
|
||||
5
test/asm/compound-assignment.err
Normal file
5
test/asm/compound-assignment.err
Normal file
@@ -0,0 +1,5 @@
|
||||
ERROR: compound-assignment.asm(36):
|
||||
'__LINE__' already defined as constant at <builtin>
|
||||
ERROR: compound-assignment.asm(39):
|
||||
Expected constant expression: 'UnDeFiNeD' is not constant at assembly time
|
||||
error: Assembly aborted (2 errors)!
|
||||
39
test/asm/compound-assignment.out
Normal file
39
test/asm/compound-assignment.out
Normal file
@@ -0,0 +1,39 @@
|
||||
p:
|
||||
$A
|
||||
$F
|
||||
$E
|
||||
$1C
|
||||
$7
|
||||
$1
|
||||
$B
|
||||
$7
|
||||
$5
|
||||
$14
|
||||
$A
|
||||
def q:
|
||||
$A
|
||||
$F
|
||||
$E
|
||||
$1C
|
||||
$7
|
||||
$1
|
||||
$B
|
||||
$7
|
||||
$5
|
||||
$14
|
||||
$A
|
||||
redef r:
|
||||
$A
|
||||
$F
|
||||
$E
|
||||
$1C
|
||||
$7
|
||||
$1
|
||||
$B
|
||||
$7
|
||||
$5
|
||||
$14
|
||||
$A
|
||||
$64
|
||||
$25
|
||||
$0
|
||||
Reference in New Issue
Block a user