mainly new comments
This commit is contained in:
parent
96fc577b15
commit
31ddd5ca12
|
@ -15,7 +15,6 @@ RealConver.def
|
||||||
Semaphores.def
|
Semaphores.def
|
||||||
Storage.def
|
Storage.def
|
||||||
Strings.def
|
Strings.def
|
||||||
TTY.def
|
|
||||||
Terminal.def
|
Terminal.def
|
||||||
Unix.def
|
Unix.def
|
||||||
head_m2.e
|
head_m2.e
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
|
(*$Foreign*)
|
||||||
DEFINITION MODULE ASCII;
|
DEFINITION MODULE ASCII;
|
||||||
|
(*
|
||||||
|
Module: Mnemonics for ASCII control characters
|
||||||
|
From: ???
|
||||||
|
Version: $Header$
|
||||||
|
*)
|
||||||
|
|
||||||
CONST
|
CONST
|
||||||
nul = 00C; soh = 01C; stx = 02C; etx = 03C;
|
nul = 00C; soh = 01C; stx = 02C; etx = 03C;
|
||||||
|
|
|
@ -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 char **_argv, **_environ;
|
||||||
extern int _argc;
|
extern int _argc;
|
||||||
unsigned int Arguments_Argc;
|
unsigned int Arguments_Argc;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
DEFINITION MODULE Arguments;
|
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
|
VAR Argc: CARDINAL; (* Number of program arguments, including the program
|
||||||
|
|
|
@ -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-*)
|
(*$R-*)
|
||||||
IMPLEMENTATION MODULE ArraySort;
|
IMPLEMENTATION MODULE ArraySort;
|
||||||
(*
|
(*
|
||||||
|
@ -21,6 +26,7 @@ IMPLEMENTATION MODULE ArraySort;
|
||||||
END Sort;
|
END Sort;
|
||||||
|
|
||||||
PROCEDURE qsort(a1, a2: ADDRESS; size: CARDINAL);
|
PROCEDURE qsort(a1, a2: ADDRESS; size: CARDINAL);
|
||||||
|
(* Implemented with quick-sort, with some extra's *)
|
||||||
VAR left, right, lefteq, righteq: ADDRESS;
|
VAR left, right, lefteq, righteq: ADDRESS;
|
||||||
cmp: CompareResult;
|
cmp: CompareResult;
|
||||||
mainloop: BOOLEAN;
|
mainloop: BOOLEAN;
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
DEFINITION MODULE CSP;
|
DEFINITION MODULE CSP;
|
||||||
(* From
|
(*
|
||||||
"A Modula-2 Implementation of CSP",
|
Module: Communicating Sequential Processes
|
||||||
|
From: "A Modula-2 Implementation of CSP",
|
||||||
M. Collado, R. Morales, J.J. Moreno,
|
M. Collado, R. Morales, J.J. Moreno,
|
||||||
SIGPlan Notices, Volume 22, Number 6, June 1987.
|
SIGPlan Notices, Volume 22, Number 6, June 1987.
|
||||||
|
Version: $Header$
|
||||||
|
|
||||||
See this article for an explanation of the use of this module.
|
See this article for an explanation of the use of this module.
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
(*$R-*)
|
(*$R-*)
|
||||||
IMPLEMENTATION MODULE CSP;
|
IMPLEMENTATION MODULE CSP;
|
||||||
(* From
|
(*
|
||||||
"A Modula-2 Implementation of CSP",
|
Module: Communicating Sequential Processes
|
||||||
|
From: "A Modula-2 Implementation of CSP",
|
||||||
M. Collado, R. Morales, J.J. Moreno,
|
M. Collado, R. Morales, J.J. Moreno,
|
||||||
SIGPlan Notices, Volume 22, Number 6, June 1987.
|
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.
|
See this article for an explanation of the use of this module.
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -1,4 +1,13 @@
|
||||||
#include <m2_traps.h>
|
#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
|
mes 2,EM_WSIZE,EM_PSIZE
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
DEFINITION MODULE Conversions;
|
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);
|
PROCEDURE ConvertOctal(num, len: CARDINAL; VAR str: ARRAY OF CHAR);
|
||||||
(* Convert number "num" to right-justified octal representation of
|
(* Convert number "num" to right-justified octal representation of
|
||||||
|
|
|
@ -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-*)
|
(*$R-*)
|
||||||
IMPLEMENTATION MODULE Conversions;
|
IMPLEMENTATION MODULE Conversions;
|
||||||
|
(*
|
||||||
|
Module: numeric-to-string conversions
|
||||||
|
Author: Ceriel J.H. Jacobs
|
||||||
|
Version: $Header$
|
||||||
|
*)
|
||||||
|
|
||||||
PROCEDURE ConvertNum(num, len, base: CARDINAL;
|
PROCEDURE ConvertNum(num, len, base: CARDINAL;
|
||||||
neg: BOOLEAN;
|
neg: BOOLEAN;
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
(*$Foreign *)
|
(*$Foreign *)
|
||||||
DEFINITION MODULE EM;
|
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;
|
FROM SYSTEM IMPORT ADDRESS;
|
||||||
|
|
||||||
|
@ -20,8 +24,15 @@ DEFINITION MODULE EM;
|
||||||
(* Generate EM trap number "trapno" *)
|
(* Generate EM trap number "trapno" *)
|
||||||
|
|
||||||
PROCEDURE SIG(t: TrapHandler): TrapHandler;
|
PROCEDURE SIG(t: TrapHandler): TrapHandler;
|
||||||
|
(* install traphandler t; return previous handler *)
|
||||||
|
|
||||||
PROCEDURE FILN(): ADDRESS;
|
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;
|
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.
|
END EM.
|
||||||
|
|
|
@ -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
|
mes 2,EM_WSIZE,EM_PSIZE
|
||||||
|
|
||||||
#define ARG1 0
|
#define ARG1 0
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
(*$Foreign*)
|
(*$Foreign*)
|
||||||
DEFINITION MODULE Epilogue;
|
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.
|
is no mechanism to have some code executed when the program finishes.
|
||||||
This module is a feeble attempt at solving this problem.
|
This module is a feeble attempt at solving this problem.
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
DEFINITION MODULE InOut;
|
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;
|
CONST EOL = 12C;
|
||||||
|
|
||||||
|
@ -23,11 +28,13 @@ DEFINITION MODULE InOut;
|
||||||
*)
|
*)
|
||||||
|
|
||||||
PROCEDURE OpenInputFile(filename: ARRAY OF CHAR);
|
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);
|
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;
|
PROCEDURE CloseInput;
|
||||||
|
|
|
@ -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-*)
|
(*$R-*)
|
||||||
IMPLEMENTATION MODULE InOut ;
|
IMPLEMENTATION MODULE InOut ;
|
||||||
|
(*
|
||||||
|
Module: Wirth's Input/Output module
|
||||||
|
Author: Ceriel J.H. Jacobs
|
||||||
|
Version: $Header$
|
||||||
|
*)
|
||||||
|
|
||||||
IMPORT Streams;
|
IMPORT Streams;
|
||||||
IMPORT Conversions;
|
IMPORT Conversions;
|
||||||
IMPORT Traps;
|
IMPORT Traps;
|
||||||
FROM TTY IMPORT isatty;
|
|
||||||
|
|
||||||
CONST TAB = 11C;
|
CONST TAB = 11C;
|
||||||
|
|
||||||
|
@ -123,7 +132,7 @@ IMPLEMENTATION MODULE InOut ;
|
||||||
j : CARDINAL;
|
j : CARDINAL;
|
||||||
BEGIN
|
BEGIN
|
||||||
Done := TRUE;
|
Done := TRUE;
|
||||||
IF isatty(0) THEN
|
IF isatty(Streams.InputStream) THEN
|
||||||
XWriteString(prompt);
|
XWriteString(prompt);
|
||||||
END;
|
END;
|
||||||
XReadString(buf);
|
XReadString(buf);
|
||||||
|
|
|
@ -5,8 +5,6 @@ RealInOut.mod
|
||||||
InOut.mod
|
InOut.mod
|
||||||
Streams.mod
|
Streams.mod
|
||||||
Terminal.mod
|
Terminal.mod
|
||||||
TTY.mod
|
|
||||||
ASCII.mod
|
|
||||||
MathLib0.mod
|
MathLib0.mod
|
||||||
Mathlib.mod
|
Mathlib.mod
|
||||||
Processes.mod
|
Processes.mod
|
||||||
|
|
|
@ -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
|
mes 2,EM_WSIZE,EM_PSIZE
|
||||||
|
|
||||||
; _LtoUset is called for set displays containing { expr1 .. expr2 }.
|
; _LtoUset is called for set displays containing { expr1 .. expr2 }.
|
||||||
|
|
|
@ -4,7 +4,7 @@ DEFDIR = $(HOME)/lib/m2
|
||||||
SOURCES = ASCII.def EM.def MathLib0.def Processes.def \
|
SOURCES = ASCII.def EM.def MathLib0.def Processes.def \
|
||||||
RealInOut.def Storage.def Arguments.def Conversion.def \
|
RealInOut.def Storage.def Arguments.def Conversion.def \
|
||||||
random.def Semaphores.def Unix.def RealConver.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 \
|
Mathlib.def PascalIO.def Traps.def CSP.def \
|
||||||
Epilogue.def Streams.def ArraySort.def
|
Epilogue.def Streams.def ArraySort.def
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
DEFINITION MODULE MathLib0;
|
DEFINITION MODULE MathLib0;
|
||||||
(*
|
(*
|
||||||
|
Module: Some mathematical functions
|
||||||
|
From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
|
||||||
|
Version: $Header$
|
||||||
|
|
||||||
Exists for compatibility.
|
Exists for compatibility.
|
||||||
A more elaborate math lib can be found in Mathlib.def
|
A more elaborate math lib can be found in Mathlib.def
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -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-*)
|
(*$R-*)
|
||||||
IMPLEMENTATION MODULE MathLib0;
|
IMPLEMENTATION MODULE MathLib0;
|
||||||
|
(*
|
||||||
|
Module: Some mathematical functions
|
||||||
|
Author: Ceriel J.H. Jacobs
|
||||||
|
Version: $Header$
|
||||||
|
*)
|
||||||
|
|
||||||
IMPORT Mathlib;
|
IMPORT Mathlib;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
DEFINITION MODULE Mathlib;
|
DEFINITION MODULE Mathlib;
|
||||||
|
(*
|
||||||
|
Module: Mathematical functions
|
||||||
|
Author: Ceriel J.H. Jacobs
|
||||||
|
Version: $Header$
|
||||||
|
*)
|
||||||
|
|
||||||
(* Some mathematical constants: *)
|
(* Some mathematical constants: *)
|
||||||
|
|
||||||
|
|
|
@ -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-*)
|
(*$R-*)
|
||||||
IMPLEMENTATION MODULE Mathlib;
|
IMPLEMENTATION MODULE Mathlib;
|
||||||
|
(*
|
||||||
|
Module: Mathematical functions
|
||||||
|
Author: Ceriel J.H. Jacobs
|
||||||
|
Version: $Header$
|
||||||
|
*)
|
||||||
|
|
||||||
FROM EM IMPORT FIF, FEF;
|
FROM EM IMPORT FIF, FEF;
|
||||||
FROM Traps IMPORT Message;
|
FROM Traps IMPORT Message;
|
||||||
|
|
|
@ -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-*)
|
(*$R-*)
|
||||||
IMPLEMENTATION MODULE PascalIO;
|
IMPLEMENTATION MODULE PascalIO;
|
||||||
(*
|
(*
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
DEFINITION MODULE Processes;
|
DEFINITION MODULE Processes;
|
||||||
|
(*
|
||||||
|
Module: Processes
|
||||||
|
From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
|
||||||
|
Version: $Header$
|
||||||
|
*)
|
||||||
|
|
||||||
TYPE SIGNAL;
|
TYPE SIGNAL;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
(*$R-*)
|
(*$R-*)
|
||||||
IMPLEMENTATION MODULE Processes [1];
|
IMPLEMENTATION MODULE Processes [1];
|
||||||
(* This implementation module comes from
|
(*
|
||||||
"Programming in Modula-2", by Niklaus Wirth,
|
Module: Processes
|
||||||
3rd edition, Springer-Verlag, New York, 1985
|
From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
|
||||||
|
Version: $Header$
|
||||||
*)
|
*)
|
||||||
|
|
||||||
FROM SYSTEM IMPORT ADDRESS, TSIZE, NEWPROCESS, TRANSFER;
|
FROM SYSTEM IMPORT ADDRESS, TSIZE, NEWPROCESS, TRANSFER;
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
DEFINITION MODULE RealConversions;
|
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);
|
PROCEDURE StringToReal(str: ARRAY OF CHAR; VAR r: REAL; VAR ok: BOOLEAN);
|
||||||
(* Convert string "str" to a real number "r" according to the syntax:
|
(* Convert string "str" to a real number "r" according to the syntax:
|
||||||
|
|
|
@ -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-*)
|
(*$R-*)
|
||||||
IMPLEMENTATION MODULE RealConversions;
|
IMPLEMENTATION MODULE RealConversions;
|
||||||
|
(*
|
||||||
|
Module: string-to-real and real-to-string conversions
|
||||||
|
Author: Ceriel J.H. Jacobs
|
||||||
|
Version: $Header$
|
||||||
|
*)
|
||||||
|
|
||||||
FROM EM IMPORT FIF;
|
FROM EM IMPORT FIF;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
DEFINITION MODULE RealInOut;
|
DEFINITION MODULE RealInOut;
|
||||||
|
(*
|
||||||
|
Module: InOut for REAL numbers
|
||||||
|
From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
|
||||||
|
Version: $Header$
|
||||||
|
*)
|
||||||
|
|
||||||
VAR Done: BOOLEAN;
|
VAR Done: BOOLEAN;
|
||||||
|
|
||||||
|
|
|
@ -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-*)
|
(*$R-*)
|
||||||
IMPLEMENTATION MODULE RealInOut;
|
IMPLEMENTATION MODULE RealInOut;
|
||||||
|
(*
|
||||||
|
Module: InOut for REAL numbers
|
||||||
|
Author: Ceriel J.H. Jacobs
|
||||||
|
Version: $Header$
|
||||||
|
*)
|
||||||
|
|
||||||
IMPORT InOut;
|
IMPORT InOut;
|
||||||
IMPORT RealConversions;
|
IMPORT RealConversions;
|
||||||
|
|
|
@ -1,4 +1,12 @@
|
||||||
DEFINITION MODULE Semaphores;
|
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;
|
TYPE Sema;
|
||||||
|
|
||||||
|
@ -12,12 +20,10 @@ DEFINITION MODULE Semaphores;
|
||||||
(* If the value of "s" is > 0, then just decrement "s".
|
(* If the value of "s" is > 0, then just decrement "s".
|
||||||
Else, suspend the current process until the semaphore becomes
|
Else, suspend the current process until the semaphore becomes
|
||||||
positive again.
|
positive again.
|
||||||
May result in a process switch.
|
|
||||||
*)
|
*)
|
||||||
|
|
||||||
PROCEDURE Up(VAR s: Sema);
|
PROCEDURE Up(VAR s: Sema);
|
||||||
(* Increment the semaphore "s".
|
(* Increment the semaphore "s".
|
||||||
This call may result in a process switch
|
|
||||||
*)
|
*)
|
||||||
|
|
||||||
PROCEDURE StartProcess(P: PROC; n: CARDINAL);
|
PROCEDURE StartProcess(P: PROC; n: CARDINAL);
|
||||||
|
|
|
@ -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-*)
|
(*$R-*)
|
||||||
IMPLEMENTATION MODULE Semaphores [1];
|
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 SYSTEM IMPORT ADDRESS, NEWPROCESS, TRANSFER;
|
||||||
FROM Storage IMPORT ALLOCATE;
|
FROM Storage IMPORT ALLOCATE;
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
DEFINITION MODULE Storage;
|
DEFINITION MODULE Storage;
|
||||||
|
(*
|
||||||
|
Module: Dynamic storage allocation
|
||||||
|
From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth
|
||||||
|
Version: $Header$
|
||||||
|
*)
|
||||||
|
|
||||||
FROM SYSTEM IMPORT ADDRESS;
|
FROM SYSTEM IMPORT ADDRESS;
|
||||||
|
|
||||||
|
|
|
@ -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-*)
|
(*$R-*)
|
||||||
IMPLEMENTATION MODULE Storage;
|
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
|
(* This storage manager maintains an array of lists of objects with the
|
||||||
same size. Commonly used sizes have their own bucket. The larger ones
|
same size. Commonly used sizes have their own bucket. The larger ones
|
||||||
are put in a single list.
|
are put in a single list.
|
||||||
|
|
|
@ -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)
|
_StringAssign(dstsiz, srcsiz, dstaddr, srcaddr)
|
||||||
register char *dstaddr, *srcaddr;
|
register char *dstaddr, *srcaddr;
|
||||||
{
|
{
|
||||||
|
@ -6,8 +17,7 @@ _StringAssign(dstsiz, srcsiz, dstaddr, srcaddr)
|
||||||
srcsiz--;
|
srcsiz--;
|
||||||
dstsiz--;
|
dstsiz--;
|
||||||
}
|
}
|
||||||
while (dstsiz > 0) {
|
if (dstsiz > 0) {
|
||||||
*dstaddr++ = 0;
|
*dstaddr = 0;
|
||||||
dstsiz--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
DEFINITION MODULE Streams;
|
DEFINITION MODULE Streams;
|
||||||
(*
|
(*
|
||||||
|
Module: Stream Input/Output
|
||||||
|
Author: Ceriel J.H. Jacobs
|
||||||
|
Version: $Header$
|
||||||
|
|
||||||
* This module provides sequential IO through streams.
|
* This module provides sequential IO through streams.
|
||||||
* A stream is either a text stream or a binary stream, and is either in
|
* A stream is either a text stream or a binary stream, and is either in
|
||||||
* reading, writing or appending mode.
|
* reading, writing or appending mode.
|
||||||
|
@ -134,10 +138,16 @@ DEFINITION MODULE Streams;
|
||||||
position: LONGINT;
|
position: LONGINT;
|
||||||
VAR result: StreamResult);
|
VAR result: StreamResult);
|
||||||
(* sets the actual read/write position to "position".
|
(* sets the actual read/write position to "position".
|
||||||
"result" is set to illegaloperation if "stream" is not a stream or
|
"result" is set to nostream if "stream" is not a stream.
|
||||||
the stream was opened for appending and the position is in front of
|
It is set to illegaloperation if the stream was opened for appending and
|
||||||
the current position, or it failed for some other
|
the position is in front of the current position, or it failed for some
|
||||||
reason (f.i. when the stream is connected to a terminal).
|
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.
|
END Streams.
|
||||||
|
|
|
@ -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-*)
|
(*$R-*)
|
||||||
IMPLEMENTATION MODULE Streams;
|
IMPLEMENTATION MODULE Streams;
|
||||||
|
(*
|
||||||
|
Module: Stream Input/Output
|
||||||
|
Author: Ceriel J.H. Jacobs
|
||||||
|
Version: $Header$
|
||||||
|
|
||||||
|
Implementation for Unix
|
||||||
|
*)
|
||||||
|
|
||||||
FROM SYSTEM IMPORT BYTE, ADR;
|
FROM SYSTEM IMPORT BYTE, ADR;
|
||||||
IMPORT Unix, TTY, Storage, Epilogue;
|
IMPORT Unix, Storage, Epilogue;
|
||||||
|
|
||||||
CONST BUFSIZ = 1024; (* tunable *)
|
CONST BUFSIZ = 1024; (* tunable *)
|
||||||
TYPE IOB = RECORD
|
TYPE IOB = RECORD
|
||||||
|
@ -332,7 +345,7 @@ IMPLEMENTATION MODULE Streams;
|
||||||
BEGIN
|
BEGIN
|
||||||
currpos := 0D;
|
currpos := 0D;
|
||||||
IF (s = NIL) OR (s^.kind = none) THEN
|
IF (s = NIL) OR (s^.kind = none) THEN
|
||||||
result := illegaloperation;
|
result := nostream;
|
||||||
RETURN;
|
RETURN;
|
||||||
END;
|
END;
|
||||||
IF (s^.mode # reading) THEN
|
IF (s^.mode # reading) THEN
|
||||||
|
@ -360,6 +373,24 @@ IMPLEMENTATION MODULE Streams;
|
||||||
result := succeeded;
|
result := succeeded;
|
||||||
END SetPosition;
|
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
|
BEGIN
|
||||||
InputStream := ADR(ibuf);
|
InputStream := ADR(ibuf);
|
||||||
OutputStream := ADR(obuf);
|
OutputStream := ADR(obuf);
|
||||||
|
@ -383,7 +414,7 @@ BEGIN
|
||||||
maxcnt := 0;
|
maxcnt := 0;
|
||||||
cnt := 0;
|
cnt := 0;
|
||||||
bufferedcnt := BUFSIZ;
|
bufferedcnt := BUFSIZ;
|
||||||
IF TTY.isatty(1) THEN
|
IF isatty(OutputStream) THEN
|
||||||
buffering := linebuffered;
|
buffering := linebuffered;
|
||||||
ELSE
|
ELSE
|
||||||
buffering := blockbuffered;
|
buffering := blockbuffered;
|
||||||
|
@ -398,7 +429,7 @@ BEGIN
|
||||||
maxcnt := 0;
|
maxcnt := 0;
|
||||||
cnt := 0;
|
cnt := 0;
|
||||||
bufferedcnt := BUFSIZ;
|
bufferedcnt := BUFSIZ;
|
||||||
IF TTY.isatty(2) THEN
|
IF isatty(ErrorStream) THEN
|
||||||
buffering := linebuffered;
|
buffering := linebuffered;
|
||||||
ELSE
|
ELSE
|
||||||
buffering := blockbuffered;
|
buffering := blockbuffered;
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
DEFINITION MODULE Strings;
|
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
|
(* Note: truncation of strings may occur if the user does not provide
|
||||||
large enough variables to contain the result of the operation.
|
large enough variables to contain the result of the operation.
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -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-*)
|
(*$R-*)
|
||||||
IMPLEMENTATION MODULE Strings;
|
IMPLEMENTATION MODULE Strings;
|
||||||
|
(*
|
||||||
|
Module: String manipulations
|
||||||
|
Author: Ceriel J.H. Jacobs
|
||||||
|
Version: $Header$
|
||||||
|
*)
|
||||||
|
|
||||||
PROCEDURE Assign(source: ARRAY OF CHAR; VAR dest: ARRAY OF CHAR);
|
PROCEDURE Assign(source: ARRAY OF CHAR; VAR dest: ARRAY OF CHAR);
|
||||||
(* Assign string source to dest
|
(* Assign string source to dest
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
DEFINITION MODULE Terminal;
|
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);
|
PROCEDURE Read(VAR ch : CHAR);
|
||||||
(* Read a character from the terminal and leave it in ch
|
(* Read a character from the terminal and leave it in ch
|
||||||
|
|
|
@ -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-*)
|
(*$R-*)
|
||||||
IMPLEMENTATION MODULE Terminal;
|
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;
|
IMPORT Unix;
|
||||||
FROM SYSTEM IMPORT ADR;
|
FROM SYSTEM IMPORT ADR;
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
DEFINITION MODULE Traps;
|
DEFINITION MODULE Traps;
|
||||||
|
(*
|
||||||
|
Module: Facility for handling traps
|
||||||
|
Author: Ceriel J.H. Jacobs
|
||||||
|
Version: $Header$
|
||||||
|
*)
|
||||||
|
|
||||||
IMPORT EM;
|
IMPORT EM;
|
||||||
|
|
||||||
|
|
|
@ -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-*)
|
(*$R-*)
|
||||||
IMPLEMENTATION MODULE Traps;
|
IMPLEMENTATION MODULE Traps;
|
||||||
|
(*
|
||||||
|
Module: Facility for handling traps
|
||||||
|
Author: Ceriel J.H. Jacobs
|
||||||
|
Version: $Header$
|
||||||
|
*)
|
||||||
|
|
||||||
IMPORT EM;
|
IMPORT EM;
|
||||||
IMPORT Unix;
|
IMPORT Unix;
|
||||||
FROM SYSTEM IMPORT ADDRESS, ADR;
|
FROM SYSTEM IMPORT ADDRESS, ADR;
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
(*$Foreign language module *)
|
(*$Foreign language module *)
|
||||||
DEFINITION MODULE Unix;
|
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;
|
FROM SYSTEM IMPORT WORD, ADDRESS;
|
||||||
|
|
||||||
(* Type needed for Signal *)
|
(* Type needed for Signal *)
|
||||||
|
|
|
@ -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
|
#ifndef NOFLOAT
|
||||||
double
|
double
|
||||||
_absd(i)
|
_absd(i)
|
||||||
|
|
|
@ -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
|
mes 2,EM_WSIZE,EM_PSIZE
|
||||||
exp $_absf
|
exp $_absf
|
||||||
pro $_absf,0
|
pro $_absf,0
|
||||||
|
|
|
@ -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)
|
_absi(i)
|
||||||
{
|
{
|
||||||
return i >= 0 ? i : -i;
|
return i >= 0 ? i : -i;
|
||||||
|
|
|
@ -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
|
long
|
||||||
_absl(i)
|
_absl(i)
|
||||||
long i;
|
long i;
|
||||||
|
|
|
@ -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 <em_abs.h>
|
||||||
#include <m2_traps.h>
|
#include <m2_traps.h>
|
||||||
|
|
||||||
|
|
|
@ -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>
|
#include <m2_traps.h>
|
||||||
|
|
||||||
struct descr {
|
struct descr {
|
||||||
|
|
|
@ -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
|
#define MAXPROCS 16
|
||||||
|
|
||||||
static int callindex;
|
static int callindex;
|
||||||
|
|
|
@ -1,22 +1,13 @@
|
||||||
#
|
#
|
||||||
/*
|
;
|
||||||
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
||||||
*
|
; See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||||
* This product is part of the Amsterdam Compiler Kit.
|
;
|
||||||
*
|
;
|
||||||
* Permission to use, sell, duplicate or disclose this software must be
|
; Module: Modula-2 runtime startoff
|
||||||
* obtained in writing. Requests for such permissions may be sent to
|
; Author: Ceriel J.H. Jacobs
|
||||||
*
|
; Version: $Header$
|
||||||
* Dr. Andrew S. Tanenbaum
|
;
|
||||||
* Wiskundig Seminarium
|
|
||||||
* Vrije Universiteit
|
|
||||||
* Postbox 7161
|
|
||||||
* 1007 MC Amsterdam
|
|
||||||
* The Netherlands
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Author: C.J.H. Jacobs */
|
|
||||||
|
|
||||||
mes 2,EM_WSIZE,EM_PSIZE
|
mes 2,EM_WSIZE,EM_PSIZE
|
||||||
|
|
||||||
|
|
|
@ -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)
|
_load(siz, addr, p)
|
||||||
register char *addr;
|
register char *addr;
|
||||||
register int siz;
|
register int siz;
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
DEFINITION MODULE random;
|
DEFINITION MODULE random;
|
||||||
|
(*
|
||||||
|
Module: random numbers
|
||||||
|
Author: Ceriel J.H. Jacobs
|
||||||
|
Version: $Header$
|
||||||
|
*)
|
||||||
|
|
||||||
PROCEDURE Random(): CARDINAL;
|
PROCEDURE Random(): CARDINAL;
|
||||||
(* Return a 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.
|
"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.
|
END random.
|
||||||
|
|
|
@ -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-*)
|
(*$R-*)
|
||||||
IMPLEMENTATION MODULE random;
|
IMPLEMENTATION MODULE random;
|
||||||
|
(*
|
||||||
|
Module: random numbers
|
||||||
|
Author: Ceriel J.H. Jacobs
|
||||||
|
Version: $Header$
|
||||||
|
*)
|
||||||
|
|
||||||
FROM Unix IMPORT getpid, time;
|
FROM Unix IMPORT getpid, time;
|
||||||
TYPE index = [0..54];
|
TYPE index = [0..54];
|
||||||
|
@ -21,12 +31,17 @@ BEGIN
|
||||||
RETURN lwb + (Random() MOD (upb - lwb + 1));
|
RETURN lwb + (Random() MOD (upb - lwb + 1));
|
||||||
END Uniform;
|
END Uniform;
|
||||||
|
|
||||||
|
PROCEDURE StartSeed(seed: CARDINAL);
|
||||||
BEGIN
|
BEGIN
|
||||||
X[0] := time(NIL);
|
X[0] := seed;
|
||||||
X[0] := CARDINAL(getpid()) * X[0];
|
|
||||||
FOR k := 1 TO 54 DO
|
FOR k := 1 TO 54 DO
|
||||||
X[k] := X[k-1] * 1297;
|
X[k] := X[k-1] * 1297;
|
||||||
END;
|
END;
|
||||||
k := 54;
|
k := 54;
|
||||||
j := 30;
|
j := 30;
|
||||||
|
END StartSeed;
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
X0 := time(NIL);
|
||||||
|
StartSeed(CARDINAL(getpid()) * X[0]);
|
||||||
END random.
|
END random.
|
||||||
|
|
|
@ -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>
|
#include <em_abs.h>
|
||||||
|
|
||||||
mes 2,EM_WSIZE,EM_PSIZE
|
mes 2,EM_WSIZE,EM_PSIZE
|
||||||
|
|
|
@ -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>
|
#include <em_abs.h>
|
||||||
|
|
||||||
mes 2,EM_WSIZE,EM_PSIZE
|
mes 2,EM_WSIZE,EM_PSIZE
|
||||||
|
|
|
@ -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>
|
#include <em_abs.h>
|
||||||
|
|
||||||
mes 2,EM_WSIZE,EM_PSIZE
|
mes 2,EM_WSIZE,EM_PSIZE
|
||||||
|
|
|
@ -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>
|
#include <em_abs.h>
|
||||||
|
|
||||||
mes 2,EM_WSIZE,EM_PSIZE
|
mes 2,EM_WSIZE,EM_PSIZE
|
||||||
|
|
|
@ -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)
|
_stackprio(n)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
_store(siz, addr, p)
|
||||||
register char *addr;
|
register char *addr;
|
||||||
register int siz;
|
register int siz;
|
||||||
|
|
|
@ -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 <em_mes.h>
|
||||||
#include <m2_traps.h>
|
#include <m2_traps.h>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue