AnsweredAssumed Answered

Stack-based math (STAKMATH) for ASM8 updated

Question asked by Tony Papadimitriou on Mar 20, 2013
Latest reply on Dec 1, 2013 by Tony Papadimitriou

(For some reason I cannot change the subject when replying to a previous thread, so I started a new one.)

 

I have updated the STAKMATH module for ASM8 to include an expression parser set of macros.  You need the latest ASM8 v8.80

 

This allows you to write an expression like the one below, and it will be converted to the appropriate macro calls.

For example: @Eval32 Ans=123*(N1+N2)/(N1-N2)-5

will result in the following sequence.

 

--------------------------------------------------

Expr: Ans=123*(N1+N2)/(N1-N2)-5

--------------------------------------------------

Load32 #5

Load32 N2

Load32 N1

Sub32

Load32 N2

Load32 N1

Add32

Load32 #123

Mul32

Div32

Sub32

Save32 Ans

 

You can use nested parentheses, spaces between operands/operators, and the assignment variable is optional.  If not used, the result will remain on top-of-stack.  Numeric constants are recognized automatically, while named constants must be given as #CONSTANT

You can also use SP-based variables (in #SPAUTO mode).


Hope you like it.  (If you find errors in parsing, please let me know.)

tonyp

Outcomes