PROGRAM definition

Language reference ››
Parent Previous Next

A typical PMP program contains the following elements:

program-definition =
PROGRAM program-name ";"
[ hardware-declarations ]
[ uses-declaration ]
[ declarations ]
[ program-initialization-part ]
[ declarations ]
main-block .

uses-declaration = USES used-unit { "," used-unit } ";" .
used-unit = identifier [ IN file-name-string ] .
declarations =
[ constants-declarations ]
[ types-declarations ]
[ variables-declarations ]
[ procedure-or-function-declaration ]
} .
main-block = begin-end-block  "." .
begin-end-block =
 { block }
block = { statements | begin-end-block } .
statements = statement { ";" statement } .

program-initialization-part =
{ block }
END ";" .

PMP syntax is as close as possible to the TP / Delphi syntax.

All programs must begin with the PROGRAM keyword, followed by the name of the program.

<program-name> must match the file name and cannot be expressed as a string, so long file names are allowed but they must contain only valid identifier characters.

NEW! (V2.0):

The alternate syntax for <uses-declaration> permits to specify a full long file name for a unit, as in Delphi, so the unit name may differ from its file name.

<file-name-string> is a constant string expression specifying the file name. It cannot contain an explicit directory part: the global search paths are used to find it.

The program body may contain some declarations about the target processor, contained in the hardware declaration section. By default the project's options are used.

The program may contain one or more optional special procedures qualified with the INTERRUPT modifier, which are used to define sets of statements that are intended to be executed as interrupt service routines.


The main program block that is the last defined block of a program.

This block is executed immediately upon processor reset (after main start-up code and program or unit initializations).  

NEW! (V2.1):

The main program may have an INITIALIZATION block that is executed once after all other initializations. With this feature, the main program is the main control loop and does not require some LOOP .. END structure after initializations:




BEGIN // Main program loop