beebasm icon indicating copy to clipboard operation
beebasm copied to clipboard

Support complex expressions in instruction parameters

Open mungre opened this issue 1 year ago • 2 comments

A line like lda (P% + 7) AND &FF00,y produces an "Incorrectly formed indirect instruction" error.

Adding brackets to fix this changes the addressing mode to "zp indirect,y", as expected.

There is no way to use the "indexed,y" addressing mode with an expression that starts with a (.

mungre avatar Sep 09 '24 15:09 mungre

Use square brackets [ ] to avoid confusion with 6502 indirect instructions:

https://github.com/stardot/beebasm/blob/e87f15393e4241f754f0f1d2fbd2ecd3d540e25a/README.md?plain=1#L213-L214

kgl2001 avatar Jan 14 '25 22:01 kgl2001

Thank you, I'd never noticed that.

I've added a trivial test to exercise both kinds of brackets, and updated the tests to run on macos-14 because macos-12 has been discontinued by github.

I noticed that beebasm accepts mismatched brackets like (2+3]. I might remove this feature.

I've labelled this issue as an enhancement. The example I posted originally is unambiguous so there's no reason why it shouldn't work.

The expression parser would need to be enhanced to return an extra flag indicating one of:

  • The expression was wholly enclosed in parentheses. For (indirect) and (indirect),y.
  • The expression started with an unclosed opening parenthesis. For (indirect,x).
  • None of the above.

mungre avatar Jan 15 '25 16:01 mungre