mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
X && 0 and X & 0 are constant 0; X || 1 is constant 1 (#1399)
Fixes #977
This commit is contained in:
29
test/asm/const-zero.asm
Normal file
29
test/asm/const-zero.asm
Normal file
@@ -0,0 +1,29 @@
|
||||
MACRO test_and
|
||||
if DEF(foo) && foo == 42
|
||||
println "Life, the Universe, and Everything!"
|
||||
else
|
||||
println "What do you get if you multiply six by seven?"
|
||||
endc
|
||||
ENDM
|
||||
test_and
|
||||
DEF foo = 42
|
||||
test_and
|
||||
|
||||
|
||||
MACRO test_or
|
||||
if DEF(DEBUG) || @ == $4567
|
||||
println "Here we are!"
|
||||
else
|
||||
println "Where are we?"
|
||||
endc
|
||||
ENDM
|
||||
SECTION "Test OR", ROMX
|
||||
test_or ; Not constant
|
||||
DEF DEBUG EQU 1
|
||||
test_or
|
||||
|
||||
|
||||
SECTION "Test arithmetic", ROM0
|
||||
Floating:
|
||||
println Floating & 0
|
||||
println 0 & Floating
|
||||
3
test/asm/const-zero.err
Normal file
3
test/asm/const-zero.err
Normal file
@@ -0,0 +1,3 @@
|
||||
error: const-zero.asm(21) -> const-zero.asm::test_or(14):
|
||||
Expected constant expression: PC is not constant at assembly time
|
||||
error: Assembly aborted (1 error)!
|
||||
6
test/asm/const-zero.out
Normal file
6
test/asm/const-zero.out
Normal file
@@ -0,0 +1,6 @@
|
||||
What do you get if you multiply six by seven?
|
||||
Life, the Universe, and Everything!
|
||||
Where are we?
|
||||
Here we are!
|
||||
$0
|
||||
$0
|
||||
@@ -6,7 +6,7 @@ MACRO test_expr
|
||||
|
||||
DEF IS_CONST = ISCONST(\1)
|
||||
PRINTLN "Test #{d:TEST_NUM}: ISCONST reports {IS_CONST}"
|
||||
IF (\1) || 1 ; Only test if the expression can be evaluated
|
||||
IF (\1) || IS_CONST ; Only test if the expression can be evaluated
|
||||
WARN "Test #{d:TEST_NUM}: Compile-time constant"
|
||||
ENDC
|
||||
ENDM
|
||||
|
||||
Reference in New Issue
Block a user