4+-(5+~3)
is translated to:
ld hl, 4
push hl
ld hl, 5
ld de, 3
ld a,e
cpl
ld e,a
ld a,d
cpl
ld d,a
add hl, de
pop de
ex de,hl
ld a,e
cpl
ld e,a
ld a,d
cpl
ld d,a
inc de
add hl, de
That may seem much, but most of it is the super inefficient unary operator - and ~.
It is able to do * and / too, but that's not a z80 command, and I have no libs yet...
It also optimizes a VERY little bit: for example, it doesn't fall for this one:
(Which is also good to have no precedence)
((((2+3)*4)+5)/7)
is translated to:
ld hl, 2
ld de, 3
add hl, de
ld de, 4
call multiply
ld de, 5
add hl, de
ld de, 7
call divide
Isn't that nice?