Keil Logo

SET Function

The SET MPL function defines macro-time symbols. The SET function takes two arguments: a valid identifier and a numeric expression. The syntax for the SET function is:

%SET (id,expression)

The SET function defines the id and assigns it the value of expression.

The SET function affects the macro processor symbol table only. Symbols defined by SET may be redefined with a second call to the SET function or may be defined as a macro by calling the DEFINE function.

To use a symbol defined by the SET function, specify the meta character followed by the symbol name. When symbols are expanded, they are replaced by the hexadecimal representation followed by the letter 'H'.

Source Text

%SET (CNT, 3)
%SET (OFS, 16)

MOV R1,#%CNT+%OFS

%SET (OFS, %OFS + 10)

OFS = %OFS

Output Text

MOV R1,#03H+10H
OFS = 1AH

Identifiers defined with the SET function may be used in the expression to redefine their values.

Source Text

%SET (CNT, 10)    %' define variable CNT'
%SET (OFS, 20)    %' define variable OFS'

%' change values for CNT and OFS:'

%SET (CNT, %CNT+%OFS)    %' CNT = 30'
%SET (OFS, %OFS * 2)     %' OFS = 40'

MOV R2,#%CNT + %OFS      %' 70'
MOV R5,#%CNT             %' 30'

Output Text

MOV R2,#1EH + 28H
MOV R5,#1EH
  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.