Calculating and Converting

CFS commands that begin with the character '=' are evaluated by an internal Calculation and Conversion module. The result is displayed in the system line (Line 25). The following functions are available:

Arithmetic and logical Operations:

The four basic arithmetical functions + - * /, as well as % calculations and the logical operations .AND., .OR., .XOR. are provided. Operands can be entered in hexadecimal or decimal format. The mathematical expression should be entered as follows:

=value [ op value ] ...

value Decimal or Hexadecimal value.

Values consisting only of 0 to 9 will be interpreted as decimal values. If the value contains the characters A to F, they will be treated as hexadecimal. Suffixing a decimal value with H or X (e.g. 10H) will cause it to be interpreted as a hexadecimal value.

op Arithmetic or logical operator. The following operators are available:

+ Addition

- Subtraction

* Multiplication

/ Division

% % calculation

.+. Addition without regard to the sign (address calculation)

.-. Subtraction without regard to the sign (address calculation)

.AND. logical AND function

.OR. logical OR function

.XOR. logical Exclusive OR

The individual operations are evaluated linearly. Example: =10+10*2 gives the result 40, and not 30 as would normally be expected. The same is true for all logical operations.

Examples:

=16+80H

The value 144 in decimal and 90H in hexadecimal will be displayed in the system line as the result of the addition.

=7FFFFD45.+.FFF

The value 80000D44 will be displayed as a result of this logical addition. The arithmetic addition =7FFFFD45+FFF will result in the error message 'result too big...' appearing, since the maximum positive hexadecimal value of 7FFFFFFF will have been exceeded (Fixed-point overflow).

=1200%14+1200%85

This expression will be evaluated as follows:

14% of 1200=168, 168+1200=1368, 85% of 1368=1162.

=7C

The decimal and hexadecimal representation of the given value will be displayed: 7C= 124 (7C)

=1.OR.2.OR.4.OR.8

The four hexadecimal operands are logically OR-ed with one another. The hexadecimal value F is displayed as the result.

=AFFE.AND.5001H

The two hexadecimal operands are logically AND-ed with each other. The hexadecimal value 0H is displayed as the result.

=7FFE.XOR.FF0

The two hexadecimal operands are logically XOR-ed with each other. The hexadecimal value 7000EH is displayed as the result.

Character and Hexadecimal Conversion:

Strings entered in hexadecimal notation will be converted to character format. Character strings will be converted to hexadecimal format. Strings to be converted should be entered in the following format:

=X'string' | =[C]'string'

Non-printable characters will be displayed as a '?' when converting to character format.

Examples:

=X'C1C442'

The character equivalent C'AD?' for X'C1C442' will be displayed in the system line. Non-printable characters are displayed as '?'.

='AFFE'

The hexadecimal equivalent X'C1C6C6C5' for C'AFFE' will be displayed in the system line.