modula-2 home

  Home  
  Tutorial  
  Win32 API  
  Reference  
  Projects  
 

 
DEFINITION MODULE SYSTEM;
 
  (* Gives access to system programming facilities that are probably non portable. *)
 
  (* The constants and types define underlying properties of storage *)
 
CONST
  BITSPERLOC    = <implementation-defined constant> ;
  LOCSPERWORD   = <implementation-defined constant> ;
 
TYPE
  LOC; (* A system basic type. Values are the uninterpreted contents of the smallest
          addressable unit of storage *)
  ADDRESS = POINTER TO LOC;
  WORD = ARRAY [0 .. LOCSPERWORD-1] OF LOC;
 
  (* BYTE and LOCSPERBYTE are provided if appropriate for machine *)
CONST
  LOCSPERBYTE = <implementation-defined constant> ;
 
TYPE
  BYTE = ARRAY [0 .. LOCSPERBYTE-1] OF LOC;
 
PROCEDURE ADDADR (addr: ADDRESS; offset: CARDINAL): ADDRESS;
  (* Returns address given by (addr + offset), or may raise an exception if this
     address is not valid.
  *)
 
PROCEDURE SUBADR (addr: ADDRESS; offset: CARDINAL): ADDRESS;
  (* Returns address given by (addr - offset), or may raise an exception if this address
     is not valid.
  *)
 
PROCEDURE DIFADR (addr1, addr2: ADDRESS): INTEGER;
  (* Returns the difference between addresses (addr1 - addr2), or may raise an exception
     if the arguments are invalid or if the address space is non-contiguous.
  *)
 
PROCEDURE MAKEADR (val: <some type>; ... ): ADDRESS;
  (* Returns an address constructed from a list of values whose types are
     implementation-defined, or may raise an exception if this address is not valid.
  *)
 
PROCEDURE ADR (VAR v: <anytype>): ADDRESS;
  (* Returns the address of variable v. *)
 
PROCEDURE ROTATE (val: <a packedset type>; num: INTEGER): <type of first parameter>;
  (* Returns a bit sequence obtained from val by rotating up or down (left or right) by
     the absolute value of num.  The direction is down if the sign of num is negative,
     otherwise the direction is up.
  *)
 
PROCEDURE SHIFT (val: <a packedset type>; num: INTEGER): <type of first parameter>;
  (* Returns a bit sequence obtained from val by shifting up or down (left or right) by
     the absolute value of num, introducing zeros as necessary.  The direction is down
     if the sign of num is negative, otherwise the direction is up.
  *)
 
PROCEDURE CAST (<targettype>; val: <anytype>): <targettype>;
  (* CAST is a type transfer function.  Given the expression denoted by val, it returns
     a value of the type <targettype>.  An invalid value for the target value or a
     physical address alignment problem may raise an exception.
  *)
 
PROCEDURE TSIZE (<type>; ... ): CARDINAL;
  (* Returns the number of LOCS used to store a value of the specified <type>.   The
     extra parameters, if present, are used to distinguish variants in a variant record.
  *)
 
END SYSTEM.