Use SYSTEM.ADDRESS in libraries. Build all with -O2. Support INC(a,b) for any int a,b that support a:=a+b.

This commit is contained in:
David Brown 2016-09-23 13:04:24 +01:00
parent f1cbbdba28
commit 22a4f8e263
92 changed files with 2752 additions and 2695 deletions

View file

@ -41,7 +41,8 @@ under a public-key cryptosystem such as RSA. *)
PROCEDURE ByteReverse(VAR in: ARRAY OF SYSTEM.BYTE; VAR out: ARRAY OF LONGINT; longs: LONGINT);
VAR
adr, t, i: LONGINT;
adr: SYSTEM.ADDRESS;
t, i: LONGINT;
bytes: ARRAY 4 OF CHAR;
BEGIN
adr := SYSTEM.ADR(in[0]); i := 0;

View file

@ -3,8 +3,7 @@ Refer to the "General ETH Oberon System Source License" contract available at: h
MODULE ethZlibBuffers; (** Stefan Walthert **)
IMPORT
SYSTEM;
IMPORT SYSTEM;
(*
should be portable even if SYSTEM is imported:
- PUT and GET only with byte sized operands
@ -13,13 +12,14 @@ IMPORT
TYPE
(** input/output buffer **)
Address = LONGINT;
Address = SYSTEM.ADDRESS;
Buffer* = RECORD
avail-: LONGINT; (** number of bytes that can be produced/consumed **)
size-: LONGINT; (** total number of bytes in buffer memory **)
totalOut-, totalIn-: LONGINT; (** total number of bytes produced/consumed **)
next: Address; (* address of next byte to produce/consume **)
adr: Address; (* buffer memory *)
avail-: LONGINT; (** number of bytes that can be produced/consumed **)
size-: LONGINT; (** total number of bytes in buffer memory **)
totalOut-: LONGINT; (** total number of bytes produced **)
totalIn-: LONGINT; (** total number of bytes consumed **)
next: Address; (* address of next byte to produce/consume **)
adr: Address; (* buffer memory *)
END;
@ -50,9 +50,9 @@ PROCEDURE ReadBytes* (VAR buf: Buffer; VAR dst: ARRAY OF CHAR; offset, len: LONG
BEGIN
ASSERT((0 <= offset) & (0 < len) & (offset + len <= LEN(dst)) & (len <= buf.avail), 100);
SYSTEM.MOVE(buf.next, SYSTEM.ADR(dst[offset]), len);
INC(buf.next, len); DEC(buf.avail, len); INC(buf.totalIn, len)
INC(buf.next, len); DEC(buf.avail, len); INC(buf.totalIn, len)
END ReadBytes;
(** write byte into (output) buffer **)
PROCEDURE Write* (VAR buf: Buffer; ch: CHAR);
BEGIN
@ -89,7 +89,7 @@ PROCEDURE Rewrite* (VAR buf: Buffer);
BEGIN
buf.next := buf.adr; buf.avail := buf.size
END Rewrite;
(** fill input buffer with new bytes to consume **)
PROCEDURE Fill* (VAR buf: Buffer; VAR src: ARRAY OF CHAR; offset, size: LONGINT);
BEGIN

View file

@ -1,6 +1,6 @@
MODULE ulmIO;
IMPORT SYS := ulmSYSTEM, SYSTEM;
IMPORT SYS := ulmSYSTEM, SYSTEM, Platform;
CONST nl = 0AX;
@ -118,6 +118,7 @@ MODULE ulmIO;
(* ========================= terminal ============================ *)
(*
PROCEDURE ReadChar(VAR ch: CHAR) : BOOLEAN;
CONST read = 3;
(*VAR r0, r1: INTEGER;*)
@ -125,7 +126,17 @@ MODULE ulmIO;
BEGIN
RETURN SYS.UNIXCALL(read, r0, r1, 0, SYSTEM.ADR(ch), 1) & (r0 > 0)
END ReadChar;
*)
PROCEDURE ReadChar(VAR ch: CHAR) : BOOLEAN;
(* Read one byte, returning success flag *)
VAR error: Platform.ErrorCode; readcount: LONGINT;
BEGIN
error := Platform.ReadBuf(Platform.StdIn, ch, readcount);
RETURN readcount > 0
END ReadChar;
(*
PROCEDURE WriteChar(ch: CHAR) : BOOLEAN;
CONST write = 4;
(*VAR r0, r1: INTEGER;*)
@ -133,6 +144,13 @@ MODULE ulmIO;
BEGIN
RETURN SYS.UNIXCALL(write, r0, r1, 1, SYSTEM.ADR(ch), 1)
END WriteChar;
*)
PROCEDURE WriteChar(ch: CHAR) : BOOLEAN;
(* Write one byte, returning success flag *)
BEGIN
RETURN Platform.Write(Platform.StdOut, SYSTEM.ADR(ch), 1) = 0
END WriteChar;
PROCEDURE Read*(VAR ch: CHAR);
BEGIN

View file

@ -49,6 +49,7 @@ TYPE pchar = POINTER TO ARRAY 1 OF CHAR;
RETURN oldflag;
END TAS;
(*
PROCEDURE UNIXCALL*(syscall: LONGINT; VAR d0, d1: LONGINT; (* in ulm version both LONGINT and INTEGER are 4 byte size *)
arg1, arg2, arg3: LONGINT) : BOOLEAN;
VAR
@ -122,7 +123,7 @@ TYPE pchar = POINTER TO ARRAY 1 OF CHAR;
END
END UNIXCALL;
*)
PROCEDURE UNIXFORK(VAR pid: LONGINT) : BOOLEAN;
BEGIN
@ -135,8 +136,7 @@ TYPE pchar = POINTER TO ARRAY 1 OF CHAR;
END UNIXSIGNAL;
PROCEDURE WMOVE*(from, to, n : LONGINT);
VAR l : LONGINT;
PROCEDURE WMOVE*(from, to, n : SYSTEM.ADDRESS);
BEGIN
SYSTEM.MOVE(from, to, n);
END WMOVE;

View file

@ -3,7 +3,7 @@ MODULE Args; (* jt, 8.12.94 *)
(* command line argument handling for voc (jet backend) *)
IMPORT Platform;
IMPORT Platform, SYSTEM;
TYPE
ArgPtr = POINTER TO ARRAY 1024 OF CHAR;
@ -11,17 +11,17 @@ MODULE Args; (* jt, 8.12.94 *)
VAR
argc-: LONGINT;
argv-: LONGINT;
argv-: SYSTEM.ADDRESS;
PROCEDURE Get* (n: INTEGER; VAR val: ARRAY OF CHAR); BEGIN Platform.GetArg(n, val) END Get;
PROCEDURE GetInt*(n: INTEGER; VAR val: LONGINT); BEGIN Platform.GetIntArg(n, val) END GetInt;
PROCEDURE Pos* (s: ARRAY OF CHAR): INTEGER; BEGIN RETURN Platform.ArgPos(s) END Pos;
PROCEDURE GetEnv*(var: ARRAY OF CHAR; VAR val: ARRAY OF CHAR);
PROCEDURE GetEnv*(var: ARRAY OF CHAR; VAR val: ARRAY OF CHAR);
BEGIN Platform.GetEnv(var, val) END GetEnv;
PROCEDURE getEnv*(var: ARRAY OF CHAR; VAR val: ARRAY OF CHAR): BOOLEAN;
PROCEDURE getEnv*(var: ARRAY OF CHAR; VAR val: ARRAY OF CHAR): BOOLEAN;
BEGIN RETURN Platform.getEnv(var, val) END getEnv;

View file

@ -87,7 +87,7 @@ MODULE Printer; (*UNIX version: JT 11.5.90, RC 2.7.93, JS 29.4.94, JT 14.4.95
VAR family: ARRAY 7 OF CHAR;
BEGIN
COPY(fname, family);
Ch(fontR, "/"); Str(fontR, fname);
Ch(fontR, "/"); Str(fontR, fname);
IF family = "Syntax" THEN Str(fontR, " DefineSMapFont") ELSE Str(fontR, " DefineMapFont") END;
Ln(fontR); Ln(fontR);
END SetMappedFont;
@ -161,7 +161,7 @@ MODULE Printer; (*UNIX version: JT 11.5.90, RC 2.7.93, JS 29.4.94, JT 14.4.95
| 92: Str(fontR, "backslash")
| 93: Str(fontR, "bracketright")
| 94: Str(fontR, "arrowup")
| 95: Str(fontR, "underscore")
| 95: Str(fontR, "underscore")
| 96: Str(fontR, "grave")
| 97..122: Ch(fontR, CHR(m))
| 123: Str(fontR, "braceleft")
@ -205,8 +205,8 @@ MODULE Printer; (*UNIX version: JT 11.5.90, RC 2.7.93, JS 29.4.94, JT 14.4.95
Str(fontR, "% Conversion of the Oberon font "); Str(fontR, fd.name); Ln(fontR);
Files.Read(R, ch);
IF ch = fontFileId THEN
Files.Read(R, ch); Str(fontR, "% abstraction: "); Int(fontR, ORD(ch));
Files.Read(R, ch); Str(fontR, ", family: "); Ch(fontR, ch);
Files.Read(R, ch); Str(fontR, "% abstraction: "); Int(fontR, ORD(ch));
Files.Read(R, ch); Str(fontR, ", family: "); Ch(fontR, ch);
Files.Read(R, ch); Str(fontR, ", variant: "); Int(fontR, ORD(ch)); Ln(fontR);
Files.ReadInt(R, height); Str(fontR, "% height: "); Int(fontR, height); Ln(fontR); Ln(fontR);
Files.ReadInt(R, minX); Files.ReadInt(R, maxX);
@ -223,7 +223,7 @@ MODULE Printer; (*UNIX version: JT 11.5.90, RC 2.7.93, JS 29.4.94, JT 14.4.95
Str(fontR, "/FontMatrix [ 72 "); Int(fontR, pRes); Str(fontR, " div "); Str(fontR, " .24 div 0 0 ");
Str(fontR, "72 "); Int(fontR, pRes); Str(fontR, " div "); Str(fontR, " .24 div 0 0");
Str(fontR, "] def"); Ln(fontR);
Str(fontR, "/FontBBox [");
Str(fontR, "/FontBBox [");
Int(fontR, minX); Ch(fontR, " ");
Int(fontR, minY); Ch(fontR, " ");
Int(fontR, maxX); Ch(fontR, " ");
@ -339,7 +339,7 @@ END;
Error("file not found", headerFileName)
END
END Open;
PROCEDURE UseListFont*(VAR name: ARRAY OF CHAR);
BEGIN
COPY(name, listFont); curFont := -1
@ -368,7 +368,7 @@ END;
IF fname = listFont THEN fontname := "Courier8.Scn.Fnt" ELSE COPY(fname, fontname) END ;
IF (curFont < 0) OR (fontTable[curFont].name # fontname) THEN
COPY(fontname, fontTable[fontIndex+1].name);
i := 0; WHILE i < 8 DO fontTable[fontIndex+1].used[i] := {}; INC(i) END;
i := 0; WHILE i < 8 DO fontTable[fontIndex+1].used[i] := {}; INC(i) END;
fNo := 0;
WHILE fontTable[fNo].name # fontname DO INC(fNo) END;
IF fNo > fontIndex THEN (* DefineFont(fontname); *) fontIndex := fNo END;
@ -394,7 +394,7 @@ END;
END;
Str(bodyR, ") s"); Ln(bodyR)
END ContString;
PROCEDURE String*(x, y: INTEGER; VAR s, fname: ARRAY OF CHAR);
BEGIN
Int(bodyR, x); Ch(bodyR, " ");
@ -410,7 +410,7 @@ END;
Int(bodyR, col); Str(bodyR, " b"); Ln(bodyR);
END ReplPattern;
PROCEDURE Picture*(x, y, w, h, mode: INTEGER; adr: LONGINT);
PROCEDURE Picture*(x, y, w, h, mode: INTEGER; adr: SYSTEM.ADDRESS);
VAR n, i, v: INTEGER; ch: CHAR;
BEGIN
Int(bodyR, x); Ch(bodyR, " ");
@ -517,7 +517,7 @@ END;
a[i] := 2.0*b[i-1] + hn; d[i] := d1 + dn;
w[i] := 1.0; i := 0;
WHILE i < n-2 DO c[i] := c[i]/a[i]; a[i+1] := a[i+1] - c[i]*b[i]; INC(i) END ;
SolveTriDiag(a, b, c, d, n-1); SolveTriDiag(a, b, c, w, n-1);
SolveTriDiag(a, b, c, d, n-1); SolveTriDiag(a, b, c, w, n-1);
d1 := (d[0] + d[i])/(w[0] + w[i] + x[i+1] - x[i]); i := 0;
WHILE i < n-1 DO d[i] := d[i] - d1*w[i]; INC(i) END ;
d[i] := d[0]
@ -582,7 +582,7 @@ END;
END Spline;
PROCEDURE Page*(nofcopies: INTEGER);
BEGIN
BEGIN
curR := 0; curG := 0; curB := 0; curFont := -1;
INC(pno); ppos := Files.Pos(bodyR); PrintCopies := nofcopies;
IF PrintMode[1] # ":" THEN
@ -639,7 +639,7 @@ END;
IF PrinterName # "none" THEN Files.Write(printR, 4X) (*force reset postscript*) END ;
Files.Register(printF);
IF PrinterName # "none" THEN
cmd := "lp -c -s ";
cmd := "lp -c -s ";
IF PrinterName # "Pluto" THEN Append(cmd, "-d "); Append(cmd, PrinterName) END ;
Append(cmd, " "); Append(cmd, printFileName);
i := Platform.System(cmd);