Keil Logo

MATCH Function

The MATCH MPL function searches a character string for a delimiter character and assigns the substrings on either side of the delimiter to specified identifiers. The syntax for the MATCH function is:

%MATCH (id1 delimiter id2) (balanced-text)

Where

id1 is a valid identifier that is assigned text in balanced-text left of delimiter.
delimiter is the first character to follow id1. Any non-macro character may be used (like a space or a comma).
id2 is a valid identifier that is assigned text in balanced-text right of delimiter.
balanced-text specifies the text the MATCH function searches. It may contain macro calls.

The MATCH function searches balanced-text for the specified delimiter. When the delimiter is found, all characters to the left are assigned to id1 and all characters to the right are assigned to id2. If the delimiter is not found, the entire balanced-text string is assigned to id1 and the null string is assigned to id2.

Source Text

%DEFINE (text) (-1,-2,-3,-4,-5)
%MATCH (next,list) (%text)
%WHILE (%LEN (%next) NE 0)
(      MOV  R8,#%next
       MOV  [R1+],R8 %MATCH
(next,list)(%list)
)

Output Text

MOV    R8,#-1
MOV    [R1+],R8
MOV    R8,#-2
MOV    [R1+],R8
MOV    R8,#-3
MOV    [R1+],R8
MOV    R8,#-4
MOV    [R1+],R8
MOV    R8,#-5
MOV    [R1+],R8
  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.