Literal values

Language reference ››
Parent Previous Next

PMP supports standard Pascal constant formats as well as additional ones that programmers like (sorry but octal, duodecimal and sexagesimal are not supported):


$<hex>        hexadecimal constant (8..32-bit) (TP/Delphi format)

0x<hex>        hexadecimal constant (8..32-bit) (C format)

h'<hex>'        hexadecimal constant (8..32-bit) (MPASM™ format) (note 2)

0b<binary>        binary constant (8..32-bit) (C format)

b'<binary>'        binary constant (8..32-bit) (MPASM™ format) (note 2)

%<binary>        binary constant (8..32-bit) (Some other Pascal format)

'<character>'        single character constant (ASCII), evaluated as CHAR.

#n        single character constant (ASCII), evaluated as CHAR.

#$<hex>        single character constant (ASCII), evaluated as CHAR.

'<string>'        string constant (note 1)

 

Note 1:        Control character literals (TP / Delphi ^n form, or C \n form) are not allowed; for concatenation use the + operator construction..

Note 2:        There is a special syntax behaviour for b'<binary>' and h'<hex>': spaces, dots, dashes and underscores are accepted inside the quoted string for improving readability; they are ignored.


NEW! (V2.0): If the $EXTENDED syntax is ON, literal numbers may also contain underscore characters for improving readability; they are ignored and cannot be at heading or trailing positions:



CONST
 MyConst = 1000_000 // Only in extended syntax
 MyHexConst = $FBCD_AA55 // Only in extended syntax
 MyBinConst = b'0000.0101' // $05
 MySpecialChar = #$0d; // CR
 MySpecialStr = 'Hello'#13#10'World!'; // 'Hello' + CR + LF + 'World!'