-
Notifications
You must be signed in to change notification settings - Fork 3
/
Obn2.Mod
69 lines (59 loc) · 1.39 KB
/
Obn2.Mod
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
(** Obn2.Mod is a module to help port Oberon-2 modules to Oberon-7.
Copyright (C) 2021 R. S. Doiel
Released under The 3-Clause BSD License.
See https://opensource.org/licenses/BSD-3-Clause
*)
MODULE Obn2;
(** ASH provides the Oberon-2 built-in ASH functionilty for
Oberon-7. See description of providing ASH in documentation
on Oberon-7 for positive and negative values *)
PROCEDURE ASH*(x, n : INTEGER) : INTEGER;
VAR res : INTEGER;
BEGIN
IF n > 0 THEN
res := LSL(x, n);
ELSE
res := ASR(x, n);
END;
RETURN res
END ASH;
(** MAX returns the maximum of two integers *)
PROCEDURE MAX*(x, y : INTEGER) : INTEGER;
VAR res : INTEGER;
BEGIN
IF x > y THEN
res := x;
ELSE
res := y;
END;
RETURN res
END MAX;
(** MIN provides the minimum of two integers *)
PROCEDURE MIN*(x, y : INTEGER) : INTEGER;
VAR res : INTEGER;
BEGIN
IF x < y THEN
res := x;
ELSE
res := y;
END;
RETURN res
END MIN;
(** ENTIER is a wrapper around FLOOR, you should really just use
FLOOR. *)
PROCEDURE ENTIER*(r : REAL) : INTEGER;
BEGIN
RETURN FLOOR(r)
END ENTIER;
(** HALT is a wrapper around ASSERT(FALSE), you should just replace
ASSERT(FALSE) *)
PROCEDURE HALT*();
BEGIN
ASSERT(FALSE);
END HALT;
(** ROT is a wrapper around ROR, you should just replace ROT with ROR *)
PROCEDURE ROT*(x, n : INTEGER) : INTEGER;
BEGIN
RETURN ROR(x, n)
END ROT;
END Obn2.