Google

May 16, 2008

Operator Precedence

Consider the expression 1 + 2 * 3. When A86 sees this expression, it could perform the multiplication first, giving an answer of 1+6 = 7; or it could do the addition first, giving an
answer of 3*3 = 9. In fact, A86 does the multiplication first,because A86 assigns a higher precedence to multiplication than it does addition.

The following list specifies the order of precedence A86 assigns to expression operators. All expressions are evaluated from left to right following the precedence rules. You may override this order of evaluation and precedence through the use of parentheses

( ). In the example above, you could override the precedence by parenthesizing the addition: (1+2) * 3.

Some symbols that we have referred to as operators, are treated by the assembler as operands having built-in values. These include $, and ST. In a similar vein, a segment override term (a segment register name followed by a colon) is recorded when it is scanned, but not acted upon until the entire containing expression is scanned and evaluated. The size operators B, W, D,F, Q, and T are also recorded and applied after scanning and evaluation.

If two operators are adjacent, the rightmost operator must have precedence; otherwise, parentheses must be used. For example,
the expression BIT ! 1 is illegal because the leftmost operator

BIT has the higher precedence of the two adjacent operators BIT and "!". You can code BIT (! 1).

--Highest Precedence--

1. Parenthesized expressions

2. Period

3. OFFSET, SEG, TYPE, REF, DEF, and PTR

4. HIGH, LOW, and BIT

5. Multiplication and division: *, /, MOD, SHR, SHL

6. Addition and subtraction: +,-

a. unary

b. binary

7. Relational: EQ, NE, LT, LE, GT, GE =

8. Logical NOT and !

9. Logical AND

10. Logical OR and XOR

11. Colon for long pointer, SHORT, LONG, and BY

12. DUP

--Lowest Precedence--

You might be also interested in:

:: why there are two ground pins in 8086
:: Program to display ASCII characters on the display unit
:: 8051 based project for electrical students
:: free and open source 8086 Microprocessor Emulator

No comments: