Dotneteer/kliveide

Error when doing multiplication in expression

marco-leal-zx opened this issue · 3 comments

When declaring:

ld a, (FRAMES - 1) * 8

I get an "Invalid token at the end of the line: *" error when compiling.

The problem seems to be with the parenthesis. If I remove them, it compiles without issues (but obviously doesn't work for my purpose).

Marco, thanks for signing this issue! I'm about to fix it soon.

Marco,

Unfortunately, this is not a bug but a feature :-). The Klive Z80 Assembler considers this instruction as "Load the value of Register A from an address", and takes FRAME -1 as the address. In situations, where parentheses may mean indirection, you can use square brackets. So this will compile:

ld a, [FRAMES -1] * 8

I know, the assembler may infer from the context that ld a,(FRAMES -1) * 8 is not an indirect load, but it does not.

Yes, I get it. It makes sense.