1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-24 14:38:05 +11:00

zasm: fix expr operator priority

This commit is contained in:
Virgil Dupras 2019-05-18 15:17:56 -04:00
parent 068e4327ec
commit d47d07757e
2 changed files with 18 additions and 5 deletions

View File

@ -10,15 +10,15 @@ parseExpr:
ret
_parseExpr:
ld a, '*'
call _findAndSplit
jp z, _applyMult
ld a, '+'
call _findAndSplit
jp z, _applyPlus
ld a, '-'
call _findAndSplit
jp z, _applyMinus
ld a, '*'
call _findAndSplit
jp z, _applyMult
jp parseNumberOrSymbol
; Given a string in (HL) and a separator char in A, return a splitted string,
@ -70,6 +70,7 @@ _applyMinus:
push ix
pop hl
ex de, hl
scf \ ccf
sbc hl, de
push hl
pop ix

View File

@ -18,8 +18,9 @@ testNum: .db 1
s1: .db "2+2", 0
s2: .db "0x4001+0x22", 0
s3: .db "FOO+BAR", 0
s4: .db "3*3", 0
s4: .db "BAR*3", 0
s5: .db "FOO-3", 0
s6: .db "FOO+BAR*4", 0
sFOO: .db "FOO", 0
sBAR: .db "BAR", 0
@ -79,7 +80,7 @@ test:
or a
jp nz, fail
ld a, ixl
cp 9
cp 0x60
jp nz, fail
call nexttest
@ -94,6 +95,17 @@ test:
jp nz, fail
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
xor a
halt