![[ModulaWare logo 9.5KB]](images/modulw02.jpg)
ModulaWare Data Sheet
gd@modulaware.com
Modula-2 Compiler MaX V5 for OpenVMS Alpha and MVR V4 for OpenVMS VAX
with ISO Modula-2 Language Extensions
and ISO Modula-2 Standard Library
0. Introduction
- ModulaWare's Modula-2 compiler MaX V5 generates 32 bit and 64 bit native-code for
OpenVMS Alpha. To overcome 32 bit address restrictions,
storage can be allocated in the 64 virtual address space, since OpenVMS V7.0.
This requires 64 bit wide pointers and address arithmetic.
The pointer-size, either 32 bit or 64 bit, is chosen in the compilation command.
The 32 bit pointer-size is provided for backward compatibility.
The pointer-size also determines the size of the pervasive whole number data types
CARDINAL, INTEGER, and SYSTEM.ADDRESS, to match the pointer-size,
which in turn determine the type of the formal parameters of
storage allocation procedure NEW and DISPOSE.
MaX V5 runs under any version of OpenVMS Alpha V6 or later.
When compilation is performed under V6.x, independent from the pointer-size,
the generated code can also be executed under V7.0 or later (and vice versa,
if the memory requirements of the application do not exceed the 32 address space).
To exploit the 64 bit virtual address space, OpenVMS Alpha V7.0 or later is required.
- ModulaWare's Modula-2 compiler MVR V4 generates 32 bit native-code for
OpenVMS VAX V5 or later.
1. Modula-2 Language Features
- Identifiers: sequences of letters, digits and the additional characters "$"
and "_". Upper and lower case letters have a distinctive function and all
characters are relevant (except for module names which have 24
relevant characters in maximum).
- Number literals: integers and cardinals (unsigned integers) in decimal,
octal, and hexadecimal notation. Reals and complexes in double
precision, expression compatible with single precision real and complex
operands; conversion functions to construct constant (F | D | G | H | S |
T)_floating numbers and (F | D | G | S | T)_complex number constants.
Constant declarations may use most of the standard functions (those
are marked below by an "*") in constant expressions for all number types
and are evaluated at compile-time.
- Comments: enclosed in (* ... (*may be nested to as many levels as you
like *) ... *).
- Type declarations: BOOLEAN, INTEGER, CARDINAL, REAL, LONGREAL,
COMPLEX, LONGCOMPLEX, CHAR, SET, BITSET, PACKEDSET, PROC
enumeration, subrange types, array types, record types, set types
(up-to 128 elements), pointer types and procedure types.
- Arithmetic operators: +,-,* for the addition, subtraction, multiplication of
operands of type integers, cardinals, subrange, real and complex. / for
real or complex division, DIV for integer or cardinal division MOD for
integer modulus, REM for integer remainder.
- Logical operators: OR, AND or &, NOT or ~ for logical conjunction,
disjunction and negation.
- Set operators: +,-,*,/ for set union, difference, intersection and symmetric
set difference.
- Relational operators: =, # or <>, <, <=, >, >=, IN for equal, unequal, less,
less or equal (set inclusion), greater, greater or equal (set inclusion),
contained in (membership).
- Expressions: allow record and array constructors for user-defined data
types, so-called aggregates of the form T{expr_list}.
- Statements: assigments, procedure calls, if statement, case statements,
while statements, repeat statements, for statement, loop statement, with
statements, return and exit statements.
- Procedure and function procedure declarations with multi-dimensional
open array and procedure-type formal parameters. Recursive calls are
allowed. Declaration of procedures & variables before use is not
required. Functions may have any type, i.e.: structured function types of
any type size are allowed.
- Modules constitute a collection of declarations and sequences of
statements. A module serves as a wall around its local objects whose
transparency is strictly under control of the programmer. It can also be
declared local to a surrounding module or procedure.
- Compilation units: definition module, foreign definition module or
implementation module.
- Module initialisation: the body of an implementation module acts as an
initialisation facility for its local objects.
2. MaX | MVR Separate Library
- Separate standard library modules: Most Modula-2 programs will make
use of separately compiled utility modules by importing them. The full set
of the ISO 10154 Modula-2 Standard Library (2nd CD) plus
ModulaWare's extensions for system specific 64 bit whole number,
floating point and complex data types is provided. The full description
(definition modules, description in English and semantic specification in
VDM-SL) is contained in the ISO Modula-2 Standard document 10514
(2nd CD 1992, DIS Jun-1994), available at the national Standardisation
Organisations. The MaX | MVR distribution includes the Modula-2
definition modules in source form (these contain a short description in
English as comments) and the Modula-2 implementation modules in
[recompilable] object form.
There is one identical set of sources for the Modula-2 library for MaX and MVR.
The library source code is 64 bit upward compatible and
can be compiled with both, 32 bit and 64 bit pointer-size.
Since address arithmetic on the Alpha is always performed with 64 bit arithmetic,
modules compiled with 32 bit pointer-size can be imported in modules compiled with 64 bit pointer-size.
The low-level modules RMS and RMSFiles
provide support for direct I/O of data buffers located in the so-called P2- and S2-space,
with up-to 2 GB in size per transfer,
using the 64 bit extensions of the record management services introduced in OpenVMS Alpha V7.
Programs linked to the 64 bit RMS[Files] modules can also be executed under OpenVMS Alpha V6.x.
RMSFiles checks the OpenVMS version in its module initialisation part
and uses the 64 bit extensions only in case it is running on Alpha under V7.0 or later.
MVR/MaX V4 and MaX V5 have identical source code for
[ISO] Modula-2 library,
I/O test programs, and
processes and semaphores test programs.
- Operating system specific library modules and utilities: a collection of
modules that provide access to operating system services and definitions,
file-I/O, mathematical functions for reals of any floating and complex types,
and layered software products such as X11, DECWindows, OSF/Motif, UIS/VWS, FMS,
VAXLab, GKS, ... as well as a make-tool and LSE-support.
3. Standard Functions and Procedures
- Standard function procedures are predeclared and directly known by
the compiler. Only those marked by SYSTEM have to be imported;
those marked by an "*" may be used in the declaration section in
constant expressions:
- ABS (x:T): T absolute value of type T.*
- SYSTEM.ADDADR (adr: ADDRESS; offset: CARDINAL): ADDRESS
address addition.
- SYSTEM.ADR (VAR x: T): ADDRESS gives the storage address of the
substituted variable.
- SYSTEM.ASH (x, n: INTEGER): T if n>=0 then x shifted to the left by n bits
otherwise arithmetically to the right by n bits (non standard extension).*
- CAP (ch: CHAR): CHAR the corresponding capital letter.*
- SYSTEM.CAST (T, i): T so-called type transfer function to cast the
expression i to type T. (Different type sizes only allowed if both, type size
of T and type of i are less or equal to 4.)*
- CHR (i: CARDINAL): CHAR the character with ordinal number i.*
- CMPLX (real1, real2: T): C constructs a complex number with real1 as
real-part and real2 as imaginary-part; result type C either type
COMPLEX if T of type REAL or of type LONGCOMPEX if T of type
LONGREAL.*
- SYSTEM.DIFADR (faddr, saddr: ADDRESS): INTEGER address
difference.
- FLOAT (x: T): REAL integer or any real to single precision real conversion.
(T is either signed or unsigned whole number type or [LONG]REAL or
(F|D|G|H)_FLOATING)*
- SYSTEM.FREGISTER (num: CARDINAL): SYSTEM.T_FLOATING (AXP)
content of the specified floating register. 0 <= num <= 31.
- LFLOAT (x: T): LONGREAL integer or any real to double precision real
conversion. (Type of T is same as in FLOAT, except for G_FLOATING)*
- SYSTEM.LIB$ESTABLISH ( %IMMED handle: ConditionHandler ): PROC;
(AXP) see MaX implementation notes
- SYSTEM.LIB$REVERT(): PROC; (AXP) see MaX implementation notes
- HIGH (a: ARRAY OF T): CARDINAL high index bound of an open array
parameter of any type T in procedures (restricted to open array
parameters with /ISO)
- IM (c: T): R imaginary-part of a complex number; result type R is either
REAL if T of type COMPLEX or LONGREAL if T of type LONG-
COMPLEX.*
- INT (x: T): INTEGER conversion of any real type T to integer.*
- LENGTH (s: ARRAY OF CHAR): CARDINAL number of characters in the
string s.*
- SYSTEM.MAKEADR (a: CARDINAL): ADDRESS address *
- MAX (T): T maximum value of type T, with T of scalar or any real type.*
- MIN (T): T minimum value of type T, with T of scalar or any real type.*
- ODD (i: T): BOOLEAN boolean expression (i MOD 2 <> 0), for i of scalar
type T.*
- ORD (i: T): CARDINAL ordinal number of i in the set of values defined by
type T of i.*
- RE (c: T): R real-part of a complex number; result type R is either REAL if
T of type COMPLEX or of type LONGREAL is T is of type LONG-
COMPLEX.*
- SYSTEM.REGISTER (num: CARDINAL): CARDINAL (VAX) content of the
specified register. 0 <= num <= 14.
- SYSTEM.REGISTER (num: CARDINAL): SYSTEM.UNSIGNED_64 (AXP)
content of the specified integer register. 0 <= num <= 31.
- SYSTEM.ROTATE (x: T; n: INTEGER): T if n>=0 then x is rotated left by n
bits otherwise x is rotated right by n bits. (T restricted to packed sets
(BITSET) in ISO M2)*
- SYSTEM.SHIFT (x: T; n: INTEGER): T if n>=0 then x shifted to the left by n
bits otherwise to the right by n bits. (T restricted to packed sets (BITSET)
in ISO M2)*
- SIZE (v: T): CARDINAL number of storage units (LOCs) used by the
substituted variable v of type T. SIZE(T) is also allowed and returns the
number of storage units (LOCs) that would be used by a variable of type
T (v restricted to entire designator or type indentifier in ISO M2)*
- SYSTEM.SUBADR (adr: ADDRESS; offset: CARDINAL): ADDRESS
address subtraction.
- SYSTEM.TSIZE (T): CARDINAL number of storage units (bytes) assigned
to any variable of type T.*
- SYSTEM.TSIZE (T; tag1const, tag2const, ... ): CARDINAL number of
bytes used by a variable of the substituted type in the storage. If the type
is a record with variants, then tag constants of the last field-list may be
substituted in their nesting order. If no or not all tag constants are
specified, then the remaining variant with maximal size is assumed.*
- TRUNC (x: T): CARDINAL conversion from any real type T to cardinal.*
- VAL (T, i): T conversion of expression e to type T. T is either
enumeration, subrange, whole number or any real type (including
system real types).*
- Standard Procedures:
- DEC (i) is equivalent to i:=i-1, INC (i) is i:=i+1
- DEC (i,n) is i:=i-n, INC (i,n) is i:=i+n
- EXCL (s,i) is s:=s-{i}, INCL (s,i) is s:=s+{i}
- HALT terminates program execution.
- NEW and DISPOSE for storage allocation and deallocation are translated
to calls of ALLOCATE and DEALLOCATE which normally are imported
from standard library module Storage.
- SYSTEM.NEWPROCESS (p: PROC; workSpaceAdr: ADDRESS;
workSpaceSize: CARDINAL; VAR p1: PROCESS) instantiates p as a
new process p1.
- SYSTEM.TRANSFER (VAR p1, p2: PROCESS) saves process
environment in p1 and transfers control to process p2.
- SYSTEM: predeclared module (known by the compiler) features
implementation dependent
- constants: LOCSPERBYTE, LOCSPERWORD, BITSPERLOC and NOP,
- types (types marked with # are implementation specific):
- BYTE (8 bit system storage type)
- LOC (= BYTE)
- ADDRESS (32 bit address pointer = ADDRESS_32|64)
- ADDRESS_32 # (32 bit address pointer)
- ADDRESS_64 # (64 bit address pointer, MaX only)
- PROC_32 # (32 bit procedure)
- PROC_64 # (64 bit procedure, MaX only)
- PROCESS_32 # (32 bit pointer to coroutine descriptor)
- PROCESS_64 # (64 bit pointer to coroutine descriptor, MaX only)
- PROCESS (32 bit or 64 bit to coroutine descriptor)
- SHORTWORD # (16 bit system storage type)
- WORD # (32 bit system storage type)
- LONGWORD # (= WORD)
- QUADWORD # (64 bit system storage type)
- OCTAWORD # (128 bit system storage type)
- SIGNED_32 # (32 bit integer)
- SIGNED_64 # (64 bit integer, MaX only)
- UNSIGNED_32 # (32 bit unsigned integer)
- UNSIGNED_64 # (64 bit unsigned integer, MaX only)
- F_FLOATING # (VAX data type = REAL)
- D_FLOATING # (VAX data type = LONGREAL)
- G_FLOATING # (VAX 64 bit real)
- S_FLOATING # (IEEE 32 bit real, MaX only)
- T_FLOATING # (IEEE 64 bit real, MaX only)
- H_FLOATING # (VAX 128 bit real, MaX only)
- F_COMPLEX # (complex, base type F_FLOATING)
- D_COMPLEX # (complex, base type D_FLOATING)
- G_COMPLEX # (complex, base type G_FLOATING)
- S_COMPLEX # (complex, base type S_FLOATING)
- T_COMPLEX # (complex, base type T_FLOATING)
- NOP may be substituted as actual parameter in a foreign procedure call
where the formal parameter is optional. In this case NOP indicates that
no actual parameter is given (the equivalent of Pascal's Proc(...,,...) is
Proc(...,NOP,...).
- All functions and procedures of module SYSTEM are listed above in the
standard function and procedure section.
4. MaX | MVR Implementation details
Per module means per compilation unit in the following:
- fast compilation (no intermediate/interpass-file generation).
- directly generates efficient AlphaAXP | VAX-11 machine code in
OpenVMS-compatible object files.
- compilation command qualifier for generation of symbolic OpenVMS
run-time debugger information.
- symbol-file lookup-strategy allows full module name length and if not
found file name is shortened to 9 and then 6 characters.
- symbol-file lookup-strategy allows directory lists, i.e.: searches logical
MOD$LIB_LIST.
- module-name separator (default = "." in ModuleName.ProcName) is
selectable in a compilation command qualifier.
- generation of module-name & separator may be suppressed alltogether
which allows to write an implementation module for a foreign definition in
Modula-2 and also Modula-2 modules/procedures called by foreign
languages and of course vice-versa.
- subrange-, enumeration-, array index-, case label-, set index-, TRUNC,
INT, VAL conversion overflow-error checks may be enabled/disabled by
compilation qualifier or compiler directives in the source code.
- when a subrange error occurs at run-time, the program displays min &
max value of the subrange type, the actual value that caused the abort
and the procedure call trace with the error line (even when compiled with
/nodebug).
- ISO Modula-2 COMPLEX-extension plus ISO M2's complex library.
- ISO Modula-2 address arithmetic function procedures in SYSTEM.
- constant pointers constructed with SYSTEM.CAST(T,
SYSTEM.MAKEADR, const_expr) may be de-referenced in
expressions.
- supports full set of the ISO Modula-2 Standard Library plus further
OpenVMS-specific I/O-modules, number-string conversions and
trigonometric modules for VAX real type G_(FLOATING | COMPLEX):
and on AXP, IEEE real types (S | T)_(FLOATING | COMPLEX):
[S]Long(G|S|T)IO, Long(G|S|T)(Str|Conv), LongComplex(G|S|T)Math,
Long(G|S|T)Math.
- up-to 128 elements in sets, allows the declaration of e.g.: TYPE Charset
= SET OF [CHR(0)..CHR(127)] for a set of 7-Bit ASCII characters, and
set constructors of the form CONST numbers = Charset{'0'..'9'}; letters =
Charset{'A'..'Z', 'a'..'z'}; control = Charset{CHR(10), CHR(13)} and set
expressions of the form ch IN letters.
- size of arrays & records in assignments and size of static or dynamic
structured parameters may be large than 65535 bytes.
- source lines and string constants may have up-to 508 characters.
- up-to 15000 objects may be declared and exported from a (foreign)
definition module.
- optional export list; if omitted everything is exported automatically.
- up-to 15000 identifier per module (together up-to 500000 identifier
characters).
- fast SYSTEM.TRANSFER inter-process (Modula-2 coroutine) switching
with stack swap: needs only 1 microsecond on a Alpha 21064 AXP 200
MHz or 40 microseconds on a microVAXII.
- multi-dimensional open array parameter (calling sequence compatible
with Oberon-2's multi-dimensional dynamic- and open-arrays).
- structured function values of any type size (calling sequence compatible
with Oberon-2's structured functions).
- record and array constructors of the form T{expr_list} which may be
nested are allowed in expressions in declaration and statement part. For
upward compatibility reasons, aggregates with the Modula/R syntax of
the form T[expr_list] are also possible when compiled with /ISO level
less than 2.
- /RecordTypeDescriptor qualifier (AXP only) provides compatibility with
Oberon-2's procedure calling conventions for objects (hidden type
descriptor value for variable parameter of record type).
- maximum code-size of a procedure is up-to 120000 instructions (AXP)
or 120000 bytes (VAX).
- VAX: generates word-displacement branches where a
byte-displacement is too short (also when evaluating conditional
expressions).
- up-to 6000 entries (procedures/functions per module).
- up-to 2500 entries (procedures/functions to be exported per module).
- AXP: shareable image support is default through the use of procedure
descriptors. VAX: generation of procedure transfer-vectors for
shareable-images may be disabled with compilation command qualifier.
- record field alignment/allocation control for recortd types: packed and
unpacked records (compilation qualifier).
- natural alignment of global and local data.
- Mixed language programming: compatible with ModulaWare's
OpenVMS Alpha | VAX Oberon-2 Compiler and with language compilers
from DEC.
- verbatim on-line help for compilation qualifiers via OpenVMS help
command.
5. Summary of ISO Modula-2, 10154 (2nd Committee Draft,
1992) Language Extensions of ModulaWare's OpenVMS
Alpha & VAX Modula-2 Compiler:
- new type LONGREAL, COMPLEX und LONGCOMPLEX and associated
standard functions RE, IM, CMPLX, arithmetic and relational operators.
- new standard functions INT, LFLOAT, MAX, MIN, LENGTH.
- SIZE is pervasive and applies to [entire] designators and types, i.e. the
parameter of SIZE shall be either a type or a variable that must not
indexed, referenced nor selected.
- HIGH applies to open array parameters and no longer applies to static
arrays.
- standard functions can be used in constant expressions of declaration
section (including complex functions, SYSTEM.MAKEADR, and
SYSTEM.CAST).
- sets with up-to 128 elements (allows SET OF [CHR(0)..CHR(127)]).
- record- and array-constructors with BY-count in declaration section and
statement part (very large constructors are possible by using optimized
internal represention; currently CASTing of constant value constructors
is not allowed in declaration part; scan-length compression of constant
value constructors in OpenVMS object code file).
- structured function types (no size restriction).
- multi-dimensional open arrays (no size restriction).
- empty records.
- module SYSTEM: new address arithmetic functions ADDADR, SUBADR,
DIFADR, as well as MAKEADR, ROTATE, SHIFT, type LOC (=BYTE)
and constants LOCSPERBYTE, LOCSPERWORD, BITSPERLOC.
- ISO M2's generic real literal type RR: constant real literals and
expressions are evaluated with longreal precision, e.g.: with CONST
rr=1.23; rr is expression compatible with [LONG]REAL. A real constant
gets an explicit real type by using standard functions, e.g.: with CONST
x=FLOAT(1.23); x is of type REAL (which is neither expression-, nor
assignment-, nor parameter-compatible with LONGREAL).
- ISO M2's generic complex literal type CC: constant complex numbers
and expressions are evaluated with longcomplex precision, e.g.: with
CONST cc=CMPLX (1.23, 4.56); cc is expression compatible with
[LONG]COMPLEX. A complex constant gets an explicit complex type by
using standard functions, e.g.: with CONST x=CMPLX(FLOAT(1.23),
FLOAT(4.56)); x is of type COMPLEX.
- SYSTEM.ADDRESS is now POINTER to SYSTEM.LOC
(=SYSTEM.BYTE) instead of POINTER TO SYSTEM.WORD
(=SYSTEM.LONGWORD).
- any predeclared pervasive indentifier (such as REAL, FLOAT, NIL) can
now be redeclared.
- in addition to integer and cardinal operators "DIV" and "MOD" there is
now "/" and "REM".
Note that all previous MaX | MVR language features which are in conflict
with the new ISO M2 rules are still allowed by using the /NOISO
compilation qualifier.
MaX | MVR supports the full set of the ISO Modula-2 Standard Library,
but ISO Modula-2's exception reporting procedures of standard library
modules are not yet implemented (raise "notAvailable" exception).
6. Further Details about OpenVMS Modula-2:
64 bit OpenVMS Modula-2 and Oberon-2 Compiler (main page)
OpenVMS Alpha Modula-2 and Oberon-2 Compiler -- Implementation Notes
64 bit Modula-2 for OpenVMS Alpha -- Implementation Notes
Migration of 32 bit Modula-2 programs to 64 bit on OpenVMS Alpha
New: Since 01-Mar-1999, the latest version of Compaq's (formerly Digital)
64 bit OpenVMS Alpha V7.2 is free for personal use;
see latest news section in What is a 64 bit Compiler?.
Home |
Site_index |
Contact |
Legal |
Buy_products |
OpenVMS_compiler |
Alpha_Oberon_System |
XDS_family |
DOS_compiler |
ModulaTor |
Bibliography |
Oberon[-2]_links |
Modula-2_links |
Onduleurs
Webdesign by www.otolo.com/webworx,
20-Mar-1999. © (1998-1999) ModulaWare.com