int e l 5.4 HOW RELATIONAL EXPRESSIONS WORK Relational expressions involve the operators =, , >, >=, used to "test" a condition. In MCS BASIC-52 relational operators return a result of 65535 (0FFFFH) if the relational expression is true, and a result of 0, if the relation expression is false. But, where is the result returned? It is returned to the argument stack. Because of this, it's possible to actually display the result of a relational expression. EXAMPLES:
PRINT 1=0 PRINT 1>0 PRINT A A PRINT A=A 0 65535 0 65535 It may seem strange to have a relational expression actually return a result, but it offers a unique benefit in that relational expressions can actually be "chained" together using the logical operators .AND., .OR.. and .XOR.. This makes it possible to test a rather complex condition with ONE statement. EXAMPLE: >1O IF A D THEN. . . . . . Additionally, the NOT([expr]) operator can be used. EXAMPLE: >10 IF NOT(A>B). AND. A By "chaining" together relational expressions with logical operators, it is possible to test very particular conditions with one statement.
When using logical operators to link together relational expressions, it is very important that the programmer pay careful attention to the precedence of operators. The logical operators were assigned lower precedence, relative to relational expressions, just to make the linking of relational expressions possible without using parentheses. - 81 -