Keil Logo

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:

Base Suffix Valid Characters Examples
Binary B,b 0-1 1111B
10011111B
101010101B
Octal O,o,Q,q 0-7 177O
7777o
25O
123o
177777O
Decimal D,d 0-9 1234
65590D
20d
123
Hexadecimal H,h 0-9, A-F, a-f 1234H
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&emdash;that is, if they have A-F in that position&emdash;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.
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.