mainly new comments

This commit is contained in:
ceriel 1988-02-19 15:54:01 +00:00
parent 96fc577b15
commit 31ddd5ca12
61 changed files with 529 additions and 58 deletions

View file

@ -15,7 +15,6 @@ RealConver.def
Semaphores.def
Storage.def
Strings.def
TTY.def
Terminal.def
Unix.def
head_m2.e

View file

@ -1,4 +1,10 @@
(*$Foreign*)
DEFINITION MODULE ASCII;
(*
Module: Mnemonics for ASCII control characters
From: ???
Version: $Header$
*)
CONST
nul = 00C; soh = 01C; stx = 02C; etx = 03C;

View file

@ -1,3 +1,14 @@
/*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/*
Module: Access to program arguments and environment
Author: Ceriel J.H. Jacobs
Version: $Header$
*/
extern char **_argv, **_environ;
extern int _argc;
unsigned int Arguments_Argc;

View file

@ -1,6 +1,8 @@
DEFINITION MODULE Arguments;
(* Routines and variables to access the programs arguments and
environment
(*
Module: Access to program arguments and environment
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
VAR Argc: CARDINAL; (* Number of program arguments, including the program

View file

@ -1,3 +1,8 @@
(*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*)
(*$R-*)
IMPLEMENTATION MODULE ArraySort;
(*
@ -21,6 +26,7 @@ IMPLEMENTATION MODULE ArraySort;
END Sort;
PROCEDURE qsort(a1, a2: ADDRESS; size: CARDINAL);
(* Implemented with quick-sort, with some extra's *)
VAR left, right, lefteq, righteq: ADDRESS;
cmp: CompareResult;
mainloop: BOOLEAN;

View file

@ -1,8 +1,10 @@
DEFINITION MODULE CSP;
(* From
"A Modula-2 Implementation of CSP",
M. Collado, R. Morales, J.J. Moreno,
SIGPlan Notices, Volume 22, Number 6, June 1987.
(*
Module: Communicating Sequential Processes
From: "A Modula-2 Implementation of CSP",
M. Collado, R. Morales, J.J. Moreno,
SIGPlan Notices, Volume 22, Number 6, June 1987.
Version: $Header$
See this article for an explanation of the use of this module.
*)

View file

@ -1,9 +1,12 @@
(*$R-*)
IMPLEMENTATION MODULE CSP;
(* From
"A Modula-2 Implementation of CSP",
M. Collado, R. Morales, J.J. Moreno,
SIGPlan Notices, Volume 22, Number 6, June 1987.
(*
Module: Communicating Sequential Processes
From: "A Modula-2 Implementation of CSP",
M. Collado, R. Morales, J.J. Moreno,
SIGPlan Notices, Volume 22, Number 6, June 1987.
Some modifications by Ceriel J.H. Jacobs
Version: $Header$
See this article for an explanation of the use of this module.
*)

View file

@ -1,4 +1,13 @@
#include <m2_traps.h>
;
; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
; See the copyright notice in the ACK home directory, in the file "Copyright".
;
;
; Module: CARDINAL operations with overflow checking
; Author: Ceriel J.H. Jacobs
; Version: $Header$
;
mes 2,EM_WSIZE,EM_PSIZE

View file

@ -1,4 +1,9 @@
DEFINITION MODULE Conversions;
(*
Module: Numeric-to-string conversions
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
PROCEDURE ConvertOctal(num, len: CARDINAL; VAR str: ARRAY OF CHAR);
(* Convert number "num" to right-justified octal representation of

View file

@ -1,5 +1,15 @@
(*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*)
(*$R-*)
IMPLEMENTATION MODULE Conversions;
(*
Module: numeric-to-string conversions
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
PROCEDURE ConvertNum(num, len, base: CARDINAL;
neg: BOOLEAN;

View file

@ -1,6 +1,10 @@
(*$Foreign *)
DEFINITION MODULE EM;
(* An interface to EM instructions and data *)
(*
Module: Interface to some EM instructions and data
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
FROM SYSTEM IMPORT ADDRESS;
@ -20,8 +24,15 @@ DEFINITION MODULE EM;
(* Generate EM trap number "trapno" *)
PROCEDURE SIG(t: TrapHandler): TrapHandler;
(* install traphandler t; return previous handler *)
PROCEDURE FILN(): ADDRESS;
(* return current program file-name. This only works if file-name
and line-number generation is not disabled during compilation
*)
PROCEDURE LINO(): INTEGER;
(* return current program line-number. This only works if file-name
and line-number generation is not disabled during compilation
*)
END EM.

View file

@ -1,4 +1,13 @@
#
;
; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
; See the copyright notice in the ACK home directory, in the file "Copyright".
;
;
; Module: Interface to some EM instructions and data
; Author: Ceriel J.H. Jacobs
; Version: $Header$
;
mes 2,EM_WSIZE,EM_PSIZE
#define ARG1 0

View file

@ -1,6 +1,12 @@
(*$Foreign*)
DEFINITION MODULE Epilogue;
(* MODULA-2 offers a facility for the initialization of modules, but there
(*
Module: install module termination procedures to be called at
program termination
Author: Ceriel J.H. Jacobs
Version: $Header$
MODULA-2 offers a facility for the initialization of modules, but there
is no mechanism to have some code executed when the program finishes.
This module is a feeble attempt at solving this problem.
*)

View file

@ -1,4 +1,9 @@
DEFINITION MODULE InOut;
(*
Module: Wirth's Input/Output module
From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
Version: $Header$
*)
CONST EOL = 12C;
@ -23,11 +28,13 @@ DEFINITION MODULE InOut;
*)
PROCEDURE OpenInputFile(filename: ARRAY OF CHAR);
(* Like OpenInput, but filename given as parameter
(* Like OpenInput, but filename given as parameter.
This procedure is not in Wirth's InOut.
*)
PROCEDURE OpenOutputFile(filename: ARRAY OF CHAR);
(* Like OpenOutput, but filename given as parameter
(* Like OpenOutput, but filename given as parameter.
This procedure is not in Wirth's InOut.
*)
PROCEDURE CloseInput;

View file

@ -1,10 +1,19 @@
(*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*)
(*$R-*)
IMPLEMENTATION MODULE InOut ;
(*
Module: Wirth's Input/Output module
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
IMPORT Streams;
IMPORT Conversions;
IMPORT Traps;
FROM TTY IMPORT isatty;
CONST TAB = 11C;
@ -123,7 +132,7 @@ IMPLEMENTATION MODULE InOut ;
j : CARDINAL;
BEGIN
Done := TRUE;
IF isatty(0) THEN
IF isatty(Streams.InputStream) THEN
XWriteString(prompt);
END;
XReadString(buf);

View file

@ -5,8 +5,6 @@ RealInOut.mod
InOut.mod
Streams.mod
Terminal.mod
TTY.mod
ASCII.mod
MathLib0.mod
Mathlib.mod
Processes.mod

View file

@ -1,4 +1,13 @@
#
;
; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
; See the copyright notice in the ACK home directory, in the file "Copyright".
;
;
; Module: Compute non-constant set displays
; Author: Ceriel J.H. Jacobs
; Version: $Header$
;
mes 2,EM_WSIZE,EM_PSIZE
; _LtoUset is called for set displays containing { expr1 .. expr2 }.

View file

@ -4,7 +4,7 @@ DEFDIR = $(HOME)/lib/m2
SOURCES = ASCII.def EM.def MathLib0.def Processes.def \
RealInOut.def Storage.def Arguments.def Conversion.def \
random.def Semaphores.def Unix.def RealConver.def \
Strings.def InOut.def Terminal.def TTY.def \
Strings.def InOut.def Terminal.def \
Mathlib.def PascalIO.def Traps.def CSP.def \
Epilogue.def Streams.def ArraySort.def

View file

@ -1,5 +1,9 @@
DEFINITION MODULE MathLib0;
(*
Module: Some mathematical functions
From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
Version: $Header$
Exists for compatibility.
A more elaborate math lib can be found in Mathlib.def
*)

View file

@ -1,5 +1,15 @@
(*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*)
(*$R-*)
IMPLEMENTATION MODULE MathLib0;
(*
Module: Some mathematical functions
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
IMPORT Mathlib;

View file

@ -1,4 +1,9 @@
DEFINITION MODULE Mathlib;
(*
Module: Mathematical functions
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
(* Some mathematical constants: *)

View file

@ -1,5 +1,15 @@
(*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*)
(*$R-*)
IMPLEMENTATION MODULE Mathlib;
(*
Module: Mathematical functions
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
FROM EM IMPORT FIF, FEF;
FROM Traps IMPORT Message;

View file

@ -1,3 +1,8 @@
(*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*)
(*$R-*)
IMPLEMENTATION MODULE PascalIO;
(*

View file

@ -1,4 +1,9 @@
DEFINITION MODULE Processes;
(*
Module: Processes
From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
Version: $Header$
*)
TYPE SIGNAL;

View file

@ -1,8 +1,9 @@
(*$R-*)
IMPLEMENTATION MODULE Processes [1];
(* This implementation module comes from
"Programming in Modula-2", by Niklaus Wirth,
3rd edition, Springer-Verlag, New York, 1985
(*
Module: Processes
From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
Version: $Header$
*)
FROM SYSTEM IMPORT ADDRESS, TSIZE, NEWPROCESS, TRANSFER;

View file

@ -1,4 +1,9 @@
DEFINITION MODULE RealConversions;
(*
Module: string-to-real and real-to-string conversions
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
PROCEDURE StringToReal(str: ARRAY OF CHAR; VAR r: REAL; VAR ok: BOOLEAN);
(* Convert string "str" to a real number "r" according to the syntax:

View file

@ -1,5 +1,15 @@
(*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*)
(*$R-*)
IMPLEMENTATION MODULE RealConversions;
(*
Module: string-to-real and real-to-string conversions
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
FROM EM IMPORT FIF;

View file

@ -1,4 +1,9 @@
DEFINITION MODULE RealInOut;
(*
Module: InOut for REAL numbers
From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
Version: $Header$
*)
VAR Done: BOOLEAN;

View file

@ -1,5 +1,15 @@
(*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*)
(*$R-*)
IMPLEMENTATION MODULE RealInOut;
(*
Module: InOut for REAL numbers
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
IMPORT InOut;
IMPORT RealConversions;

View file

@ -1,4 +1,12 @@
DEFINITION MODULE Semaphores;
(*
Module: Processes with semaphores
Author: Ceriel J.H. Jacobs
Version: $Header$
On systems using quasi-concurrency, the only opportunities for process-
switches are calls to Down and Up.
*)
TYPE Sema;
@ -12,12 +20,10 @@ DEFINITION MODULE Semaphores;
(* If the value of "s" is > 0, then just decrement "s".
Else, suspend the current process until the semaphore becomes
positive again.
May result in a process switch.
*)
PROCEDURE Up(VAR s: Sema);
(* Increment the semaphore "s".
This call may result in a process switch
*)
PROCEDURE StartProcess(P: PROC; n: CARDINAL);

View file

@ -1,5 +1,17 @@
(*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*)
(*$R-*)
IMPLEMENTATION MODULE Semaphores [1];
(*
Module: Processes with semaphores
Author: Ceriel J.H. Jacobs
Version: $Header$
Quasi-concurrency implementation
*)
FROM SYSTEM IMPORT ADDRESS, NEWPROCESS, TRANSFER;
FROM Storage IMPORT ALLOCATE;

View file

@ -1,4 +1,9 @@
DEFINITION MODULE Storage;
(*
Module: Dynamic storage allocation
From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
Version: $Header$
*)
FROM SYSTEM IMPORT ADDRESS;

View file

@ -1,5 +1,16 @@
(*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*)
(*$R-*)
IMPLEMENTATION MODULE Storage;
(*
Module: Dynamic Storage Allocation
Author: Ceriel J.H. Jacobs
Adapted from a version in C by Hans Tebra
Version: $Header$
*)
(* This storage manager maintains an array of lists of objects with the
same size. Commonly used sizes have their own bucket. The larger ones
are put in a single list.

View file

@ -1,3 +1,14 @@
/*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/*
Module: assign string to character array, with possible 0-byte
extension
Author: Ceriel J.H. Jacobs
Version: $Header$
*/
_StringAssign(dstsiz, srcsiz, dstaddr, srcaddr)
register char *dstaddr, *srcaddr;
{
@ -6,8 +17,7 @@ _StringAssign(dstsiz, srcsiz, dstaddr, srcaddr)
srcsiz--;
dstsiz--;
}
while (dstsiz > 0) {
*dstaddr++ = 0;
dstsiz--;
if (dstsiz > 0) {
*dstaddr = 0;
}
}

View file

@ -1,5 +1,9 @@
DEFINITION MODULE Streams;
(*
Module: Stream Input/Output
Author: Ceriel J.H. Jacobs
Version: $Header$
* This module provides sequential IO through streams.
* A stream is either a text stream or a binary stream, and is either in
* reading, writing or appending mode.
@ -134,10 +138,16 @@ DEFINITION MODULE Streams;
position: LONGINT;
VAR result: StreamResult);
(* sets the actual read/write position to "position".
"result" is set to illegaloperation if "stream" is not a stream or
the stream was opened for appending and the position is in front of
the current position, or it failed for some other
reason (f.i. when the stream is connected to a terminal).
"result" is set to nostream if "stream" is not a stream.
It is set to illegaloperation if the stream was opened for appending and
the position is in front of the current position, or it failed for some
other reason (f.i. when the stream is connected to a terminal).
*)
PROCEDURE isatty(stream: Stream; VAR result: StreamResult): BOOLEAN;
(* return TRUE if the stream is connected to a terminal.
"result" is set to nostream if "stream" is not a stream, and
set to illegaloperation if the operation failed for some other reason.
*)
END Streams.

View file

@ -1,8 +1,21 @@
#
(*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*)
(*$R-*)
IMPLEMENTATION MODULE Streams;
(*
Module: Stream Input/Output
Author: Ceriel J.H. Jacobs
Version: $Header$
Implementation for Unix
*)
FROM SYSTEM IMPORT BYTE, ADR;
IMPORT Unix, TTY, Storage, Epilogue;
IMPORT Unix, Storage, Epilogue;
CONST BUFSIZ = 1024; (* tunable *)
TYPE IOB = RECORD
@ -332,7 +345,7 @@ IMPLEMENTATION MODULE Streams;
BEGIN
currpos := 0D;
IF (s = NIL) OR (s^.kind = none) THEN
result := illegaloperation;
result := nostream;
RETURN;
END;
IF (s^.mode # reading) THEN
@ -360,6 +373,24 @@ IMPLEMENTATION MODULE Streams;
result := succeeded;
END SetPosition;
PROCEDURE isatty(stream: Stream): BOOLEAN;
VAR buf: ARRAY[1..100] OF CHAR;
BEGIN
IF (stream = NIL) OR (s^.kind = none) THEN
result := nostream;
RETURN FALSE;
END;
#ifdef __USG
RETURN ioctl(stream^.fildes, INTEGER(ORD('T') * 256 + 1), ADR(buf)) >= 0;
#else
#ifdef __BSD4_2
RETURN ioctl(stream^.fildes, INTEGER(ORD('t') * 256 + 8 + 6*65536 + 40000000H), ADR(buf)) >= 0;
#else
RETURN ioctl(stream^.fildes, INTEGER(ORD('t') * 256 + 8), ADR(buf)) >= 0;
#endif
#endif
END isatty;
BEGIN
InputStream := ADR(ibuf);
OutputStream := ADR(obuf);
@ -383,7 +414,7 @@ BEGIN
maxcnt := 0;
cnt := 0;
bufferedcnt := BUFSIZ;
IF TTY.isatty(1) THEN
IF isatty(OutputStream) THEN
buffering := linebuffered;
ELSE
buffering := blockbuffered;
@ -398,7 +429,7 @@ BEGIN
maxcnt := 0;
cnt := 0;
bufferedcnt := BUFSIZ;
IF TTY.isatty(2) THEN
IF isatty(ErrorStream) THEN
buffering := linebuffered;
ELSE
buffering := blockbuffered;

View file

@ -1,4 +1,9 @@
DEFINITION MODULE Strings;
(*
Module: String manipulations
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
(* Note: truncation of strings may occur if the user does not provide
large enough variables to contain the result of the operation.
*)

View file

@ -1,5 +1,15 @@
(*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*)
(*$R-*)
IMPLEMENTATION MODULE Strings;
(*
Module: String manipulations
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
PROCEDURE Assign(source: ARRAY OF CHAR; VAR dest: ARRAY OF CHAR);
(* Assign string source to dest

View file

@ -1,4 +1,9 @@
DEFINITION MODULE Terminal;
(*
Module: Input/Output to/from terminals
From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
Version: $Header$
*)
PROCEDURE Read(VAR ch : CHAR);
(* Read a character from the terminal and leave it in ch

View file

@ -1,7 +1,17 @@
#
(*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*)
(*$R-*)
IMPLEMENTATION MODULE Terminal;
(* This implementation is Unix-dependant
(*
Module: Input/Output to/from terminals
Author: Ceriel J.H. Jacobs
Version: $Header$
Implementation for Unix.
*)
IMPORT Unix;
FROM SYSTEM IMPORT ADR;

View file

@ -1,4 +1,9 @@
DEFINITION MODULE Traps;
(*
Module: Facility for handling traps
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
IMPORT EM;

View file

@ -1,5 +1,16 @@
(*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*)
(*$R-*)
IMPLEMENTATION MODULE Traps;
(*
Module: Facility for handling traps
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
IMPORT EM;
IMPORT Unix;
FROM SYSTEM IMPORT ADDRESS, ADR;

View file

@ -1,6 +1,10 @@
(*$Foreign language module *)
DEFINITION MODULE Unix;
(* An interface to some Unix system-calls *)
(*
Module: interface to some Unix systemcalls
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
FROM SYSTEM IMPORT WORD, ADDRESS;
(* Type needed for Signal *)

View file

@ -1,3 +1,13 @@
/*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/*
Module: double abs function
Author: Ceriel J.H. Jacobs
Version: $Header$
*/
#ifndef NOFLOAT
double
_absd(i)

View file

@ -1,4 +1,13 @@
#
;
; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
; See the copyright notice in the ACK home directory, in the file "Copyright".
;
;
; Module: REAL abs function
; Author: Ceriel J.H. Jacobs
; Version: $Header$
;
mes 2,EM_WSIZE,EM_PSIZE
exp $_absf
pro $_absf,0

View file

@ -1,3 +1,14 @@
/*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/*
Module: integer abs function
Author: Ceriel J.H. Jacobs
Version: $Header$
*/
_absi(i)
{
return i >= 0 ? i : -i;

View file

@ -1,3 +1,13 @@
/*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/*
Module: longint abs function
Author: Ceriel J.H. Jacobs
Version: $Header$
*/
long
_absl(i)
long i;

View file

@ -1,3 +1,13 @@
/*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/*
Module: default modula-2 trap handler
Author: Ceriel J.H. Jacobs
Version: $Header$
*/
#include <em_abs.h>
#include <m2_traps.h>

View file

@ -1,3 +1,13 @@
/*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/*
Module: runtime support for conformant arrays
Author: Ceriel J.H. Jacobs
Version: $Header$
*/
#include <m2_traps.h>
struct descr {

View file

@ -1,3 +1,13 @@
/*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/*
Module: program termination routines
Author: Ceriel J.H. Jacobs
Version: $Header$
*/
#define MAXPROCS 16
static int callindex;

View file

@ -1,22 +1,13 @@
#
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
/* Author: C.J.H. Jacobs */
;
; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
; See the copyright notice in the ACK home directory, in the file "Copyright".
;
;
; Module: Modula-2 runtime startoff
; Author: Ceriel J.H. Jacobs
; Version: $Header$
;
mes 2,EM_WSIZE,EM_PSIZE

View file

@ -1,3 +1,13 @@
/*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/*
Module: get value on stack, byte by byte
Author: Ceriel J.H. Jacobs
Version: $Header$
*/
_load(siz, addr, p)
register char *addr;
register int siz;

View file

@ -1,4 +1,9 @@
DEFINITION MODULE random;
(*
Module: random numbers
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
PROCEDURE Random(): CARDINAL;
(* Return a random CARDINAL
@ -9,4 +14,9 @@ PROCEDURE Uniform (lwb, upb: CARDINAL): CARDINAL;
"lwb" must be smaller than "upb", or "lwb" is returned.
*)
PROCEDURE StartSeed(seed: CARDINAL);
(* Initialize the generator. You don't have to call this procedure, unless
you don't want the system to pick a starting value for itself.
*)
END random.

View file

@ -1,5 +1,15 @@
(*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*)
(*$R-*)
IMPLEMENTATION MODULE random;
(*
Module: random numbers
Author: Ceriel J.H. Jacobs
Version: $Header$
*)
FROM Unix IMPORT getpid, time;
TYPE index = [0..54];
@ -21,12 +31,17 @@ BEGIN
RETURN lwb + (Random() MOD (upb - lwb + 1));
END Uniform;
PROCEDURE StartSeed(seed: CARDINAL);
BEGIN
X[0] := time(NIL);
X[0] := CARDINAL(getpid()) * X[0];
X[0] := seed;
FOR k := 1 TO 54 DO
X[k] := X[k-1] * 1297;
END;
k := 54;
j := 30;
END StartSeed;
BEGIN
X0 := time(NIL);
StartSeed(CARDINAL(getpid()) * X[0]);
END random.

View file

@ -1,4 +1,13 @@
#
;
; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
; See the copyright notice in the ACK home directory, in the file "Copyright".
;
;
; Module: range checks for INTEGER
; Author: Ceriel J.H. Jacobs
; Version: $Header$
;
#include <em_abs.h>
mes 2,EM_WSIZE,EM_PSIZE

View file

@ -1,4 +1,13 @@
#
;
; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
; See the copyright notice in the ACK home directory, in the file "Copyright".
;
;
; Module: range checks for LONGINTS
; Author: Ceriel J.H. Jacobs
; Version: $Header$
;
#include <em_abs.h>
mes 2,EM_WSIZE,EM_PSIZE

View file

@ -1,4 +1,13 @@
#
;
; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
; See the copyright notice in the ACK home directory, in the file "Copyright".
;
;
; Module: range checks for CARDINAL
; Author: Ceriel J.H. Jacobs
; Version: $Header$
;
#include <em_abs.h>
mes 2,EM_WSIZE,EM_PSIZE

View file

@ -1,4 +1,13 @@
#
;
; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
; See the copyright notice in the ACK home directory, in the file "Copyright".
;
;
; Module: Range checks for LONGCARD
; Author: Ceriel J.H. Jacobs
; Version: $Header$
;
#include <em_abs.h>
mes 2,EM_WSIZE,EM_PSIZE

View file

@ -1,3 +1,13 @@
/*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/*
Module: Dummy priority routines
Author: Ceriel J.H. Jacobs
Version: $Header$
*/
_stackprio(n)
{
}

View file

@ -1,3 +1,13 @@
/*
(c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/*
Module: store values from stack, byte by byte
Author: Ceriel J.H. Jacobs
Version: $Header$
*/
_store(siz, addr, p)
register char *addr;
register int siz;

View file

@ -1,4 +1,16 @@
#
;
; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
; See the copyright notice in the ACK home directory, in the file "Copyright".
;
;
; Module: implementation of coroutines
; Author: Ceriel J.H. Jacobs
; Version: $Header$
;
; This version works for EM implementations that have a contiguous downwards
; growing stack, on which data below the stack-pointer is not destroyed.
;
#include <em_mes.h>
#include <m2_traps.h>