EXPRESSIONS

 EXPRESSIONS

1) Types of Expressions

There are three types of expressions in C--, not counting constant
expressions.  They are EAX/AX/AL expressions, non-EAX/AX/AL expressions and
conditional expressions.  All C-- expressions are evaluated left to right,
regardless of the operations involved.

2)  EAX/AX/AL Expressions

EAX/AX/AL math is used for expressions which the result will be stored in a
memory variable or the EAX, AX or AL register.  If the expression is going to
be stored in a char or byte variable, AL math will be used.  If the
expression is going to be stored in a int or word variable, AX math will be
used.  If the expression is going to be stored in a long or dword variable,
EAX math will be used.

If there are no procedure calls in an EAX/AX/AL expression, only the
values of AX (or EAX or AL), CX  (or ECX or CL) and DX (or EDX or DL) may be
destroyed, all other register values will be preserved during and after the
expression is evaluated.


3)  Non-EAX/AX/AL Expressions

Non-EAX/AX/AL math is used for expressions which the result will be stored
in a register other than EAX, AX or AL.  With non-EAX/AX/AL only the result
register's value will change, all other register values will be preserved,
the high byte of the byte registers may be destroyed, if a word value is
used with an expression which will be stored in a byte register.  This does
however restrict the operations and operands available with non-EAX/AX/AL
math. No MACRO, REG procedure or STACK procedure calls may be made within a
non-AX/AL/EAX expression.


4)  Conditional Expressions

Conditional expressions are expressions which are used for generating a 'yes'
or 'no' for 'if' statements and 'do {} while' loops.

There are two types of conditional expressions, simple and complex.

4.1)  Simple Conditional Expressions

Simple conditional expressions are a single token or expression that will be
taken as a 'yes' if the calculated value is non-zero, or a 'no' if the
calculated value is zero.

4.2)  Complex Conditional Expressions

Complex conditional expressions are of the following form:

    ( leftside compare_op rightside )

Where:
    'leftside' is any AL/AX/EAX or constant expression.  The expression
        type will be determined by the first token (register or
        variable)default is 'word', if an other type is desired, the
        keyword 'byte', 'char', 'int', 'long' or 'dword' can
        preceed the expression to specify its type.
    'compare_op' is any one of '==', '!=', '<>', '<', '>', '<=', or '>='.
    'rightside' is any single register, variable or constant expression.

Some examples of valid complex conditional expressions:

    ( x+y > z )
    (int CX*DX <= 12*3 )
    (byte first*second+hold == cnumber )

Some examples of invalid complex conditional expressions:

    ( x+y >= x-y ) // rightside is not a single token or constant expr.
    ( z = y )      // '==' not '=' must be used

Post a Comment

0 Comments