X && 0 and X & 0 are constant 0; X || 1 is constant 1 (#1399)

Fixes #977
This commit is contained in:
Sylvie
2024-06-13 11:09:39 -04:00
committed by GitHub
parent c5c6cc9794
commit dfec7111e2
6 changed files with 65 additions and 2 deletions

29
test/asm/const-zero.asm Normal file
View 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