Equal_Parser  (Author: Scarmatil)  ..



To enable it, you have to write:


PREPARSE Equal


See Pre_Parser_concept, for PREPARSE rigid syntax. The ''Equal'' Pre-Parser's purpose is to imitate the HLL writing Style (non-Assembly syntax). ''Equal'' is, in fact, not one, but two different Pre-Parsers: The Statements Equal Pre-Parser, and the FPU Equal pre-Parser.



Compile-Time Expressions


Statements the Equal Pre-Parser translates, expressions like:


eax = 1

edx = &TRUE+(2*2)

D$Value1 = D$Value2

W$Value1+2 = W$Value2+2

D$Handle = call 'DLLNAME.DllFunction', Para1, ...  ; or any Proc call returning eax.


into:


mov eax 1

mov edx &TRUE+(2*2)

push D$Value2 | pop D$Value1

push W$Value2+2 | pop W$Value1+2

call 'DLLNAME.DllFunction', Para1, ...  | mov D$Handle eax



Run-Time Expressions


It also can parse Run-time Expressions (Expressions expanded into Instructions and, eventually Data Declarations, whose values will only be known at Run-Time):


eax = (D$a+D$b)/6+(D$c*7)

D$val3 = (3 * D$a + 12) / (24 * D$b) - D$c * D$c * 18 / 13 + D$z


R$FpuValue = 13.333+5*R$MyReal/((-1.24+F$MyFloat*W$MyWord)/3-(2+D$MyDWord))


Operators List:


=> ^        ; power operator, the first operand has to be strictly positive 

=> * / + - : common operators

   => // **    ; signed operators 


integrated FPU functions: cos(), sin(), abs(), tan() and sqrt().


ebx = sin(45)

T$FloatNumber = sqrt(abs(7+-3*ebx)+R$FpVal)


Signed operations:


To force signed integer division and multiplication you can use '//' and '**' operators. Notice that if one of the operands is a floating point value (6.2,T$MyVal,...) the operation will be signed even with '*' and '/' operators.


Conversions:


The parser can perform any conversion as long as they are not impossible (B$val1 = D$val2 ;for example):


  > ST0 = (D$a+D$b)/6+(D$c*7)       ; integer result stored in a FPU register

  > Q$MyQValue = B$MyByteVal  

  > ...


Array support:


There is no possible way to use arrays (X can be any of the data sizes stated below):

    - X$(address)     : this will be interpreted as : X$address*(X_size)

    - X$Array(index)  : this will be interpreted as : X$Array+index*(X_size)


[MyTable: D$ 'ZERO' 'ONE ' 'TWO ' 'THREE' 'FOUR' 'FIVE']


    mov eax  4

    eax  =  D$MyTable(eax)  ; eax = 'FOUR'



Supported data size:


(both in source and destination): B$, W$, D$, Q$, F$, R$ and T$.



 Basically this parser works as follows 


It first copies the operation from CodeSourceA to CodeSourceB ( from the first parenthesis to EOI)


Then spaces are added (if needed) before and after each parenthesis, operator and data  (registers and constants included)


The parsing begins and, the first closing parenthesis is searched. Each time the parser meets an opening parenthesis, its address is stored in ebx . Once a closing parenthesis is found, the operations in these parentheses are processed.  (for more details, see in each part)

  


Example of how the parser expands a Statement


   > eax = (D$b-D$a*(ebx+7/2)-3)


You can see what the Equal Parser does, with the Double-Click Float  Menu, Option [Unfold], just like with a User Defined Macro, if you Double-Click, say, on the above 'eax':

  

    FINIT

    PUSH EAX

    PUSH EBX

    PUSH EDX

    [AAAAAAAA: 0]

    MOV D$AAAAAAAA EBX

    [BAAAAAAA:T$ 3.5E+0000]

    FLD T$BAAAAAAA

    FIADD D$AAAAAAAA

    FSTP T$BAAAAAAA

    FLD T$BAAAAAAA

    FIMUL D$A

    FSTP T$CAAAAAAA

    [CAAAAAAA:T$ 0]

    FLD T$CAAAAAAA

    FISUBR D$B

    FSTP T$DAAAAAAA

    [DAAAAAAA:T$ 0]

    [EAAAAAAA:T$ 3]

    FLD T$EAAAAAAA

    FLD T$DAAAAAAA

    FSUBRP ST0 ST1

    FSTP T$EAAAAAAA

    POP EDX

    POP EBX

    POP EAX

    [FAAAAAAA: 0]

    FLD T$EAAAAAAA


~~~~~~~