fixed operator precedence: bitwise must come before comparisons

This commit is contained in:
Irmen de Jong 2022-08-14 12:34:00 +02:00
parent d8e18df3a1
commit 7ef4ddf0f3
4 changed files with 11 additions and 13 deletions

View File

@ -3,7 +3,6 @@ TODO
For next release
^^^^^^^^^^^^^^^^
- fix operator precedence: if rasterCount ^ $80 >= 230 EOR should precede >=
- @(ptr) |= 3 -> asm peephole optimize remove the second ldy if the instruction before doesn't modify y
ldy #0
lda (starfieldPtr2),y

View File

@ -87,7 +87,7 @@ main {
@(staticStar1) = 0
else
@(staticStar1) = 192
if (rasterCount ^ $80) >= 230
if rasterCount ^ $80 >= 230
@(staticStar2) = 0
else
@(staticStar2) = 192

View File

@ -5,17 +5,16 @@
main {
sub start() {
uword @zp flags_ptr = memory("flags", 200, 0)
txt.print("calculating...\n")
txt.print_uwhex(flags_ptr, true)
txt.nl()
ubyte rasterCount = 231
repeat 10 {
txt.print("new iter\n")
txt.print_ub(@($06))
sys.memset(flags_ptr, 200, 0)
}
if rasterCount >= 230
txt.print("y1")
if rasterCount ^ $80 >= 230
txt.print("y2")
if (rasterCount ^ $80) >= 230
txt.print("y3")
txt.print("done\n")
}
}

View File

@ -161,10 +161,10 @@ expression :
| left = expression EOL? bop = ('*' | '/' | '%' ) EOL? right = expression
| left = expression EOL? bop = ('+' | '-' ) EOL? right = expression
| left = expression EOL? bop = ('<<' | '>>' ) EOL? right = expression
| left = expression EOL? bop = ('<' | '>' | '<=' | '>=') EOL? right = expression
| left = expression EOL? bop = '&' EOL? right = expression
| left = expression EOL? bop = '^' EOL? right = expression
| left = expression EOL? bop = '|' EOL? right = expression
| left = expression EOL? bop = ('<' | '>' | '<=' | '>=') EOL? right = expression
| left = expression EOL? bop = ('==' | '!=') EOL? right = expression
| rangefrom = expression rto = ('to'|'downto') rangeto = expression ('step' rangestep = expression)? // can't create separate rule due to mutual left-recursion
| left = expression EOL? bop = 'in' EOL? right = expression