Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

equ directive should support operator precedence in its arithmetic expressions #83

Open
bxparks opened this issue Jun 22, 2024 · 3 comments

Comments

@bxparks
Copy link

bxparks commented Jun 22, 2024

Problem

The equ directive can contain arithmetic expressions. But apparently, there is no support for operator precedence. So the following equ statement:

helloRowCol equ helloRow + $100*helloCol

is currently interpreted as (helloRow+$100) * helloCol.

The correct expression has to be written as:

helloRowCol equ helloRow + ($100*helloCol)

as done in #82, but this is very easy to forget.

Expectation

  • The equ directive should support basic operator precedence, so that multiplication * and division / has a higher precedence than addition + and subtraction -`.
  • If there are other operators supported by the equ, a reasonable order of precedence would be to follow the same rules as the C language.
@calc84maniac
Copy link
Collaborator

As far as I'm aware, this is intentional design for compatibility with TASM.

@bxparks
Copy link
Author

bxparks commented Jun 22, 2024

Interesting. In that case, this is a place where a non-fatal warning message would be useful. In other words, if the current left-to-right operator precedence rule would produce a different result than the MDAS rule that many people would expect.

@Eeems
Copy link

Eeems commented Jun 22, 2024

It would be nice to have a flag to use proper precedence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants