Functional operators, String operators – MITSUBISHI ELECTRIC T-60 User Manual

Page 48

Advertising
background image

It is possible to use logical operators to test bytes for a particular bit pattern.

For instance, the AND operator may be used to mask all but one of the bits of
a status byte at a machine I/O port. The OR operator may be used to merge
two bytes to create a particular binary value. The following examples

demonstrate how the logical operators work:

Example

Explanation

63 AND 16=16

63=binary 111111 and 16=binary 10000, so 63 AND 16=16

10 OR 10=10

10=binary 1010, so 1010 OR 1010=1010(10)

NOT X = -(X+1)

The two’s complement of any integer is the bit
complement plus one.

Functional Operators

A function is used in an expression to call a predetermined operation that is

to be performed on an operand. BASIC has intrinsic functions that reside in
the system, such as SQR (square root) or SIN (sine).

BASIC also allows user-defined functions written by the programmer. See

the DEF FN statement in the EMERSON EMC BASIC PROGRAMMING
GUIDE.

The CALL instruction allows access to T-60 machine specific features such as
special screen functions or option board functions. The CALL instruction

may have optional parameters associated with it. Refer to the CALL
instruction in the EMERSON EMC BASIC PROGRAMMING GUIDE.

String Operators

To compare strings, use the same relational operators used with numbers:

Operator

Meaning

=

Equal to

<>

Unequal

<

Less than

>

Greater than

<=

Less than or equal to

>=

Greater than or equal to

The BASIC Interpreter compares strings by taking one character at a time
from each string and comparing their ASCII codes. If the ASCII codes in each
string are the same, the strings are equal. If the ASCII codes differ, the lower

code number will precede the higher code. If the interpreter reaches the end
of one string during string comparison, the shorter string is said to be

smaller, providing that both strings are the same up to that point. Leading
and trailing blanks are significant.

T-60 Operator's Manual

40

Advertising