zasm: fix expr operator priority
This commit is contained in:
parent
068e4327ec
commit
d47d07757e
@ -10,15 +10,15 @@ parseExpr:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
_parseExpr:
|
_parseExpr:
|
||||||
ld a, '*'
|
|
||||||
call _findAndSplit
|
|
||||||
jp z, _applyMult
|
|
||||||
ld a, '+'
|
ld a, '+'
|
||||||
call _findAndSplit
|
call _findAndSplit
|
||||||
jp z, _applyPlus
|
jp z, _applyPlus
|
||||||
ld a, '-'
|
ld a, '-'
|
||||||
call _findAndSplit
|
call _findAndSplit
|
||||||
jp z, _applyMinus
|
jp z, _applyMinus
|
||||||
|
ld a, '*'
|
||||||
|
call _findAndSplit
|
||||||
|
jp z, _applyMult
|
||||||
jp parseNumberOrSymbol
|
jp parseNumberOrSymbol
|
||||||
|
|
||||||
; Given a string in (HL) and a separator char in A, return a splitted string,
|
; Given a string in (HL) and a separator char in A, return a splitted string,
|
||||||
@ -70,6 +70,7 @@ _applyMinus:
|
|||||||
push ix
|
push ix
|
||||||
pop hl
|
pop hl
|
||||||
ex de, hl
|
ex de, hl
|
||||||
|
scf \ ccf
|
||||||
sbc hl, de
|
sbc hl, de
|
||||||
push hl
|
push hl
|
||||||
pop ix
|
pop ix
|
||||||
|
@ -18,8 +18,9 @@ testNum: .db 1
|
|||||||
s1: .db "2+2", 0
|
s1: .db "2+2", 0
|
||||||
s2: .db "0x4001+0x22", 0
|
s2: .db "0x4001+0x22", 0
|
||||||
s3: .db "FOO+BAR", 0
|
s3: .db "FOO+BAR", 0
|
||||||
s4: .db "3*3", 0
|
s4: .db "BAR*3", 0
|
||||||
s5: .db "FOO-3", 0
|
s5: .db "FOO-3", 0
|
||||||
|
s6: .db "FOO+BAR*4", 0
|
||||||
|
|
||||||
sFOO: .db "FOO", 0
|
sFOO: .db "FOO", 0
|
||||||
sBAR: .db "BAR", 0
|
sBAR: .db "BAR", 0
|
||||||
@ -79,7 +80,7 @@ test:
|
|||||||
or a
|
or a
|
||||||
jp nz, fail
|
jp nz, fail
|
||||||
ld a, ixl
|
ld a, ixl
|
||||||
cp 9
|
cp 0x60
|
||||||
jp nz, fail
|
jp nz, fail
|
||||||
call nexttest
|
call nexttest
|
||||||
|
|
||||||
@ -94,6 +95,17 @@ test:
|
|||||||
jp nz, fail
|
jp nz, fail
|
||||||
call nexttest
|
call nexttest
|
||||||
|
|
||||||
|
ld hl, s6
|
||||||
|
call parseExpr
|
||||||
|
jp nz, fail
|
||||||
|
ld a, ixh
|
||||||
|
cp 0x40
|
||||||
|
jp nz, fail
|
||||||
|
ld a, ixl
|
||||||
|
cp 0x80
|
||||||
|
jp nz, fail
|
||||||
|
call nexttest
|
||||||
|
|
||||||
; success
|
; success
|
||||||
xor a
|
xor a
|
||||||
halt
|
halt
|
||||||
|
Loading…
Reference in New Issue
Block a user