Ax51 User's Guide

Expressions

The MPL macro processor interprets balanced text strings as numeric expressions when they are used arguments to the following MPL functions:

Numeric expressions are processed as follows:

  1. The text of the expression is expanded in the ordinary manner in which macro function arguments are evaluated.
  2. The resulting string is evaluated to a numeric value which is converted into a character representation of the expression's value (which is the final value of the expression).

The following operators may be used in numeric expressions:

  • Parentheses ()
  • HIGH, LOW
  • *, /, MOD, SHL, SHR
  • EQ, LT, LE, GT, GE, NE
  • NOT
  • AND, OR, XOR

Arithmetic on MPL numeric expressions is performed using signed 16-bit integers. The result of relational operators is either 0 (FALSE) or 1 (TRUE).

Numeric Constants

Numbers may be specified in hexadecimal (base 16), decimal (base 10), octal (base 8), and binary (base 2) using the suffix and character specified in the following table:

BaseSuffixValid CharactersExamples
BinaryB,b0-11111B
10011111B
101010101B
OctalO,o,Q,q0-7177O
7777o
25O
123o
177777O
DecimalD,d0-91234
65590D
20d
123
HexadecimalH,h0-9, A-F, a-f1234H
99H
123H
0A0F0H
0FFH

A number with no explicit base is interpreted as a decimal number. The first character of a number must always be a digit (0-9). Hexadecimal numbers that do not have a digit as the first character — that is, if they have A-F in that position — must be prefixed with a 0.

Dollar sign characters ('$') may be used within numbers to make them more readable. However, the dollar sign may not be the first or last character of a number. For example:

1111$0000$1010$0011B is equivalent to 1111000010100011B.
1$2$3$4 is equivalent to -1234.

Hexadecimal numbers may be entered using C language conventions.

0xFE02 is equivalent to 0FE02h.
0X5566 is equivalent to 05566h.

Character Constants

The MPL macro processor supports ASCII character strings which may consist of one or two characters enclosed in single quotes ("'"). For example:

'A' evaluates to 0041H.
'AB' evaluates to 4142H.
'a' evaluates to 0061H.
'ab' evaluates to 6162H.
'' is a null string which is not valid.
'abc' causes an error. The constant contains more than two characters.

Note

  • The macro processor cannot access the assembler's symbol table. Therfore, the values of labels and of SET and EQU symbols are not known during macro processing. However, you may use the SET macro function to define macro symbols.