From ee77ec43ca8805aeccf654adf12c72dc08b49c6e Mon Sep 17 00:00:00 2001 From: David Brown Date: Tue, 11 Oct 2016 11:42:22 +0100 Subject: [PATCH] Out.Mod. Add buffer, simplify real output. --- bootstrap/unix-44/Compiler.c | 2 +- bootstrap/unix-44/Configuration.c | 4 +- bootstrap/unix-44/Configuration.h | 2 +- bootstrap/unix-44/Files.c | 2 +- bootstrap/unix-44/Files.h | 2 +- bootstrap/unix-44/Heap.c | 2 +- bootstrap/unix-44/Heap.h | 2 +- bootstrap/unix-44/Modules.c | 2 +- bootstrap/unix-44/Modules.h | 2 +- bootstrap/unix-44/OPB.c | 2 +- bootstrap/unix-44/OPB.h | 2 +- bootstrap/unix-44/OPC.c | 2 +- bootstrap/unix-44/OPC.h | 2 +- bootstrap/unix-44/OPM.c | 2 +- bootstrap/unix-44/OPM.h | 2 +- bootstrap/unix-44/OPP.c | 2 +- bootstrap/unix-44/OPP.h | 2 +- bootstrap/unix-44/OPS.c | 2 +- bootstrap/unix-44/OPS.h | 2 +- bootstrap/unix-44/OPT.c | 2 +- bootstrap/unix-44/OPT.h | 2 +- bootstrap/unix-44/OPV.c | 2 +- bootstrap/unix-44/OPV.h | 2 +- bootstrap/unix-44/Out.c | 224 +++++++++++---------------- bootstrap/unix-44/Out.h | 5 +- bootstrap/unix-44/Platform.c | 2 +- bootstrap/unix-44/Platform.h | 2 +- bootstrap/unix-44/Reals.c | 2 +- bootstrap/unix-44/Reals.h | 2 +- bootstrap/unix-44/Strings.c | 17 +- bootstrap/unix-44/Strings.h | 2 +- bootstrap/unix-44/Texts.c | 2 +- bootstrap/unix-44/Texts.h | 2 +- bootstrap/unix-44/errors.c | 2 +- bootstrap/unix-44/errors.h | 2 +- bootstrap/unix-44/extTools.c | 2 +- bootstrap/unix-44/extTools.h | 2 +- bootstrap/unix-44/vt100.c | 2 +- bootstrap/unix-44/vt100.h | 2 +- bootstrap/unix-48/Compiler.c | 2 +- bootstrap/unix-48/Configuration.c | 4 +- bootstrap/unix-48/Configuration.h | 2 +- bootstrap/unix-48/Files.c | 2 +- bootstrap/unix-48/Files.h | 2 +- bootstrap/unix-48/Heap.c | 2 +- bootstrap/unix-48/Heap.h | 2 +- bootstrap/unix-48/Modules.c | 2 +- bootstrap/unix-48/Modules.h | 2 +- bootstrap/unix-48/OPB.c | 2 +- bootstrap/unix-48/OPB.h | 2 +- bootstrap/unix-48/OPC.c | 2 +- bootstrap/unix-48/OPC.h | 2 +- bootstrap/unix-48/OPM.c | 2 +- bootstrap/unix-48/OPM.h | 2 +- bootstrap/unix-48/OPP.c | 2 +- bootstrap/unix-48/OPP.h | 2 +- bootstrap/unix-48/OPS.c | 2 +- bootstrap/unix-48/OPS.h | 2 +- bootstrap/unix-48/OPT.c | 2 +- bootstrap/unix-48/OPT.h | 2 +- bootstrap/unix-48/OPV.c | 2 +- bootstrap/unix-48/OPV.h | 2 +- bootstrap/unix-48/Out.c | 224 +++++++++++---------------- bootstrap/unix-48/Out.h | 5 +- bootstrap/unix-48/Platform.c | 2 +- bootstrap/unix-48/Platform.h | 2 +- bootstrap/unix-48/Reals.c | 2 +- bootstrap/unix-48/Reals.h | 2 +- bootstrap/unix-48/Strings.c | 17 +- bootstrap/unix-48/Strings.h | 2 +- bootstrap/unix-48/Texts.c | 2 +- bootstrap/unix-48/Texts.h | 2 +- bootstrap/unix-48/errors.c | 2 +- bootstrap/unix-48/errors.h | 2 +- bootstrap/unix-48/extTools.c | 2 +- bootstrap/unix-48/extTools.h | 2 +- bootstrap/unix-48/vt100.c | 2 +- bootstrap/unix-48/vt100.h | 2 +- bootstrap/unix-88/Compiler.c | 2 +- bootstrap/unix-88/Configuration.c | 4 +- bootstrap/unix-88/Configuration.h | 2 +- bootstrap/unix-88/Files.c | 2 +- bootstrap/unix-88/Files.h | 2 +- bootstrap/unix-88/Heap.c | 2 +- bootstrap/unix-88/Heap.h | 2 +- bootstrap/unix-88/Modules.c | 2 +- bootstrap/unix-88/Modules.h | 2 +- bootstrap/unix-88/OPB.c | 2 +- bootstrap/unix-88/OPB.h | 2 +- bootstrap/unix-88/OPC.c | 2 +- bootstrap/unix-88/OPC.h | 2 +- bootstrap/unix-88/OPM.c | 2 +- bootstrap/unix-88/OPM.h | 2 +- bootstrap/unix-88/OPP.c | 2 +- bootstrap/unix-88/OPP.h | 2 +- bootstrap/unix-88/OPS.c | 2 +- bootstrap/unix-88/OPS.h | 2 +- bootstrap/unix-88/OPT.c | 2 +- bootstrap/unix-88/OPT.h | 2 +- bootstrap/unix-88/OPV.c | 2 +- bootstrap/unix-88/OPV.h | 2 +- bootstrap/unix-88/Out.c | 224 +++++++++++---------------- bootstrap/unix-88/Out.h | 5 +- bootstrap/unix-88/Platform.c | 2 +- bootstrap/unix-88/Platform.h | 2 +- bootstrap/unix-88/Reals.c | 2 +- bootstrap/unix-88/Reals.h | 2 +- bootstrap/unix-88/Strings.c | 17 +- bootstrap/unix-88/Strings.h | 2 +- bootstrap/unix-88/Texts.c | 2 +- bootstrap/unix-88/Texts.h | 2 +- bootstrap/unix-88/errors.c | 2 +- bootstrap/unix-88/errors.h | 2 +- bootstrap/unix-88/extTools.c | 2 +- bootstrap/unix-88/extTools.h | 2 +- bootstrap/unix-88/vt100.c | 2 +- bootstrap/unix-88/vt100.h | 2 +- bootstrap/windows-48/Compiler.c | 2 +- bootstrap/windows-48/Configuration.c | 4 +- bootstrap/windows-48/Configuration.h | 2 +- bootstrap/windows-48/Files.c | 2 +- bootstrap/windows-48/Files.h | 2 +- bootstrap/windows-48/Heap.c | 2 +- bootstrap/windows-48/Heap.h | 2 +- bootstrap/windows-48/Modules.c | 2 +- bootstrap/windows-48/Modules.h | 2 +- bootstrap/windows-48/OPB.c | 2 +- bootstrap/windows-48/OPB.h | 2 +- bootstrap/windows-48/OPC.c | 2 +- bootstrap/windows-48/OPC.h | 2 +- bootstrap/windows-48/OPM.c | 2 +- bootstrap/windows-48/OPM.h | 2 +- bootstrap/windows-48/OPP.c | 2 +- bootstrap/windows-48/OPP.h | 2 +- bootstrap/windows-48/OPS.c | 2 +- bootstrap/windows-48/OPS.h | 2 +- bootstrap/windows-48/OPT.c | 2 +- bootstrap/windows-48/OPT.h | 2 +- bootstrap/windows-48/OPV.c | 2 +- bootstrap/windows-48/OPV.h | 2 +- bootstrap/windows-48/Out.c | 224 +++++++++++---------------- bootstrap/windows-48/Out.h | 5 +- bootstrap/windows-48/Platform.c | 2 +- bootstrap/windows-48/Platform.h | 2 +- bootstrap/windows-48/Reals.c | 2 +- bootstrap/windows-48/Reals.h | 2 +- bootstrap/windows-48/Strings.c | 17 +- bootstrap/windows-48/Strings.h | 2 +- bootstrap/windows-48/Texts.c | 2 +- bootstrap/windows-48/Texts.h | 2 +- bootstrap/windows-48/errors.c | 2 +- bootstrap/windows-48/errors.h | 2 +- bootstrap/windows-48/extTools.c | 2 +- bootstrap/windows-48/extTools.h | 2 +- bootstrap/windows-48/vt100.c | 2 +- bootstrap/windows-48/vt100.h | 2 +- bootstrap/windows-88/Compiler.c | 2 +- bootstrap/windows-88/Configuration.c | 4 +- bootstrap/windows-88/Configuration.h | 2 +- bootstrap/windows-88/Files.c | 2 +- bootstrap/windows-88/Files.h | 2 +- bootstrap/windows-88/Heap.c | 2 +- bootstrap/windows-88/Heap.h | 2 +- bootstrap/windows-88/Modules.c | 2 +- bootstrap/windows-88/Modules.h | 2 +- bootstrap/windows-88/OPB.c | 2 +- bootstrap/windows-88/OPB.h | 2 +- bootstrap/windows-88/OPC.c | 2 +- bootstrap/windows-88/OPC.h | 2 +- bootstrap/windows-88/OPM.c | 2 +- bootstrap/windows-88/OPM.h | 2 +- bootstrap/windows-88/OPP.c | 2 +- bootstrap/windows-88/OPP.h | 2 +- bootstrap/windows-88/OPS.c | 2 +- bootstrap/windows-88/OPS.h | 2 +- bootstrap/windows-88/OPT.c | 2 +- bootstrap/windows-88/OPT.h | 2 +- bootstrap/windows-88/OPV.c | 2 +- bootstrap/windows-88/OPV.h | 2 +- bootstrap/windows-88/Out.c | 224 +++++++++++---------------- bootstrap/windows-88/Out.h | 5 +- bootstrap/windows-88/Platform.c | 2 +- bootstrap/windows-88/Platform.h | 2 +- bootstrap/windows-88/Reals.c | 2 +- bootstrap/windows-88/Reals.h | 2 +- bootstrap/windows-88/Strings.c | 17 +- bootstrap/windows-88/Strings.h | 2 +- bootstrap/windows-88/Texts.c | 2 +- bootstrap/windows-88/Texts.h | 2 +- bootstrap/windows-88/errors.c | 2 +- bootstrap/windows-88/errors.h | 2 +- bootstrap/windows-88/extTools.c | 2 +- bootstrap/windows-88/extTools.h | 2 +- bootstrap/windows-88/vt100.c | 2 +- bootstrap/windows-88/vt100.h | 2 +- src/runtime/Out.Mod | 170 ++++++++------------ src/runtime/Strings.Mod | 6 +- src/test/confidence/out/expected | 36 ++--- src/test/confidence/out/result-O2 | 18 +-- src/test/confidence/out/result-OC | 18 +-- 200 files changed, 803 insertions(+), 1045 deletions(-) diff --git a/bootstrap/unix-44/Compiler.c b/bootstrap/unix-44/Compiler.c index 2dd6f251..b303a7c4 100644 --- a/bootstrap/unix-44/Compiler.c +++ b/bootstrap/unix-44/Compiler.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/Configuration.c b/bootstrap/unix-44/Configuration.c index 3498204c..8ac138be 100644 --- a/bootstrap/unix-44/Configuration.c +++ b/bootstrap/unix-44/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/unix-44/Configuration.h b/bootstrap/unix-44/Configuration.h index 14d86591..207eeb63 100644 --- a/bootstrap/unix-44/Configuration.h +++ b/bootstrap/unix-44/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-44/Files.c b/bootstrap/unix-44/Files.c index cb7920a3..c983396b 100644 --- a/bootstrap/unix-44/Files.c +++ b/bootstrap/unix-44/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/Files.h b/bootstrap/unix-44/Files.h index 4a49d744..ba64fc56 100644 --- a/bootstrap/unix-44/Files.h +++ b/bootstrap/unix-44/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-44/Heap.c b/bootstrap/unix-44/Heap.c index 860107f9..8758813f 100644 --- a/bootstrap/unix-44/Heap.c +++ b/bootstrap/unix-44/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/Heap.h b/bootstrap/unix-44/Heap.h index 84c9bb20..bcf77f96 100644 --- a/bootstrap/unix-44/Heap.h +++ b/bootstrap/unix-44/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-44/Modules.c b/bootstrap/unix-44/Modules.c index ab3bb29b..5302c9f4 100644 --- a/bootstrap/unix-44/Modules.c +++ b/bootstrap/unix-44/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/Modules.h b/bootstrap/unix-44/Modules.h index 95fc4f94..abb938ae 100644 --- a/bootstrap/unix-44/Modules.h +++ b/bootstrap/unix-44/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/unix-44/OPB.c b/bootstrap/unix-44/OPB.c index bfc64251..3233aa7b 100644 --- a/bootstrap/unix-44/OPB.c +++ b/bootstrap/unix-44/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/OPB.h b/bootstrap/unix-44/OPB.h index d04325c7..6931fe6e 100644 --- a/bootstrap/unix-44/OPB.h +++ b/bootstrap/unix-44/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-44/OPC.c b/bootstrap/unix-44/OPC.c index 54cd9a85..48f0d967 100644 --- a/bootstrap/unix-44/OPC.c +++ b/bootstrap/unix-44/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/OPC.h b/bootstrap/unix-44/OPC.h index 69a5580c..40825f04 100644 --- a/bootstrap/unix-44/OPC.h +++ b/bootstrap/unix-44/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-44/OPM.c b/bootstrap/unix-44/OPM.c index 7da9b7b0..abb65cd0 100644 --- a/bootstrap/unix-44/OPM.c +++ b/bootstrap/unix-44/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/OPM.h b/bootstrap/unix-44/OPM.h index d2a06df9..e18ab6ff 100644 --- a/bootstrap/unix-44/OPM.h +++ b/bootstrap/unix-44/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-44/OPP.c b/bootstrap/unix-44/OPP.c index 768bfd2c..10e8168f 100644 --- a/bootstrap/unix-44/OPP.c +++ b/bootstrap/unix-44/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/OPP.h b/bootstrap/unix-44/OPP.h index ee87db69..49d03b82 100644 --- a/bootstrap/unix-44/OPP.h +++ b/bootstrap/unix-44/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-44/OPS.c b/bootstrap/unix-44/OPS.c index 02c301dc..288a081d 100644 --- a/bootstrap/unix-44/OPS.c +++ b/bootstrap/unix-44/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/OPS.h b/bootstrap/unix-44/OPS.h index 98dd65e7..bc45e385 100644 --- a/bootstrap/unix-44/OPS.h +++ b/bootstrap/unix-44/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-44/OPT.c b/bootstrap/unix-44/OPT.c index f9666e9a..9ec11e5d 100644 --- a/bootstrap/unix-44/OPT.c +++ b/bootstrap/unix-44/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/OPT.h b/bootstrap/unix-44/OPT.h index f5b615f8..95947e81 100644 --- a/bootstrap/unix-44/OPT.h +++ b/bootstrap/unix-44/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-44/OPV.c b/bootstrap/unix-44/OPV.c index ce5e3036..96075563 100644 --- a/bootstrap/unix-44/OPV.c +++ b/bootstrap/unix-44/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/OPV.h b/bootstrap/unix-44/OPV.h index 43fd6331..0d54d226 100644 --- a/bootstrap/unix-44/OPV.h +++ b/bootstrap/unix-44/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-44/Out.c b/bootstrap/unix-44/Out.c index 37cb4c91..3df836a0 100644 --- a/bootstrap/unix-44/Out.c +++ b/bootstrap/unix-44/Out.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -7,34 +7,63 @@ #include "SYSTEM.h" #include "Platform.h" -#include "Strings.h" +static CHAR Out_buf[128]; +static int16 Out_in; export void Out_Char (CHAR ch); +export void Out_Flush (void); export void Out_Int (int64 x, int64 n); +static int32 Out_Length (CHAR *s, LONGINT s__len); export void Out_Ln (void); export void Out_LongReal (LONGREAL x, int16 n); export void Out_Open (void); export void Out_Real (REAL x, int16 n); +static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp); export void Out_String (CHAR *str, LONGINT str__len); -export REAL Out_Ten (int16 e); -static LONGREAL Out_TenL (int16 e); +export LONGREAL Out_Ten (int16 e); static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i); static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 *i); -#define Out_Entier32(x) (int32)(x) #define Out_Entier64(x) (int64)(x) +void Out_Flush (void) +{ + int16 error; + if (Out_in > 0) { + error = Platform_Write(1, (address)Out_buf, Out_in); + } + Out_in = 0; +} + void Out_Open (void) { } void Out_Char (CHAR ch) { - int16 error; - error = Platform_Write(1, (address)&ch, 1); + if (Out_in >= 128) { + Out_Flush(); + } + Out_buf[__X(Out_in, 128)] = ch; + Out_in += 1; + if (ch == 0x0a) { + Out_Flush(); + } +} + +static int32 Out_Length (CHAR *s, LONGINT s__len) +{ + int32 _o_result; + int32 l; + l = 0; + while ((l < s__len && s[__X(l, s__len)] != 0x00)) { + l += 1; + } + _o_result = l; + return _o_result; } void Out_String (CHAR *str, LONGINT str__len) @@ -42,11 +71,16 @@ void Out_String (CHAR *str, LONGINT str__len) int32 l; int16 error; __DUP(str, str__len, CHAR); - l = 0; - while ((l < str__len && str[__X(l, str__len)] != 0x00)) { - l += 1; + l = Out_Length((void*)str, str__len); + if (Out_in + l > 128) { + Out_Flush(); + } + if (l > 128) { + error = Platform_Write(1, (address)str, l); + } else { + __MOVE((address)str, (address)&Out_buf[__X(Out_in, 128)], l); + Out_in += (int16)l; } - error = Platform_Write(1, (address)str, l); __DEL(str); } @@ -89,6 +123,7 @@ void Out_Int (int64 x, int64 n) void Out_Ln (void) { Out_String(Platform_NL, 3); + Out_Flush(); } static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i) @@ -99,13 +134,14 @@ static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i) static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 *i) { - int16 j, l; + int16 j; + int32 l; __DUP(t, t__len, CHAR); - l = Strings_Length(t, t__len); + l = Out_Length((void*)t, t__len); if (l > *i) { l = *i; } - *i -= l; + *i -= (int16)l; j = 0; while (j < l) { s[__X(*i + j, s__len)] = t[__X(j, t__len)]; @@ -114,116 +150,7 @@ static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 __DEL(t); } -REAL Out_Ten (int16 e) -{ - REAL _o_result; - LONGREAL r, power; - r = (LONGREAL)1; - power = (LONGREAL)10; - while (e > 0) { - if (__ODD(e)) { - r = r * power; - } - power = power * power; - e = __ASHR(e, 1); - } - _o_result = r; - return _o_result; -} - -void Out_Real (REAL x, int16 n) -{ - int16 e; - int32 f; - CHAR s[30]; - int16 i; - REAL x0; - BOOLEAN nn, en; - int32 m; - int16 d; - nn = __VAL(int32, x) < 0; - if (nn) { - n -= 1; - } - e = (int16)__MASK(__ASHR(__VAL(int32, x), 23), -256); - f = __MASK(__VAL(int32, x), -8388608); - i = 30; - if (e == 255) { - if (f == 0) { - Out_prepend((CHAR*)"Infinity", 9, (void*)s, 30, &i); - } else { - Out_prepend((CHAR*)"NaN", 4, (void*)s, 30, &i); - } - } else { - if (e == 0) { - Out_prepend((CHAR*)"E+00", 5, (void*)s, 30, &i); - m = 0; - } else { - if (nn) { - x = -x; - } - e = __ASHR((e - 127) * 77, 8); - if (e >= 0) { - x = x / (REAL)Out_Ten(e); - } else { - x = Out_Ten(-e) * x; - } - if (x >= (REAL)10) { - x = 1.0000000e-001 * x; - e += 1; - } - en = e < 0; - if (en) { - e = -e; - } - d = 2; - while (d > 0) { - Out_digit(e, (void*)s, 30, &i); - e = __DIV(e, 10); - d -= 1; - } - if (en) { - Out_prepend((CHAR*)"E-", 3, (void*)s, 30, &i); - } else { - Out_prepend((CHAR*)"E+", 3, (void*)s, 30, &i); - } - x0 = Out_Ten(7); - x = x0 * x + 5.0000000e-001; - if (x >= (REAL)10 * x0) { - x = 1.0000000e-001 * x; - e += 1; - } - m = Out_Entier32(x); - } - d = 8; - while ((((d > 2 && d > n - 5)) && (int)__MOD(m, 10) == 0)) { - m = __DIV(m, 10); - d -= 1; - } - while (d > 1) { - Out_digit(m, (void*)s, 30, &i); - m = __DIV(m, 10); - d -= 1; - } - i -= 1; - s[__X(i, 30)] = '.'; - Out_digit(m, (void*)s, 30, &i); - } - n -= 30 - i; - while (n > 0) { - Out_Char(' '); - n -= 1; - } - if (nn) { - Out_Char('-'); - } - while (i < 30) { - Out_Char(s[__X(i, 30)]); - i += 1; - } -} - -static LONGREAL Out_TenL (int16 e) +LONGREAL Out_Ten (int16 e) { LONGREAL _o_result; LONGREAL r, power; @@ -240,7 +167,7 @@ static LONGREAL Out_TenL (int16 e) return _o_result; } -void Out_LongReal (LONGREAL x, int16 n) +static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp) { int16 e; int64 f; @@ -249,7 +176,7 @@ void Out_LongReal (LONGREAL x, int16 n) LONGREAL x0; BOOLEAN nn, en; int64 m; - int16 d; + int16 d, dr; nn = __VAL(int64, x) < 0; if (nn) { n -= 1; @@ -265,7 +192,15 @@ void Out_LongReal (LONGREAL x, int16 n) } } else { if (e == 0) { - Out_prepend((CHAR*)"D+000", 6, (void*)s, 30, &i); + d = i - exponentdigits; + while (i > d) { + i -= 1; + s[__X(i, 30)] = '0'; + } + i -= 1; + s[__X(i, 30)] = '+'; + i -= 1; + s[__X(i, 30)] = exp; m = 0; } else { if (nn) { @@ -273,9 +208,9 @@ void Out_LongReal (LONGREAL x, int16 n) } e = (int16)__ASHR((e - 1023) * 77, 8); if (e >= 0) { - x = x / (LONGREAL)Out_TenL(e); + x = x / (LONGREAL)Out_Ten(e); } else { - x = Out_TenL(-e) * x; + x = Out_Ten(-e) * x; } if (x >= (LONGREAL)10) { x = 1.00000000000000e-001 * x; @@ -285,18 +220,21 @@ void Out_LongReal (LONGREAL x, int16 n) if (en) { e = -e; } - d = 3; + d = exponentdigits; while (d > 0) { Out_digit(e, (void*)s, 30, &i); e = __DIV(e, 10); d -= 1; } + i -= 1; if (en) { - Out_prepend((CHAR*)"D-", 3, (void*)s, 30, &i); + s[__X(i, 30)] = '-'; } else { - Out_prepend((CHAR*)"D+", 3, (void*)s, 30, &i); + s[__X(i, 30)] = '+'; } - x0 = Out_TenL(15); + i -= 1; + s[__X(i, 30)] = exp; + x0 = Out_Ten(maxsigdigits - 1); x = x0 * x + 5.00000000000000e-001; if (x >= (LONGREAL)10 * x0) { x = 1.00000000000000e-001 * x; @@ -304,8 +242,12 @@ void Out_LongReal (LONGREAL x, int16 n) } m = Out_Entier64(x); } - d = 16; - while ((((d > 2 && d > n - 6)) && __MOD(m, 10) == 0)) { + d = maxsigdigits; + dr = n - (exponentdigits + 3); + if (dr < 2) { + dr = 2; + } + while ((d > dr && __MOD(m, 10) == 0)) { m = __DIV(m, 10); d -= 1; } @@ -332,13 +274,23 @@ void Out_LongReal (LONGREAL x, int16 n) } } +void Out_Real (REAL x, int16 n) +{ + Out_RealP(x, n, 2, 7, 'E'); +} + +void Out_LongReal (LONGREAL x, int16 n) +{ + Out_RealP(x, n, 3, 16, 'D'); +} + export void *Out__init(void) { __DEFMOD; __MODULE_IMPORT(Platform); - __MODULE_IMPORT(Strings); __REGMOD("Out", 0); + __REGCMD("Flush", Out_Flush); __REGCMD("Ln", Out_Ln); __REGCMD("Open", Out_Open); /* BEGIN */ diff --git a/bootstrap/unix-44/Out.h b/bootstrap/unix-44/Out.h index 9076f6d1..362b4414 100644 --- a/bootstrap/unix-44/Out.h +++ b/bootstrap/unix-44/Out.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Out__h #define Out__h @@ -9,13 +9,14 @@ import void Out_Char (CHAR ch); +import void Out_Flush (void); import void Out_Int (int64 x, int64 n); import void Out_Ln (void); import void Out_LongReal (LONGREAL x, int16 n); import void Out_Open (void); import void Out_Real (REAL x, int16 n); import void Out_String (CHAR *str, LONGINT str__len); -import REAL Out_Ten (int16 e); +import LONGREAL Out_Ten (int16 e); import void *Out__init(void); diff --git a/bootstrap/unix-44/Platform.c b/bootstrap/unix-44/Platform.c index 3ba187a5..0667398d 100644 --- a/bootstrap/unix-44/Platform.c +++ b/bootstrap/unix-44/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/Platform.h b/bootstrap/unix-44/Platform.h index a96c77e9..4897b84e 100644 --- a/bootstrap/unix-44/Platform.h +++ b/bootstrap/unix-44/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-44/Reals.c b/bootstrap/unix-44/Reals.c index 4e18ac01..8697b424 100644 --- a/bootstrap/unix-44/Reals.c +++ b/bootstrap/unix-44/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/Reals.h b/bootstrap/unix-44/Reals.h index 5728d211..e764f95f 100644 --- a/bootstrap/unix-44/Reals.h +++ b/bootstrap/unix-44/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-44/Strings.c b/bootstrap/unix-44/Strings.c index 37643e92..8a95a8eb 100644 --- a/bootstrap/unix-44/Strings.c +++ b/bootstrap/unix-44/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -24,15 +24,22 @@ export void Strings_Replace (CHAR *source, LONGINT source__len, int16 pos, CHAR int16 Strings_Length (CHAR *s, LONGINT s__len) { int16 _o_result; - int16 i; + int32 i; __DUP(s, s__len, CHAR); i = 0; while ((i < s__len && s[__X(i, s__len)] != 0x00)) { i += 1; } - _o_result = i; - __DEL(s); - return _o_result; + if (i <= 32767) { + _o_result = (int16)i; + __DEL(s); + return _o_result; + } else { + _o_result = 32767; + __DEL(s); + return _o_result; + } + __RETCHK; } void Strings_Append (CHAR *extra, LONGINT extra__len, CHAR *dest, LONGINT dest__len) diff --git a/bootstrap/unix-44/Strings.h b/bootstrap/unix-44/Strings.h index b7482150..4989383b 100644 --- a/bootstrap/unix-44/Strings.h +++ b/bootstrap/unix-44/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-44/Texts.c b/bootstrap/unix-44/Texts.c index 340d4654..6fd83b96 100644 --- a/bootstrap/unix-44/Texts.c +++ b/bootstrap/unix-44/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/Texts.h b/bootstrap/unix-44/Texts.h index 0992f4eb..82b41cda 100644 --- a/bootstrap/unix-44/Texts.h +++ b/bootstrap/unix-44/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-44/errors.c b/bootstrap/unix-44/errors.c index 5ecfeea1..408d5ec7 100644 --- a/bootstrap/unix-44/errors.c +++ b/bootstrap/unix-44/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/errors.h b/bootstrap/unix-44/errors.h index 20eeca0d..b0247272 100644 --- a/bootstrap/unix-44/errors.h +++ b/bootstrap/unix-44/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/unix-44/extTools.c b/bootstrap/unix-44/extTools.c index b1328b1c..5df06422 100644 --- a/bootstrap/unix-44/extTools.c +++ b/bootstrap/unix-44/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/extTools.h b/bootstrap/unix-44/extTools.h index 27684ca4..ef0da35c 100644 --- a/bootstrap/unix-44/extTools.h +++ b/bootstrap/unix-44/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-44/vt100.c b/bootstrap/unix-44/vt100.c index a2c7b023..65b16ccc 100644 --- a/bootstrap/unix-44/vt100.c +++ b/bootstrap/unix-44/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/vt100.h b/bootstrap/unix-44/vt100.h index 83b8a893..2211e981 100644 --- a/bootstrap/unix-44/vt100.h +++ b/bootstrap/unix-44/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef vt100__h #define vt100__h diff --git a/bootstrap/unix-48/Compiler.c b/bootstrap/unix-48/Compiler.c index 2dd6f251..b303a7c4 100644 --- a/bootstrap/unix-48/Compiler.c +++ b/bootstrap/unix-48/Compiler.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/Configuration.c b/bootstrap/unix-48/Configuration.c index 3498204c..8ac138be 100644 --- a/bootstrap/unix-48/Configuration.c +++ b/bootstrap/unix-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/unix-48/Configuration.h b/bootstrap/unix-48/Configuration.h index 14d86591..207eeb63 100644 --- a/bootstrap/unix-48/Configuration.h +++ b/bootstrap/unix-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-48/Files.c b/bootstrap/unix-48/Files.c index cb7920a3..c983396b 100644 --- a/bootstrap/unix-48/Files.c +++ b/bootstrap/unix-48/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/Files.h b/bootstrap/unix-48/Files.h index 4a49d744..ba64fc56 100644 --- a/bootstrap/unix-48/Files.h +++ b/bootstrap/unix-48/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-48/Heap.c b/bootstrap/unix-48/Heap.c index 860107f9..8758813f 100644 --- a/bootstrap/unix-48/Heap.c +++ b/bootstrap/unix-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/Heap.h b/bootstrap/unix-48/Heap.h index 84c9bb20..bcf77f96 100644 --- a/bootstrap/unix-48/Heap.h +++ b/bootstrap/unix-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-48/Modules.c b/bootstrap/unix-48/Modules.c index ab3bb29b..5302c9f4 100644 --- a/bootstrap/unix-48/Modules.c +++ b/bootstrap/unix-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/Modules.h b/bootstrap/unix-48/Modules.h index 95fc4f94..abb938ae 100644 --- a/bootstrap/unix-48/Modules.h +++ b/bootstrap/unix-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/unix-48/OPB.c b/bootstrap/unix-48/OPB.c index bfc64251..3233aa7b 100644 --- a/bootstrap/unix-48/OPB.c +++ b/bootstrap/unix-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/OPB.h b/bootstrap/unix-48/OPB.h index d04325c7..6931fe6e 100644 --- a/bootstrap/unix-48/OPB.h +++ b/bootstrap/unix-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-48/OPC.c b/bootstrap/unix-48/OPC.c index 54cd9a85..48f0d967 100644 --- a/bootstrap/unix-48/OPC.c +++ b/bootstrap/unix-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/OPC.h b/bootstrap/unix-48/OPC.h index 69a5580c..40825f04 100644 --- a/bootstrap/unix-48/OPC.h +++ b/bootstrap/unix-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-48/OPM.c b/bootstrap/unix-48/OPM.c index 7da9b7b0..abb65cd0 100644 --- a/bootstrap/unix-48/OPM.c +++ b/bootstrap/unix-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/OPM.h b/bootstrap/unix-48/OPM.h index d2a06df9..e18ab6ff 100644 --- a/bootstrap/unix-48/OPM.h +++ b/bootstrap/unix-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-48/OPP.c b/bootstrap/unix-48/OPP.c index 768bfd2c..10e8168f 100644 --- a/bootstrap/unix-48/OPP.c +++ b/bootstrap/unix-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/OPP.h b/bootstrap/unix-48/OPP.h index ee87db69..49d03b82 100644 --- a/bootstrap/unix-48/OPP.h +++ b/bootstrap/unix-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-48/OPS.c b/bootstrap/unix-48/OPS.c index 02c301dc..288a081d 100644 --- a/bootstrap/unix-48/OPS.c +++ b/bootstrap/unix-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/OPS.h b/bootstrap/unix-48/OPS.h index 98dd65e7..bc45e385 100644 --- a/bootstrap/unix-48/OPS.h +++ b/bootstrap/unix-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-48/OPT.c b/bootstrap/unix-48/OPT.c index 7ebdfd73..55178203 100644 --- a/bootstrap/unix-48/OPT.c +++ b/bootstrap/unix-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/OPT.h b/bootstrap/unix-48/OPT.h index f5b615f8..95947e81 100644 --- a/bootstrap/unix-48/OPT.h +++ b/bootstrap/unix-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-48/OPV.c b/bootstrap/unix-48/OPV.c index ce5e3036..96075563 100644 --- a/bootstrap/unix-48/OPV.c +++ b/bootstrap/unix-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/OPV.h b/bootstrap/unix-48/OPV.h index 43fd6331..0d54d226 100644 --- a/bootstrap/unix-48/OPV.h +++ b/bootstrap/unix-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-48/Out.c b/bootstrap/unix-48/Out.c index 37cb4c91..3df836a0 100644 --- a/bootstrap/unix-48/Out.c +++ b/bootstrap/unix-48/Out.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -7,34 +7,63 @@ #include "SYSTEM.h" #include "Platform.h" -#include "Strings.h" +static CHAR Out_buf[128]; +static int16 Out_in; export void Out_Char (CHAR ch); +export void Out_Flush (void); export void Out_Int (int64 x, int64 n); +static int32 Out_Length (CHAR *s, LONGINT s__len); export void Out_Ln (void); export void Out_LongReal (LONGREAL x, int16 n); export void Out_Open (void); export void Out_Real (REAL x, int16 n); +static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp); export void Out_String (CHAR *str, LONGINT str__len); -export REAL Out_Ten (int16 e); -static LONGREAL Out_TenL (int16 e); +export LONGREAL Out_Ten (int16 e); static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i); static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 *i); -#define Out_Entier32(x) (int32)(x) #define Out_Entier64(x) (int64)(x) +void Out_Flush (void) +{ + int16 error; + if (Out_in > 0) { + error = Platform_Write(1, (address)Out_buf, Out_in); + } + Out_in = 0; +} + void Out_Open (void) { } void Out_Char (CHAR ch) { - int16 error; - error = Platform_Write(1, (address)&ch, 1); + if (Out_in >= 128) { + Out_Flush(); + } + Out_buf[__X(Out_in, 128)] = ch; + Out_in += 1; + if (ch == 0x0a) { + Out_Flush(); + } +} + +static int32 Out_Length (CHAR *s, LONGINT s__len) +{ + int32 _o_result; + int32 l; + l = 0; + while ((l < s__len && s[__X(l, s__len)] != 0x00)) { + l += 1; + } + _o_result = l; + return _o_result; } void Out_String (CHAR *str, LONGINT str__len) @@ -42,11 +71,16 @@ void Out_String (CHAR *str, LONGINT str__len) int32 l; int16 error; __DUP(str, str__len, CHAR); - l = 0; - while ((l < str__len && str[__X(l, str__len)] != 0x00)) { - l += 1; + l = Out_Length((void*)str, str__len); + if (Out_in + l > 128) { + Out_Flush(); + } + if (l > 128) { + error = Platform_Write(1, (address)str, l); + } else { + __MOVE((address)str, (address)&Out_buf[__X(Out_in, 128)], l); + Out_in += (int16)l; } - error = Platform_Write(1, (address)str, l); __DEL(str); } @@ -89,6 +123,7 @@ void Out_Int (int64 x, int64 n) void Out_Ln (void) { Out_String(Platform_NL, 3); + Out_Flush(); } static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i) @@ -99,13 +134,14 @@ static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i) static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 *i) { - int16 j, l; + int16 j; + int32 l; __DUP(t, t__len, CHAR); - l = Strings_Length(t, t__len); + l = Out_Length((void*)t, t__len); if (l > *i) { l = *i; } - *i -= l; + *i -= (int16)l; j = 0; while (j < l) { s[__X(*i + j, s__len)] = t[__X(j, t__len)]; @@ -114,116 +150,7 @@ static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 __DEL(t); } -REAL Out_Ten (int16 e) -{ - REAL _o_result; - LONGREAL r, power; - r = (LONGREAL)1; - power = (LONGREAL)10; - while (e > 0) { - if (__ODD(e)) { - r = r * power; - } - power = power * power; - e = __ASHR(e, 1); - } - _o_result = r; - return _o_result; -} - -void Out_Real (REAL x, int16 n) -{ - int16 e; - int32 f; - CHAR s[30]; - int16 i; - REAL x0; - BOOLEAN nn, en; - int32 m; - int16 d; - nn = __VAL(int32, x) < 0; - if (nn) { - n -= 1; - } - e = (int16)__MASK(__ASHR(__VAL(int32, x), 23), -256); - f = __MASK(__VAL(int32, x), -8388608); - i = 30; - if (e == 255) { - if (f == 0) { - Out_prepend((CHAR*)"Infinity", 9, (void*)s, 30, &i); - } else { - Out_prepend((CHAR*)"NaN", 4, (void*)s, 30, &i); - } - } else { - if (e == 0) { - Out_prepend((CHAR*)"E+00", 5, (void*)s, 30, &i); - m = 0; - } else { - if (nn) { - x = -x; - } - e = __ASHR((e - 127) * 77, 8); - if (e >= 0) { - x = x / (REAL)Out_Ten(e); - } else { - x = Out_Ten(-e) * x; - } - if (x >= (REAL)10) { - x = 1.0000000e-001 * x; - e += 1; - } - en = e < 0; - if (en) { - e = -e; - } - d = 2; - while (d > 0) { - Out_digit(e, (void*)s, 30, &i); - e = __DIV(e, 10); - d -= 1; - } - if (en) { - Out_prepend((CHAR*)"E-", 3, (void*)s, 30, &i); - } else { - Out_prepend((CHAR*)"E+", 3, (void*)s, 30, &i); - } - x0 = Out_Ten(7); - x = x0 * x + 5.0000000e-001; - if (x >= (REAL)10 * x0) { - x = 1.0000000e-001 * x; - e += 1; - } - m = Out_Entier32(x); - } - d = 8; - while ((((d > 2 && d > n - 5)) && (int)__MOD(m, 10) == 0)) { - m = __DIV(m, 10); - d -= 1; - } - while (d > 1) { - Out_digit(m, (void*)s, 30, &i); - m = __DIV(m, 10); - d -= 1; - } - i -= 1; - s[__X(i, 30)] = '.'; - Out_digit(m, (void*)s, 30, &i); - } - n -= 30 - i; - while (n > 0) { - Out_Char(' '); - n -= 1; - } - if (nn) { - Out_Char('-'); - } - while (i < 30) { - Out_Char(s[__X(i, 30)]); - i += 1; - } -} - -static LONGREAL Out_TenL (int16 e) +LONGREAL Out_Ten (int16 e) { LONGREAL _o_result; LONGREAL r, power; @@ -240,7 +167,7 @@ static LONGREAL Out_TenL (int16 e) return _o_result; } -void Out_LongReal (LONGREAL x, int16 n) +static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp) { int16 e; int64 f; @@ -249,7 +176,7 @@ void Out_LongReal (LONGREAL x, int16 n) LONGREAL x0; BOOLEAN nn, en; int64 m; - int16 d; + int16 d, dr; nn = __VAL(int64, x) < 0; if (nn) { n -= 1; @@ -265,7 +192,15 @@ void Out_LongReal (LONGREAL x, int16 n) } } else { if (e == 0) { - Out_prepend((CHAR*)"D+000", 6, (void*)s, 30, &i); + d = i - exponentdigits; + while (i > d) { + i -= 1; + s[__X(i, 30)] = '0'; + } + i -= 1; + s[__X(i, 30)] = '+'; + i -= 1; + s[__X(i, 30)] = exp; m = 0; } else { if (nn) { @@ -273,9 +208,9 @@ void Out_LongReal (LONGREAL x, int16 n) } e = (int16)__ASHR((e - 1023) * 77, 8); if (e >= 0) { - x = x / (LONGREAL)Out_TenL(e); + x = x / (LONGREAL)Out_Ten(e); } else { - x = Out_TenL(-e) * x; + x = Out_Ten(-e) * x; } if (x >= (LONGREAL)10) { x = 1.00000000000000e-001 * x; @@ -285,18 +220,21 @@ void Out_LongReal (LONGREAL x, int16 n) if (en) { e = -e; } - d = 3; + d = exponentdigits; while (d > 0) { Out_digit(e, (void*)s, 30, &i); e = __DIV(e, 10); d -= 1; } + i -= 1; if (en) { - Out_prepend((CHAR*)"D-", 3, (void*)s, 30, &i); + s[__X(i, 30)] = '-'; } else { - Out_prepend((CHAR*)"D+", 3, (void*)s, 30, &i); + s[__X(i, 30)] = '+'; } - x0 = Out_TenL(15); + i -= 1; + s[__X(i, 30)] = exp; + x0 = Out_Ten(maxsigdigits - 1); x = x0 * x + 5.00000000000000e-001; if (x >= (LONGREAL)10 * x0) { x = 1.00000000000000e-001 * x; @@ -304,8 +242,12 @@ void Out_LongReal (LONGREAL x, int16 n) } m = Out_Entier64(x); } - d = 16; - while ((((d > 2 && d > n - 6)) && __MOD(m, 10) == 0)) { + d = maxsigdigits; + dr = n - (exponentdigits + 3); + if (dr < 2) { + dr = 2; + } + while ((d > dr && __MOD(m, 10) == 0)) { m = __DIV(m, 10); d -= 1; } @@ -332,13 +274,23 @@ void Out_LongReal (LONGREAL x, int16 n) } } +void Out_Real (REAL x, int16 n) +{ + Out_RealP(x, n, 2, 7, 'E'); +} + +void Out_LongReal (LONGREAL x, int16 n) +{ + Out_RealP(x, n, 3, 16, 'D'); +} + export void *Out__init(void) { __DEFMOD; __MODULE_IMPORT(Platform); - __MODULE_IMPORT(Strings); __REGMOD("Out", 0); + __REGCMD("Flush", Out_Flush); __REGCMD("Ln", Out_Ln); __REGCMD("Open", Out_Open); /* BEGIN */ diff --git a/bootstrap/unix-48/Out.h b/bootstrap/unix-48/Out.h index 9076f6d1..362b4414 100644 --- a/bootstrap/unix-48/Out.h +++ b/bootstrap/unix-48/Out.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Out__h #define Out__h @@ -9,13 +9,14 @@ import void Out_Char (CHAR ch); +import void Out_Flush (void); import void Out_Int (int64 x, int64 n); import void Out_Ln (void); import void Out_LongReal (LONGREAL x, int16 n); import void Out_Open (void); import void Out_Real (REAL x, int16 n); import void Out_String (CHAR *str, LONGINT str__len); -import REAL Out_Ten (int16 e); +import LONGREAL Out_Ten (int16 e); import void *Out__init(void); diff --git a/bootstrap/unix-48/Platform.c b/bootstrap/unix-48/Platform.c index 3ba187a5..0667398d 100644 --- a/bootstrap/unix-48/Platform.c +++ b/bootstrap/unix-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/Platform.h b/bootstrap/unix-48/Platform.h index a96c77e9..4897b84e 100644 --- a/bootstrap/unix-48/Platform.h +++ b/bootstrap/unix-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-48/Reals.c b/bootstrap/unix-48/Reals.c index 4e18ac01..8697b424 100644 --- a/bootstrap/unix-48/Reals.c +++ b/bootstrap/unix-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/Reals.h b/bootstrap/unix-48/Reals.h index 5728d211..e764f95f 100644 --- a/bootstrap/unix-48/Reals.h +++ b/bootstrap/unix-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-48/Strings.c b/bootstrap/unix-48/Strings.c index 37643e92..8a95a8eb 100644 --- a/bootstrap/unix-48/Strings.c +++ b/bootstrap/unix-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -24,15 +24,22 @@ export void Strings_Replace (CHAR *source, LONGINT source__len, int16 pos, CHAR int16 Strings_Length (CHAR *s, LONGINT s__len) { int16 _o_result; - int16 i; + int32 i; __DUP(s, s__len, CHAR); i = 0; while ((i < s__len && s[__X(i, s__len)] != 0x00)) { i += 1; } - _o_result = i; - __DEL(s); - return _o_result; + if (i <= 32767) { + _o_result = (int16)i; + __DEL(s); + return _o_result; + } else { + _o_result = 32767; + __DEL(s); + return _o_result; + } + __RETCHK; } void Strings_Append (CHAR *extra, LONGINT extra__len, CHAR *dest, LONGINT dest__len) diff --git a/bootstrap/unix-48/Strings.h b/bootstrap/unix-48/Strings.h index b7482150..4989383b 100644 --- a/bootstrap/unix-48/Strings.h +++ b/bootstrap/unix-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-48/Texts.c b/bootstrap/unix-48/Texts.c index 92376713..421c5f47 100644 --- a/bootstrap/unix-48/Texts.c +++ b/bootstrap/unix-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/Texts.h b/bootstrap/unix-48/Texts.h index 107cdc6c..e27e5f53 100644 --- a/bootstrap/unix-48/Texts.h +++ b/bootstrap/unix-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-48/errors.c b/bootstrap/unix-48/errors.c index 5ecfeea1..408d5ec7 100644 --- a/bootstrap/unix-48/errors.c +++ b/bootstrap/unix-48/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/errors.h b/bootstrap/unix-48/errors.h index 20eeca0d..b0247272 100644 --- a/bootstrap/unix-48/errors.h +++ b/bootstrap/unix-48/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/unix-48/extTools.c b/bootstrap/unix-48/extTools.c index b1328b1c..5df06422 100644 --- a/bootstrap/unix-48/extTools.c +++ b/bootstrap/unix-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/extTools.h b/bootstrap/unix-48/extTools.h index 27684ca4..ef0da35c 100644 --- a/bootstrap/unix-48/extTools.h +++ b/bootstrap/unix-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-48/vt100.c b/bootstrap/unix-48/vt100.c index a2c7b023..65b16ccc 100644 --- a/bootstrap/unix-48/vt100.c +++ b/bootstrap/unix-48/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/vt100.h b/bootstrap/unix-48/vt100.h index 83b8a893..2211e981 100644 --- a/bootstrap/unix-48/vt100.h +++ b/bootstrap/unix-48/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef vt100__h #define vt100__h diff --git a/bootstrap/unix-88/Compiler.c b/bootstrap/unix-88/Compiler.c index 2dd6f251..b303a7c4 100644 --- a/bootstrap/unix-88/Compiler.c +++ b/bootstrap/unix-88/Compiler.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/Configuration.c b/bootstrap/unix-88/Configuration.c index 3498204c..8ac138be 100644 --- a/bootstrap/unix-88/Configuration.c +++ b/bootstrap/unix-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/unix-88/Configuration.h b/bootstrap/unix-88/Configuration.h index 14d86591..207eeb63 100644 --- a/bootstrap/unix-88/Configuration.h +++ b/bootstrap/unix-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-88/Files.c b/bootstrap/unix-88/Files.c index 2324bd31..00efd9fc 100644 --- a/bootstrap/unix-88/Files.c +++ b/bootstrap/unix-88/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/Files.h b/bootstrap/unix-88/Files.h index 5156a13d..1e455c40 100644 --- a/bootstrap/unix-88/Files.h +++ b/bootstrap/unix-88/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-88/Heap.c b/bootstrap/unix-88/Heap.c index e3aceaf6..b09688eb 100644 --- a/bootstrap/unix-88/Heap.c +++ b/bootstrap/unix-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/Heap.h b/bootstrap/unix-88/Heap.h index 29ed6e2f..a5b2fe18 100644 --- a/bootstrap/unix-88/Heap.h +++ b/bootstrap/unix-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-88/Modules.c b/bootstrap/unix-88/Modules.c index 273f6c11..73f0a95b 100644 --- a/bootstrap/unix-88/Modules.c +++ b/bootstrap/unix-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/Modules.h b/bootstrap/unix-88/Modules.h index 95fc4f94..abb938ae 100644 --- a/bootstrap/unix-88/Modules.h +++ b/bootstrap/unix-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/unix-88/OPB.c b/bootstrap/unix-88/OPB.c index bfc64251..3233aa7b 100644 --- a/bootstrap/unix-88/OPB.c +++ b/bootstrap/unix-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/OPB.h b/bootstrap/unix-88/OPB.h index d04325c7..6931fe6e 100644 --- a/bootstrap/unix-88/OPB.h +++ b/bootstrap/unix-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-88/OPC.c b/bootstrap/unix-88/OPC.c index 54cd9a85..48f0d967 100644 --- a/bootstrap/unix-88/OPC.c +++ b/bootstrap/unix-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/OPC.h b/bootstrap/unix-88/OPC.h index 69a5580c..40825f04 100644 --- a/bootstrap/unix-88/OPC.h +++ b/bootstrap/unix-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-88/OPM.c b/bootstrap/unix-88/OPM.c index ec6acf95..f377d2a5 100644 --- a/bootstrap/unix-88/OPM.c +++ b/bootstrap/unix-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/OPM.h b/bootstrap/unix-88/OPM.h index d2a06df9..e18ab6ff 100644 --- a/bootstrap/unix-88/OPM.h +++ b/bootstrap/unix-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-88/OPP.c b/bootstrap/unix-88/OPP.c index ddd0d49c..5c4e3c07 100644 --- a/bootstrap/unix-88/OPP.c +++ b/bootstrap/unix-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/OPP.h b/bootstrap/unix-88/OPP.h index ee87db69..49d03b82 100644 --- a/bootstrap/unix-88/OPP.h +++ b/bootstrap/unix-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-88/OPS.c b/bootstrap/unix-88/OPS.c index 02c301dc..288a081d 100644 --- a/bootstrap/unix-88/OPS.c +++ b/bootstrap/unix-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/OPS.h b/bootstrap/unix-88/OPS.h index 98dd65e7..bc45e385 100644 --- a/bootstrap/unix-88/OPS.h +++ b/bootstrap/unix-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-88/OPT.c b/bootstrap/unix-88/OPT.c index 60915d55..3e3e97fb 100644 --- a/bootstrap/unix-88/OPT.c +++ b/bootstrap/unix-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/OPT.h b/bootstrap/unix-88/OPT.h index f5b615f8..95947e81 100644 --- a/bootstrap/unix-88/OPT.h +++ b/bootstrap/unix-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-88/OPV.c b/bootstrap/unix-88/OPV.c index e3b8aff9..fd84941f 100644 --- a/bootstrap/unix-88/OPV.c +++ b/bootstrap/unix-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/OPV.h b/bootstrap/unix-88/OPV.h index 43fd6331..0d54d226 100644 --- a/bootstrap/unix-88/OPV.h +++ b/bootstrap/unix-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-88/Out.c b/bootstrap/unix-88/Out.c index 37cb4c91..3df836a0 100644 --- a/bootstrap/unix-88/Out.c +++ b/bootstrap/unix-88/Out.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -7,34 +7,63 @@ #include "SYSTEM.h" #include "Platform.h" -#include "Strings.h" +static CHAR Out_buf[128]; +static int16 Out_in; export void Out_Char (CHAR ch); +export void Out_Flush (void); export void Out_Int (int64 x, int64 n); +static int32 Out_Length (CHAR *s, LONGINT s__len); export void Out_Ln (void); export void Out_LongReal (LONGREAL x, int16 n); export void Out_Open (void); export void Out_Real (REAL x, int16 n); +static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp); export void Out_String (CHAR *str, LONGINT str__len); -export REAL Out_Ten (int16 e); -static LONGREAL Out_TenL (int16 e); +export LONGREAL Out_Ten (int16 e); static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i); static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 *i); -#define Out_Entier32(x) (int32)(x) #define Out_Entier64(x) (int64)(x) +void Out_Flush (void) +{ + int16 error; + if (Out_in > 0) { + error = Platform_Write(1, (address)Out_buf, Out_in); + } + Out_in = 0; +} + void Out_Open (void) { } void Out_Char (CHAR ch) { - int16 error; - error = Platform_Write(1, (address)&ch, 1); + if (Out_in >= 128) { + Out_Flush(); + } + Out_buf[__X(Out_in, 128)] = ch; + Out_in += 1; + if (ch == 0x0a) { + Out_Flush(); + } +} + +static int32 Out_Length (CHAR *s, LONGINT s__len) +{ + int32 _o_result; + int32 l; + l = 0; + while ((l < s__len && s[__X(l, s__len)] != 0x00)) { + l += 1; + } + _o_result = l; + return _o_result; } void Out_String (CHAR *str, LONGINT str__len) @@ -42,11 +71,16 @@ void Out_String (CHAR *str, LONGINT str__len) int32 l; int16 error; __DUP(str, str__len, CHAR); - l = 0; - while ((l < str__len && str[__X(l, str__len)] != 0x00)) { - l += 1; + l = Out_Length((void*)str, str__len); + if (Out_in + l > 128) { + Out_Flush(); + } + if (l > 128) { + error = Platform_Write(1, (address)str, l); + } else { + __MOVE((address)str, (address)&Out_buf[__X(Out_in, 128)], l); + Out_in += (int16)l; } - error = Platform_Write(1, (address)str, l); __DEL(str); } @@ -89,6 +123,7 @@ void Out_Int (int64 x, int64 n) void Out_Ln (void) { Out_String(Platform_NL, 3); + Out_Flush(); } static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i) @@ -99,13 +134,14 @@ static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i) static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 *i) { - int16 j, l; + int16 j; + int32 l; __DUP(t, t__len, CHAR); - l = Strings_Length(t, t__len); + l = Out_Length((void*)t, t__len); if (l > *i) { l = *i; } - *i -= l; + *i -= (int16)l; j = 0; while (j < l) { s[__X(*i + j, s__len)] = t[__X(j, t__len)]; @@ -114,116 +150,7 @@ static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 __DEL(t); } -REAL Out_Ten (int16 e) -{ - REAL _o_result; - LONGREAL r, power; - r = (LONGREAL)1; - power = (LONGREAL)10; - while (e > 0) { - if (__ODD(e)) { - r = r * power; - } - power = power * power; - e = __ASHR(e, 1); - } - _o_result = r; - return _o_result; -} - -void Out_Real (REAL x, int16 n) -{ - int16 e; - int32 f; - CHAR s[30]; - int16 i; - REAL x0; - BOOLEAN nn, en; - int32 m; - int16 d; - nn = __VAL(int32, x) < 0; - if (nn) { - n -= 1; - } - e = (int16)__MASK(__ASHR(__VAL(int32, x), 23), -256); - f = __MASK(__VAL(int32, x), -8388608); - i = 30; - if (e == 255) { - if (f == 0) { - Out_prepend((CHAR*)"Infinity", 9, (void*)s, 30, &i); - } else { - Out_prepend((CHAR*)"NaN", 4, (void*)s, 30, &i); - } - } else { - if (e == 0) { - Out_prepend((CHAR*)"E+00", 5, (void*)s, 30, &i); - m = 0; - } else { - if (nn) { - x = -x; - } - e = __ASHR((e - 127) * 77, 8); - if (e >= 0) { - x = x / (REAL)Out_Ten(e); - } else { - x = Out_Ten(-e) * x; - } - if (x >= (REAL)10) { - x = 1.0000000e-001 * x; - e += 1; - } - en = e < 0; - if (en) { - e = -e; - } - d = 2; - while (d > 0) { - Out_digit(e, (void*)s, 30, &i); - e = __DIV(e, 10); - d -= 1; - } - if (en) { - Out_prepend((CHAR*)"E-", 3, (void*)s, 30, &i); - } else { - Out_prepend((CHAR*)"E+", 3, (void*)s, 30, &i); - } - x0 = Out_Ten(7); - x = x0 * x + 5.0000000e-001; - if (x >= (REAL)10 * x0) { - x = 1.0000000e-001 * x; - e += 1; - } - m = Out_Entier32(x); - } - d = 8; - while ((((d > 2 && d > n - 5)) && (int)__MOD(m, 10) == 0)) { - m = __DIV(m, 10); - d -= 1; - } - while (d > 1) { - Out_digit(m, (void*)s, 30, &i); - m = __DIV(m, 10); - d -= 1; - } - i -= 1; - s[__X(i, 30)] = '.'; - Out_digit(m, (void*)s, 30, &i); - } - n -= 30 - i; - while (n > 0) { - Out_Char(' '); - n -= 1; - } - if (nn) { - Out_Char('-'); - } - while (i < 30) { - Out_Char(s[__X(i, 30)]); - i += 1; - } -} - -static LONGREAL Out_TenL (int16 e) +LONGREAL Out_Ten (int16 e) { LONGREAL _o_result; LONGREAL r, power; @@ -240,7 +167,7 @@ static LONGREAL Out_TenL (int16 e) return _o_result; } -void Out_LongReal (LONGREAL x, int16 n) +static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp) { int16 e; int64 f; @@ -249,7 +176,7 @@ void Out_LongReal (LONGREAL x, int16 n) LONGREAL x0; BOOLEAN nn, en; int64 m; - int16 d; + int16 d, dr; nn = __VAL(int64, x) < 0; if (nn) { n -= 1; @@ -265,7 +192,15 @@ void Out_LongReal (LONGREAL x, int16 n) } } else { if (e == 0) { - Out_prepend((CHAR*)"D+000", 6, (void*)s, 30, &i); + d = i - exponentdigits; + while (i > d) { + i -= 1; + s[__X(i, 30)] = '0'; + } + i -= 1; + s[__X(i, 30)] = '+'; + i -= 1; + s[__X(i, 30)] = exp; m = 0; } else { if (nn) { @@ -273,9 +208,9 @@ void Out_LongReal (LONGREAL x, int16 n) } e = (int16)__ASHR((e - 1023) * 77, 8); if (e >= 0) { - x = x / (LONGREAL)Out_TenL(e); + x = x / (LONGREAL)Out_Ten(e); } else { - x = Out_TenL(-e) * x; + x = Out_Ten(-e) * x; } if (x >= (LONGREAL)10) { x = 1.00000000000000e-001 * x; @@ -285,18 +220,21 @@ void Out_LongReal (LONGREAL x, int16 n) if (en) { e = -e; } - d = 3; + d = exponentdigits; while (d > 0) { Out_digit(e, (void*)s, 30, &i); e = __DIV(e, 10); d -= 1; } + i -= 1; if (en) { - Out_prepend((CHAR*)"D-", 3, (void*)s, 30, &i); + s[__X(i, 30)] = '-'; } else { - Out_prepend((CHAR*)"D+", 3, (void*)s, 30, &i); + s[__X(i, 30)] = '+'; } - x0 = Out_TenL(15); + i -= 1; + s[__X(i, 30)] = exp; + x0 = Out_Ten(maxsigdigits - 1); x = x0 * x + 5.00000000000000e-001; if (x >= (LONGREAL)10 * x0) { x = 1.00000000000000e-001 * x; @@ -304,8 +242,12 @@ void Out_LongReal (LONGREAL x, int16 n) } m = Out_Entier64(x); } - d = 16; - while ((((d > 2 && d > n - 6)) && __MOD(m, 10) == 0)) { + d = maxsigdigits; + dr = n - (exponentdigits + 3); + if (dr < 2) { + dr = 2; + } + while ((d > dr && __MOD(m, 10) == 0)) { m = __DIV(m, 10); d -= 1; } @@ -332,13 +274,23 @@ void Out_LongReal (LONGREAL x, int16 n) } } +void Out_Real (REAL x, int16 n) +{ + Out_RealP(x, n, 2, 7, 'E'); +} + +void Out_LongReal (LONGREAL x, int16 n) +{ + Out_RealP(x, n, 3, 16, 'D'); +} + export void *Out__init(void) { __DEFMOD; __MODULE_IMPORT(Platform); - __MODULE_IMPORT(Strings); __REGMOD("Out", 0); + __REGCMD("Flush", Out_Flush); __REGCMD("Ln", Out_Ln); __REGCMD("Open", Out_Open); /* BEGIN */ diff --git a/bootstrap/unix-88/Out.h b/bootstrap/unix-88/Out.h index 9076f6d1..362b4414 100644 --- a/bootstrap/unix-88/Out.h +++ b/bootstrap/unix-88/Out.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Out__h #define Out__h @@ -9,13 +9,14 @@ import void Out_Char (CHAR ch); +import void Out_Flush (void); import void Out_Int (int64 x, int64 n); import void Out_Ln (void); import void Out_LongReal (LONGREAL x, int16 n); import void Out_Open (void); import void Out_Real (REAL x, int16 n); import void Out_String (CHAR *str, LONGINT str__len); -import REAL Out_Ten (int16 e); +import LONGREAL Out_Ten (int16 e); import void *Out__init(void); diff --git a/bootstrap/unix-88/Platform.c b/bootstrap/unix-88/Platform.c index feddb176..ddd65b5f 100644 --- a/bootstrap/unix-88/Platform.c +++ b/bootstrap/unix-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/Platform.h b/bootstrap/unix-88/Platform.h index ffacb767..f2194f3c 100644 --- a/bootstrap/unix-88/Platform.h +++ b/bootstrap/unix-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-88/Reals.c b/bootstrap/unix-88/Reals.c index 4e18ac01..8697b424 100644 --- a/bootstrap/unix-88/Reals.c +++ b/bootstrap/unix-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/Reals.h b/bootstrap/unix-88/Reals.h index 5728d211..e764f95f 100644 --- a/bootstrap/unix-88/Reals.h +++ b/bootstrap/unix-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/unix-88/Strings.c b/bootstrap/unix-88/Strings.c index 37643e92..8a95a8eb 100644 --- a/bootstrap/unix-88/Strings.c +++ b/bootstrap/unix-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -24,15 +24,22 @@ export void Strings_Replace (CHAR *source, LONGINT source__len, int16 pos, CHAR int16 Strings_Length (CHAR *s, LONGINT s__len) { int16 _o_result; - int16 i; + int32 i; __DUP(s, s__len, CHAR); i = 0; while ((i < s__len && s[__X(i, s__len)] != 0x00)) { i += 1; } - _o_result = i; - __DEL(s); - return _o_result; + if (i <= 32767) { + _o_result = (int16)i; + __DEL(s); + return _o_result; + } else { + _o_result = 32767; + __DEL(s); + return _o_result; + } + __RETCHK; } void Strings_Append (CHAR *extra, LONGINT extra__len, CHAR *dest, LONGINT dest__len) diff --git a/bootstrap/unix-88/Strings.h b/bootstrap/unix-88/Strings.h index b7482150..4989383b 100644 --- a/bootstrap/unix-88/Strings.h +++ b/bootstrap/unix-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-88/Texts.c b/bootstrap/unix-88/Texts.c index 0d2f319e..ce4a885a 100644 --- a/bootstrap/unix-88/Texts.c +++ b/bootstrap/unix-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/Texts.h b/bootstrap/unix-88/Texts.h index 4b01b650..26669d1c 100644 --- a/bootstrap/unix-88/Texts.h +++ b/bootstrap/unix-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-88/errors.c b/bootstrap/unix-88/errors.c index 5ecfeea1..408d5ec7 100644 --- a/bootstrap/unix-88/errors.c +++ b/bootstrap/unix-88/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/errors.h b/bootstrap/unix-88/errors.h index 20eeca0d..b0247272 100644 --- a/bootstrap/unix-88/errors.h +++ b/bootstrap/unix-88/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/unix-88/extTools.c b/bootstrap/unix-88/extTools.c index b1328b1c..5df06422 100644 --- a/bootstrap/unix-88/extTools.c +++ b/bootstrap/unix-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/extTools.h b/bootstrap/unix-88/extTools.h index 27684ca4..ef0da35c 100644 --- a/bootstrap/unix-88/extTools.h +++ b/bootstrap/unix-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-88/vt100.c b/bootstrap/unix-88/vt100.c index a2c7b023..65b16ccc 100644 --- a/bootstrap/unix-88/vt100.c +++ b/bootstrap/unix-88/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/vt100.h b/bootstrap/unix-88/vt100.h index 83b8a893..2211e981 100644 --- a/bootstrap/unix-88/vt100.h +++ b/bootstrap/unix-88/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef vt100__h #define vt100__h diff --git a/bootstrap/windows-48/Compiler.c b/bootstrap/windows-48/Compiler.c index 2dd6f251..b303a7c4 100644 --- a/bootstrap/windows-48/Compiler.c +++ b/bootstrap/windows-48/Compiler.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/Configuration.c b/bootstrap/windows-48/Configuration.c index 3498204c..8ac138be 100644 --- a/bootstrap/windows-48/Configuration.c +++ b/bootstrap/windows-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/windows-48/Configuration.h b/bootstrap/windows-48/Configuration.h index 14d86591..207eeb63 100644 --- a/bootstrap/windows-48/Configuration.h +++ b/bootstrap/windows-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/windows-48/Files.c b/bootstrap/windows-48/Files.c index a444fff2..0c55ce0a 100644 --- a/bootstrap/windows-48/Files.c +++ b/bootstrap/windows-48/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/Files.h b/bootstrap/windows-48/Files.h index a447dbad..8cee9102 100644 --- a/bootstrap/windows-48/Files.h +++ b/bootstrap/windows-48/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/windows-48/Heap.c b/bootstrap/windows-48/Heap.c index 860107f9..8758813f 100644 --- a/bootstrap/windows-48/Heap.c +++ b/bootstrap/windows-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/Heap.h b/bootstrap/windows-48/Heap.h index 84c9bb20..bcf77f96 100644 --- a/bootstrap/windows-48/Heap.h +++ b/bootstrap/windows-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/windows-48/Modules.c b/bootstrap/windows-48/Modules.c index ab3bb29b..5302c9f4 100644 --- a/bootstrap/windows-48/Modules.c +++ b/bootstrap/windows-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/Modules.h b/bootstrap/windows-48/Modules.h index 95fc4f94..abb938ae 100644 --- a/bootstrap/windows-48/Modules.h +++ b/bootstrap/windows-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/windows-48/OPB.c b/bootstrap/windows-48/OPB.c index bfc64251..3233aa7b 100644 --- a/bootstrap/windows-48/OPB.c +++ b/bootstrap/windows-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/OPB.h b/bootstrap/windows-48/OPB.h index d04325c7..6931fe6e 100644 --- a/bootstrap/windows-48/OPB.h +++ b/bootstrap/windows-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/windows-48/OPC.c b/bootstrap/windows-48/OPC.c index 54cd9a85..48f0d967 100644 --- a/bootstrap/windows-48/OPC.c +++ b/bootstrap/windows-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/OPC.h b/bootstrap/windows-48/OPC.h index 69a5580c..40825f04 100644 --- a/bootstrap/windows-48/OPC.h +++ b/bootstrap/windows-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/windows-48/OPM.c b/bootstrap/windows-48/OPM.c index 7da9b7b0..abb65cd0 100644 --- a/bootstrap/windows-48/OPM.c +++ b/bootstrap/windows-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/OPM.h b/bootstrap/windows-48/OPM.h index d2a06df9..e18ab6ff 100644 --- a/bootstrap/windows-48/OPM.h +++ b/bootstrap/windows-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/windows-48/OPP.c b/bootstrap/windows-48/OPP.c index 768bfd2c..10e8168f 100644 --- a/bootstrap/windows-48/OPP.c +++ b/bootstrap/windows-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/OPP.h b/bootstrap/windows-48/OPP.h index ee87db69..49d03b82 100644 --- a/bootstrap/windows-48/OPP.h +++ b/bootstrap/windows-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/windows-48/OPS.c b/bootstrap/windows-48/OPS.c index 02c301dc..288a081d 100644 --- a/bootstrap/windows-48/OPS.c +++ b/bootstrap/windows-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/OPS.h b/bootstrap/windows-48/OPS.h index 98dd65e7..bc45e385 100644 --- a/bootstrap/windows-48/OPS.h +++ b/bootstrap/windows-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/windows-48/OPT.c b/bootstrap/windows-48/OPT.c index 7ebdfd73..55178203 100644 --- a/bootstrap/windows-48/OPT.c +++ b/bootstrap/windows-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/OPT.h b/bootstrap/windows-48/OPT.h index f5b615f8..95947e81 100644 --- a/bootstrap/windows-48/OPT.h +++ b/bootstrap/windows-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/windows-48/OPV.c b/bootstrap/windows-48/OPV.c index ce5e3036..96075563 100644 --- a/bootstrap/windows-48/OPV.c +++ b/bootstrap/windows-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/OPV.h b/bootstrap/windows-48/OPV.h index 43fd6331..0d54d226 100644 --- a/bootstrap/windows-48/OPV.h +++ b/bootstrap/windows-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/windows-48/Out.c b/bootstrap/windows-48/Out.c index 790b4f75..b21d426b 100644 --- a/bootstrap/windows-48/Out.c +++ b/bootstrap/windows-48/Out.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -7,34 +7,63 @@ #include "SYSTEM.h" #include "Platform.h" -#include "Strings.h" +static CHAR Out_buf[128]; +static int16 Out_in; export void Out_Char (CHAR ch); +export void Out_Flush (void); export void Out_Int (int64 x, int64 n); +static int32 Out_Length (CHAR *s, LONGINT s__len); export void Out_Ln (void); export void Out_LongReal (LONGREAL x, int16 n); export void Out_Open (void); export void Out_Real (REAL x, int16 n); +static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp); export void Out_String (CHAR *str, LONGINT str__len); -export REAL Out_Ten (int16 e); -static LONGREAL Out_TenL (int16 e); +export LONGREAL Out_Ten (int16 e); static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i); static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 *i); -#define Out_Entier32(x) (int32)(x) #define Out_Entier64(x) (int64)(x) +void Out_Flush (void) +{ + int16 error; + if (Out_in > 0) { + error = Platform_Write(Platform_StdOut, (address)Out_buf, Out_in); + } + Out_in = 0; +} + void Out_Open (void) { } void Out_Char (CHAR ch) { - int16 error; - error = Platform_Write(Platform_StdOut, (address)&ch, 1); + if (Out_in >= 128) { + Out_Flush(); + } + Out_buf[__X(Out_in, 128)] = ch; + Out_in += 1; + if (ch == 0x0a) { + Out_Flush(); + } +} + +static int32 Out_Length (CHAR *s, LONGINT s__len) +{ + int32 _o_result; + int32 l; + l = 0; + while ((l < s__len && s[__X(l, s__len)] != 0x00)) { + l += 1; + } + _o_result = l; + return _o_result; } void Out_String (CHAR *str, LONGINT str__len) @@ -42,11 +71,16 @@ void Out_String (CHAR *str, LONGINT str__len) int32 l; int16 error; __DUP(str, str__len, CHAR); - l = 0; - while ((l < str__len && str[__X(l, str__len)] != 0x00)) { - l += 1; + l = Out_Length((void*)str, str__len); + if (Out_in + l > 128) { + Out_Flush(); + } + if (l > 128) { + error = Platform_Write(Platform_StdOut, (address)str, l); + } else { + __MOVE((address)str, (address)&Out_buf[__X(Out_in, 128)], l); + Out_in += (int16)l; } - error = Platform_Write(Platform_StdOut, (address)str, l); __DEL(str); } @@ -89,6 +123,7 @@ void Out_Int (int64 x, int64 n) void Out_Ln (void) { Out_String(Platform_NL, 3); + Out_Flush(); } static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i) @@ -99,13 +134,14 @@ static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i) static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 *i) { - int16 j, l; + int16 j; + int32 l; __DUP(t, t__len, CHAR); - l = Strings_Length(t, t__len); + l = Out_Length((void*)t, t__len); if (l > *i) { l = *i; } - *i -= l; + *i -= (int16)l; j = 0; while (j < l) { s[__X(*i + j, s__len)] = t[__X(j, t__len)]; @@ -114,116 +150,7 @@ static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 __DEL(t); } -REAL Out_Ten (int16 e) -{ - REAL _o_result; - LONGREAL r, power; - r = (LONGREAL)1; - power = (LONGREAL)10; - while (e > 0) { - if (__ODD(e)) { - r = r * power; - } - power = power * power; - e = __ASHR(e, 1); - } - _o_result = r; - return _o_result; -} - -void Out_Real (REAL x, int16 n) -{ - int16 e; - int32 f; - CHAR s[30]; - int16 i; - REAL x0; - BOOLEAN nn, en; - int32 m; - int16 d; - nn = __VAL(int32, x) < 0; - if (nn) { - n -= 1; - } - e = (int16)__MASK(__ASHR(__VAL(int32, x), 23), -256); - f = __MASK(__VAL(int32, x), -8388608); - i = 30; - if (e == 255) { - if (f == 0) { - Out_prepend((CHAR*)"Infinity", 9, (void*)s, 30, &i); - } else { - Out_prepend((CHAR*)"NaN", 4, (void*)s, 30, &i); - } - } else { - if (e == 0) { - Out_prepend((CHAR*)"E+00", 5, (void*)s, 30, &i); - m = 0; - } else { - if (nn) { - x = -x; - } - e = __ASHR((e - 127) * 77, 8); - if (e >= 0) { - x = x / (REAL)Out_Ten(e); - } else { - x = Out_Ten(-e) * x; - } - if (x >= (REAL)10) { - x = 1.0000000e-001 * x; - e += 1; - } - en = e < 0; - if (en) { - e = -e; - } - d = 2; - while (d > 0) { - Out_digit(e, (void*)s, 30, &i); - e = __DIV(e, 10); - d -= 1; - } - if (en) { - Out_prepend((CHAR*)"E-", 3, (void*)s, 30, &i); - } else { - Out_prepend((CHAR*)"E+", 3, (void*)s, 30, &i); - } - x0 = Out_Ten(7); - x = x0 * x + 5.0000000e-001; - if (x >= (REAL)10 * x0) { - x = 1.0000000e-001 * x; - e += 1; - } - m = Out_Entier32(x); - } - d = 8; - while ((((d > 2 && d > n - 5)) && (int)__MOD(m, 10) == 0)) { - m = __DIV(m, 10); - d -= 1; - } - while (d > 1) { - Out_digit(m, (void*)s, 30, &i); - m = __DIV(m, 10); - d -= 1; - } - i -= 1; - s[__X(i, 30)] = '.'; - Out_digit(m, (void*)s, 30, &i); - } - n -= 30 - i; - while (n > 0) { - Out_Char(' '); - n -= 1; - } - if (nn) { - Out_Char('-'); - } - while (i < 30) { - Out_Char(s[__X(i, 30)]); - i += 1; - } -} - -static LONGREAL Out_TenL (int16 e) +LONGREAL Out_Ten (int16 e) { LONGREAL _o_result; LONGREAL r, power; @@ -240,7 +167,7 @@ static LONGREAL Out_TenL (int16 e) return _o_result; } -void Out_LongReal (LONGREAL x, int16 n) +static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp) { int16 e; int64 f; @@ -249,7 +176,7 @@ void Out_LongReal (LONGREAL x, int16 n) LONGREAL x0; BOOLEAN nn, en; int64 m; - int16 d; + int16 d, dr; nn = __VAL(int64, x) < 0; if (nn) { n -= 1; @@ -265,7 +192,15 @@ void Out_LongReal (LONGREAL x, int16 n) } } else { if (e == 0) { - Out_prepend((CHAR*)"D+000", 6, (void*)s, 30, &i); + d = i - exponentdigits; + while (i > d) { + i -= 1; + s[__X(i, 30)] = '0'; + } + i -= 1; + s[__X(i, 30)] = '+'; + i -= 1; + s[__X(i, 30)] = exp; m = 0; } else { if (nn) { @@ -273,9 +208,9 @@ void Out_LongReal (LONGREAL x, int16 n) } e = (int16)__ASHR((e - 1023) * 77, 8); if (e >= 0) { - x = x / (LONGREAL)Out_TenL(e); + x = x / (LONGREAL)Out_Ten(e); } else { - x = Out_TenL(-e) * x; + x = Out_Ten(-e) * x; } if (x >= (LONGREAL)10) { x = 1.00000000000000e-001 * x; @@ -285,18 +220,21 @@ void Out_LongReal (LONGREAL x, int16 n) if (en) { e = -e; } - d = 3; + d = exponentdigits; while (d > 0) { Out_digit(e, (void*)s, 30, &i); e = __DIV(e, 10); d -= 1; } + i -= 1; if (en) { - Out_prepend((CHAR*)"D-", 3, (void*)s, 30, &i); + s[__X(i, 30)] = '-'; } else { - Out_prepend((CHAR*)"D+", 3, (void*)s, 30, &i); + s[__X(i, 30)] = '+'; } - x0 = Out_TenL(15); + i -= 1; + s[__X(i, 30)] = exp; + x0 = Out_Ten(maxsigdigits - 1); x = x0 * x + 5.00000000000000e-001; if (x >= (LONGREAL)10 * x0) { x = 1.00000000000000e-001 * x; @@ -304,8 +242,12 @@ void Out_LongReal (LONGREAL x, int16 n) } m = Out_Entier64(x); } - d = 16; - while ((((d > 2 && d > n - 6)) && __MOD(m, 10) == 0)) { + d = maxsigdigits; + dr = n - (exponentdigits + 3); + if (dr < 2) { + dr = 2; + } + while ((d > dr && __MOD(m, 10) == 0)) { m = __DIV(m, 10); d -= 1; } @@ -332,13 +274,23 @@ void Out_LongReal (LONGREAL x, int16 n) } } +void Out_Real (REAL x, int16 n) +{ + Out_RealP(x, n, 2, 7, 'E'); +} + +void Out_LongReal (LONGREAL x, int16 n) +{ + Out_RealP(x, n, 3, 16, 'D'); +} + export void *Out__init(void) { __DEFMOD; __MODULE_IMPORT(Platform); - __MODULE_IMPORT(Strings); __REGMOD("Out", 0); + __REGCMD("Flush", Out_Flush); __REGCMD("Ln", Out_Ln); __REGCMD("Open", Out_Open); /* BEGIN */ diff --git a/bootstrap/windows-48/Out.h b/bootstrap/windows-48/Out.h index 9076f6d1..362b4414 100644 --- a/bootstrap/windows-48/Out.h +++ b/bootstrap/windows-48/Out.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Out__h #define Out__h @@ -9,13 +9,14 @@ import void Out_Char (CHAR ch); +import void Out_Flush (void); import void Out_Int (int64 x, int64 n); import void Out_Ln (void); import void Out_LongReal (LONGREAL x, int16 n); import void Out_Open (void); import void Out_Real (REAL x, int16 n); import void Out_String (CHAR *str, LONGINT str__len); -import REAL Out_Ten (int16 e); +import LONGREAL Out_Ten (int16 e); import void *Out__init(void); diff --git a/bootstrap/windows-48/Platform.c b/bootstrap/windows-48/Platform.c index 3e82ab82..d50ae9ec 100644 --- a/bootstrap/windows-48/Platform.c +++ b/bootstrap/windows-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/Platform.h b/bootstrap/windows-48/Platform.h index c5ff14b6..3aa708ca 100644 --- a/bootstrap/windows-48/Platform.h +++ b/bootstrap/windows-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/windows-48/Reals.c b/bootstrap/windows-48/Reals.c index 4e18ac01..8697b424 100644 --- a/bootstrap/windows-48/Reals.c +++ b/bootstrap/windows-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/Reals.h b/bootstrap/windows-48/Reals.h index 5728d211..e764f95f 100644 --- a/bootstrap/windows-48/Reals.h +++ b/bootstrap/windows-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/windows-48/Strings.c b/bootstrap/windows-48/Strings.c index 37643e92..8a95a8eb 100644 --- a/bootstrap/windows-48/Strings.c +++ b/bootstrap/windows-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -24,15 +24,22 @@ export void Strings_Replace (CHAR *source, LONGINT source__len, int16 pos, CHAR int16 Strings_Length (CHAR *s, LONGINT s__len) { int16 _o_result; - int16 i; + int32 i; __DUP(s, s__len, CHAR); i = 0; while ((i < s__len && s[__X(i, s__len)] != 0x00)) { i += 1; } - _o_result = i; - __DEL(s); - return _o_result; + if (i <= 32767) { + _o_result = (int16)i; + __DEL(s); + return _o_result; + } else { + _o_result = 32767; + __DEL(s); + return _o_result; + } + __RETCHK; } void Strings_Append (CHAR *extra, LONGINT extra__len, CHAR *dest, LONGINT dest__len) diff --git a/bootstrap/windows-48/Strings.h b/bootstrap/windows-48/Strings.h index b7482150..4989383b 100644 --- a/bootstrap/windows-48/Strings.h +++ b/bootstrap/windows-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/windows-48/Texts.c b/bootstrap/windows-48/Texts.c index 92376713..421c5f47 100644 --- a/bootstrap/windows-48/Texts.c +++ b/bootstrap/windows-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/Texts.h b/bootstrap/windows-48/Texts.h index 107cdc6c..e27e5f53 100644 --- a/bootstrap/windows-48/Texts.h +++ b/bootstrap/windows-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/windows-48/errors.c b/bootstrap/windows-48/errors.c index 5ecfeea1..408d5ec7 100644 --- a/bootstrap/windows-48/errors.c +++ b/bootstrap/windows-48/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/errors.h b/bootstrap/windows-48/errors.h index 20eeca0d..b0247272 100644 --- a/bootstrap/windows-48/errors.h +++ b/bootstrap/windows-48/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/windows-48/extTools.c b/bootstrap/windows-48/extTools.c index b1328b1c..5df06422 100644 --- a/bootstrap/windows-48/extTools.c +++ b/bootstrap/windows-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/extTools.h b/bootstrap/windows-48/extTools.h index 27684ca4..ef0da35c 100644 --- a/bootstrap/windows-48/extTools.h +++ b/bootstrap/windows-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/windows-48/vt100.c b/bootstrap/windows-48/vt100.c index a2c7b023..65b16ccc 100644 --- a/bootstrap/windows-48/vt100.c +++ b/bootstrap/windows-48/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/vt100.h b/bootstrap/windows-48/vt100.h index 83b8a893..2211e981 100644 --- a/bootstrap/windows-48/vt100.h +++ b/bootstrap/windows-48/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef vt100__h #define vt100__h diff --git a/bootstrap/windows-88/Compiler.c b/bootstrap/windows-88/Compiler.c index 2dd6f251..b303a7c4 100644 --- a/bootstrap/windows-88/Compiler.c +++ b/bootstrap/windows-88/Compiler.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/Configuration.c b/bootstrap/windows-88/Configuration.c index 3498204c..8ac138be 100644 --- a/bootstrap/windows-88/Configuration.c +++ b/bootstrap/windows-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); __ENDMOD; } diff --git a/bootstrap/windows-88/Configuration.h b/bootstrap/windows-88/Configuration.h index 14d86591..207eeb63 100644 --- a/bootstrap/windows-88/Configuration.h +++ b/bootstrap/windows-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/windows-88/Files.c b/bootstrap/windows-88/Files.c index dd50c47a..b9443fd9 100644 --- a/bootstrap/windows-88/Files.c +++ b/bootstrap/windows-88/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/Files.h b/bootstrap/windows-88/Files.h index 99068de9..98e13fc1 100644 --- a/bootstrap/windows-88/Files.h +++ b/bootstrap/windows-88/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/windows-88/Heap.c b/bootstrap/windows-88/Heap.c index e3aceaf6..b09688eb 100644 --- a/bootstrap/windows-88/Heap.c +++ b/bootstrap/windows-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/Heap.h b/bootstrap/windows-88/Heap.h index 29ed6e2f..a5b2fe18 100644 --- a/bootstrap/windows-88/Heap.h +++ b/bootstrap/windows-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/windows-88/Modules.c b/bootstrap/windows-88/Modules.c index 273f6c11..73f0a95b 100644 --- a/bootstrap/windows-88/Modules.c +++ b/bootstrap/windows-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/Modules.h b/bootstrap/windows-88/Modules.h index 95fc4f94..abb938ae 100644 --- a/bootstrap/windows-88/Modules.h +++ b/bootstrap/windows-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/windows-88/OPB.c b/bootstrap/windows-88/OPB.c index bfc64251..3233aa7b 100644 --- a/bootstrap/windows-88/OPB.c +++ b/bootstrap/windows-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/OPB.h b/bootstrap/windows-88/OPB.h index d04325c7..6931fe6e 100644 --- a/bootstrap/windows-88/OPB.h +++ b/bootstrap/windows-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/windows-88/OPC.c b/bootstrap/windows-88/OPC.c index 54cd9a85..48f0d967 100644 --- a/bootstrap/windows-88/OPC.c +++ b/bootstrap/windows-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/OPC.h b/bootstrap/windows-88/OPC.h index 69a5580c..40825f04 100644 --- a/bootstrap/windows-88/OPC.h +++ b/bootstrap/windows-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/windows-88/OPM.c b/bootstrap/windows-88/OPM.c index ec6acf95..f377d2a5 100644 --- a/bootstrap/windows-88/OPM.c +++ b/bootstrap/windows-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/OPM.h b/bootstrap/windows-88/OPM.h index d2a06df9..e18ab6ff 100644 --- a/bootstrap/windows-88/OPM.h +++ b/bootstrap/windows-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/windows-88/OPP.c b/bootstrap/windows-88/OPP.c index ddd0d49c..5c4e3c07 100644 --- a/bootstrap/windows-88/OPP.c +++ b/bootstrap/windows-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/OPP.h b/bootstrap/windows-88/OPP.h index ee87db69..49d03b82 100644 --- a/bootstrap/windows-88/OPP.h +++ b/bootstrap/windows-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/windows-88/OPS.c b/bootstrap/windows-88/OPS.c index 02c301dc..288a081d 100644 --- a/bootstrap/windows-88/OPS.c +++ b/bootstrap/windows-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/OPS.h b/bootstrap/windows-88/OPS.h index 98dd65e7..bc45e385 100644 --- a/bootstrap/windows-88/OPS.h +++ b/bootstrap/windows-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/windows-88/OPT.c b/bootstrap/windows-88/OPT.c index 60915d55..3e3e97fb 100644 --- a/bootstrap/windows-88/OPT.c +++ b/bootstrap/windows-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/OPT.h b/bootstrap/windows-88/OPT.h index f5b615f8..95947e81 100644 --- a/bootstrap/windows-88/OPT.h +++ b/bootstrap/windows-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/windows-88/OPV.c b/bootstrap/windows-88/OPV.c index e3b8aff9..fd84941f 100644 --- a/bootstrap/windows-88/OPV.c +++ b/bootstrap/windows-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/OPV.h b/bootstrap/windows-88/OPV.h index 43fd6331..0d54d226 100644 --- a/bootstrap/windows-88/OPV.h +++ b/bootstrap/windows-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/windows-88/Out.c b/bootstrap/windows-88/Out.c index 790b4f75..b21d426b 100644 --- a/bootstrap/windows-88/Out.c +++ b/bootstrap/windows-88/Out.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -7,34 +7,63 @@ #include "SYSTEM.h" #include "Platform.h" -#include "Strings.h" +static CHAR Out_buf[128]; +static int16 Out_in; export void Out_Char (CHAR ch); +export void Out_Flush (void); export void Out_Int (int64 x, int64 n); +static int32 Out_Length (CHAR *s, LONGINT s__len); export void Out_Ln (void); export void Out_LongReal (LONGREAL x, int16 n); export void Out_Open (void); export void Out_Real (REAL x, int16 n); +static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp); export void Out_String (CHAR *str, LONGINT str__len); -export REAL Out_Ten (int16 e); -static LONGREAL Out_TenL (int16 e); +export LONGREAL Out_Ten (int16 e); static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i); static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 *i); -#define Out_Entier32(x) (int32)(x) #define Out_Entier64(x) (int64)(x) +void Out_Flush (void) +{ + int16 error; + if (Out_in > 0) { + error = Platform_Write(Platform_StdOut, (address)Out_buf, Out_in); + } + Out_in = 0; +} + void Out_Open (void) { } void Out_Char (CHAR ch) { - int16 error; - error = Platform_Write(Platform_StdOut, (address)&ch, 1); + if (Out_in >= 128) { + Out_Flush(); + } + Out_buf[__X(Out_in, 128)] = ch; + Out_in += 1; + if (ch == 0x0a) { + Out_Flush(); + } +} + +static int32 Out_Length (CHAR *s, LONGINT s__len) +{ + int32 _o_result; + int32 l; + l = 0; + while ((l < s__len && s[__X(l, s__len)] != 0x00)) { + l += 1; + } + _o_result = l; + return _o_result; } void Out_String (CHAR *str, LONGINT str__len) @@ -42,11 +71,16 @@ void Out_String (CHAR *str, LONGINT str__len) int32 l; int16 error; __DUP(str, str__len, CHAR); - l = 0; - while ((l < str__len && str[__X(l, str__len)] != 0x00)) { - l += 1; + l = Out_Length((void*)str, str__len); + if (Out_in + l > 128) { + Out_Flush(); + } + if (l > 128) { + error = Platform_Write(Platform_StdOut, (address)str, l); + } else { + __MOVE((address)str, (address)&Out_buf[__X(Out_in, 128)], l); + Out_in += (int16)l; } - error = Platform_Write(Platform_StdOut, (address)str, l); __DEL(str); } @@ -89,6 +123,7 @@ void Out_Int (int64 x, int64 n) void Out_Ln (void) { Out_String(Platform_NL, 3); + Out_Flush(); } static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i) @@ -99,13 +134,14 @@ static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i) static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 *i) { - int16 j, l; + int16 j; + int32 l; __DUP(t, t__len, CHAR); - l = Strings_Length(t, t__len); + l = Out_Length((void*)t, t__len); if (l > *i) { l = *i; } - *i -= l; + *i -= (int16)l; j = 0; while (j < l) { s[__X(*i + j, s__len)] = t[__X(j, t__len)]; @@ -114,116 +150,7 @@ static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 __DEL(t); } -REAL Out_Ten (int16 e) -{ - REAL _o_result; - LONGREAL r, power; - r = (LONGREAL)1; - power = (LONGREAL)10; - while (e > 0) { - if (__ODD(e)) { - r = r * power; - } - power = power * power; - e = __ASHR(e, 1); - } - _o_result = r; - return _o_result; -} - -void Out_Real (REAL x, int16 n) -{ - int16 e; - int32 f; - CHAR s[30]; - int16 i; - REAL x0; - BOOLEAN nn, en; - int32 m; - int16 d; - nn = __VAL(int32, x) < 0; - if (nn) { - n -= 1; - } - e = (int16)__MASK(__ASHR(__VAL(int32, x), 23), -256); - f = __MASK(__VAL(int32, x), -8388608); - i = 30; - if (e == 255) { - if (f == 0) { - Out_prepend((CHAR*)"Infinity", 9, (void*)s, 30, &i); - } else { - Out_prepend((CHAR*)"NaN", 4, (void*)s, 30, &i); - } - } else { - if (e == 0) { - Out_prepend((CHAR*)"E+00", 5, (void*)s, 30, &i); - m = 0; - } else { - if (nn) { - x = -x; - } - e = __ASHR((e - 127) * 77, 8); - if (e >= 0) { - x = x / (REAL)Out_Ten(e); - } else { - x = Out_Ten(-e) * x; - } - if (x >= (REAL)10) { - x = 1.0000000e-001 * x; - e += 1; - } - en = e < 0; - if (en) { - e = -e; - } - d = 2; - while (d > 0) { - Out_digit(e, (void*)s, 30, &i); - e = __DIV(e, 10); - d -= 1; - } - if (en) { - Out_prepend((CHAR*)"E-", 3, (void*)s, 30, &i); - } else { - Out_prepend((CHAR*)"E+", 3, (void*)s, 30, &i); - } - x0 = Out_Ten(7); - x = x0 * x + 5.0000000e-001; - if (x >= (REAL)10 * x0) { - x = 1.0000000e-001 * x; - e += 1; - } - m = Out_Entier32(x); - } - d = 8; - while ((((d > 2 && d > n - 5)) && (int)__MOD(m, 10) == 0)) { - m = __DIV(m, 10); - d -= 1; - } - while (d > 1) { - Out_digit(m, (void*)s, 30, &i); - m = __DIV(m, 10); - d -= 1; - } - i -= 1; - s[__X(i, 30)] = '.'; - Out_digit(m, (void*)s, 30, &i); - } - n -= 30 - i; - while (n > 0) { - Out_Char(' '); - n -= 1; - } - if (nn) { - Out_Char('-'); - } - while (i < 30) { - Out_Char(s[__X(i, 30)]); - i += 1; - } -} - -static LONGREAL Out_TenL (int16 e) +LONGREAL Out_Ten (int16 e) { LONGREAL _o_result; LONGREAL r, power; @@ -240,7 +167,7 @@ static LONGREAL Out_TenL (int16 e) return _o_result; } -void Out_LongReal (LONGREAL x, int16 n) +static void Out_RealP (LONGREAL x, int16 n, int16 exponentdigits, int16 maxsigdigits, CHAR exp) { int16 e; int64 f; @@ -249,7 +176,7 @@ void Out_LongReal (LONGREAL x, int16 n) LONGREAL x0; BOOLEAN nn, en; int64 m; - int16 d; + int16 d, dr; nn = __VAL(int64, x) < 0; if (nn) { n -= 1; @@ -265,7 +192,15 @@ void Out_LongReal (LONGREAL x, int16 n) } } else { if (e == 0) { - Out_prepend((CHAR*)"D+000", 6, (void*)s, 30, &i); + d = i - exponentdigits; + while (i > d) { + i -= 1; + s[__X(i, 30)] = '0'; + } + i -= 1; + s[__X(i, 30)] = '+'; + i -= 1; + s[__X(i, 30)] = exp; m = 0; } else { if (nn) { @@ -273,9 +208,9 @@ void Out_LongReal (LONGREAL x, int16 n) } e = (int16)__ASHR((e - 1023) * 77, 8); if (e >= 0) { - x = x / (LONGREAL)Out_TenL(e); + x = x / (LONGREAL)Out_Ten(e); } else { - x = Out_TenL(-e) * x; + x = Out_Ten(-e) * x; } if (x >= (LONGREAL)10) { x = 1.00000000000000e-001 * x; @@ -285,18 +220,21 @@ void Out_LongReal (LONGREAL x, int16 n) if (en) { e = -e; } - d = 3; + d = exponentdigits; while (d > 0) { Out_digit(e, (void*)s, 30, &i); e = __DIV(e, 10); d -= 1; } + i -= 1; if (en) { - Out_prepend((CHAR*)"D-", 3, (void*)s, 30, &i); + s[__X(i, 30)] = '-'; } else { - Out_prepend((CHAR*)"D+", 3, (void*)s, 30, &i); + s[__X(i, 30)] = '+'; } - x0 = Out_TenL(15); + i -= 1; + s[__X(i, 30)] = exp; + x0 = Out_Ten(maxsigdigits - 1); x = x0 * x + 5.00000000000000e-001; if (x >= (LONGREAL)10 * x0) { x = 1.00000000000000e-001 * x; @@ -304,8 +242,12 @@ void Out_LongReal (LONGREAL x, int16 n) } m = Out_Entier64(x); } - d = 16; - while ((((d > 2 && d > n - 6)) && __MOD(m, 10) == 0)) { + d = maxsigdigits; + dr = n - (exponentdigits + 3); + if (dr < 2) { + dr = 2; + } + while ((d > dr && __MOD(m, 10) == 0)) { m = __DIV(m, 10); d -= 1; } @@ -332,13 +274,23 @@ void Out_LongReal (LONGREAL x, int16 n) } } +void Out_Real (REAL x, int16 n) +{ + Out_RealP(x, n, 2, 7, 'E'); +} + +void Out_LongReal (LONGREAL x, int16 n) +{ + Out_RealP(x, n, 3, 16, 'D'); +} + export void *Out__init(void) { __DEFMOD; __MODULE_IMPORT(Platform); - __MODULE_IMPORT(Strings); __REGMOD("Out", 0); + __REGCMD("Flush", Out_Flush); __REGCMD("Ln", Out_Ln); __REGCMD("Open", Out_Open); /* BEGIN */ diff --git a/bootstrap/windows-88/Out.h b/bootstrap/windows-88/Out.h index 9076f6d1..362b4414 100644 --- a/bootstrap/windows-88/Out.h +++ b/bootstrap/windows-88/Out.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Out__h #define Out__h @@ -9,13 +9,14 @@ import void Out_Char (CHAR ch); +import void Out_Flush (void); import void Out_Int (int64 x, int64 n); import void Out_Ln (void); import void Out_LongReal (LONGREAL x, int16 n); import void Out_Open (void); import void Out_Real (REAL x, int16 n); import void Out_String (CHAR *str, LONGINT str__len); -import REAL Out_Ten (int16 e); +import LONGREAL Out_Ten (int16 e); import void *Out__init(void); diff --git a/bootstrap/windows-88/Platform.c b/bootstrap/windows-88/Platform.c index 6f3c4e4f..7efc77b3 100644 --- a/bootstrap/windows-88/Platform.c +++ b/bootstrap/windows-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/Platform.h b/bootstrap/windows-88/Platform.h index 1008cc4b..52d679bb 100644 --- a/bootstrap/windows-88/Platform.h +++ b/bootstrap/windows-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/windows-88/Reals.c b/bootstrap/windows-88/Reals.c index 4e18ac01..8697b424 100644 --- a/bootstrap/windows-88/Reals.c +++ b/bootstrap/windows-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/Reals.h b/bootstrap/windows-88/Reals.h index 5728d211..e764f95f 100644 --- a/bootstrap/windows-88/Reals.h +++ b/bootstrap/windows-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Reals__h #define Reals__h diff --git a/bootstrap/windows-88/Strings.c b/bootstrap/windows-88/Strings.c index 37643e92..8a95a8eb 100644 --- a/bootstrap/windows-88/Strings.c +++ b/bootstrap/windows-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -24,15 +24,22 @@ export void Strings_Replace (CHAR *source, LONGINT source__len, int16 pos, CHAR int16 Strings_Length (CHAR *s, LONGINT s__len) { int16 _o_result; - int16 i; + int32 i; __DUP(s, s__len, CHAR); i = 0; while ((i < s__len && s[__X(i, s__len)] != 0x00)) { i += 1; } - _o_result = i; - __DEL(s); - return _o_result; + if (i <= 32767) { + _o_result = (int16)i; + __DEL(s); + return _o_result; + } else { + _o_result = 32767; + __DEL(s); + return _o_result; + } + __RETCHK; } void Strings_Append (CHAR *extra, LONGINT extra__len, CHAR *dest, LONGINT dest__len) diff --git a/bootstrap/windows-88/Strings.h b/bootstrap/windows-88/Strings.h index b7482150..4989383b 100644 --- a/bootstrap/windows-88/Strings.h +++ b/bootstrap/windows-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/windows-88/Texts.c b/bootstrap/windows-88/Texts.c index 0d2f319e..ce4a885a 100644 --- a/bootstrap/windows-88/Texts.c +++ b/bootstrap/windows-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/Texts.h b/bootstrap/windows-88/Texts.h index 4b01b650..26669d1c 100644 --- a/bootstrap/windows-88/Texts.h +++ b/bootstrap/windows-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/windows-88/errors.c b/bootstrap/windows-88/errors.c index 5ecfeea1..408d5ec7 100644 --- a/bootstrap/windows-88/errors.c +++ b/bootstrap/windows-88/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/errors.h b/bootstrap/windows-88/errors.h index 20eeca0d..b0247272 100644 --- a/bootstrap/windows-88/errors.h +++ b/bootstrap/windows-88/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef errors__h #define errors__h diff --git a/bootstrap/windows-88/extTools.c b/bootstrap/windows-88/extTools.c index b1328b1c..5df06422 100644 --- a/bootstrap/windows-88/extTools.c +++ b/bootstrap/windows-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/extTools.h b/bootstrap/windows-88/extTools.h index 27684ca4..ef0da35c 100644 --- a/bootstrap/windows-88/extTools.h +++ b/bootstrap/windows-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/windows-88/vt100.c b/bootstrap/windows-88/vt100.c index a2c7b023..65b16ccc 100644 --- a/bootstrap/windows-88/vt100.c +++ b/bootstrap/windows-88/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/vt100.h b/bootstrap/windows-88/vt100.h index 83b8a893..2211e981 100644 --- a/bootstrap/windows-88/vt100.h +++ b/bootstrap/windows-88/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/11]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef vt100__h #define vt100__h diff --git a/src/runtime/Out.Mod b/src/runtime/Out.Mod index 72287c56..9463fef8 100644 --- a/src/runtime/Out.Mod +++ b/src/runtime/Out.Mod @@ -1,24 +1,46 @@ MODULE Out; (* DCW Brown. 2016-09-27 *) -IMPORT SYSTEM, Platform, Strings; +IMPORT SYSTEM, Platform; + +VAR buf: ARRAY 128 OF CHAR; in: INTEGER; + +PROCEDURE Flush*; +VAR error: Platform.ErrorCode; +BEGIN + IF in > 0 THEN error := Platform.Write(Platform.StdOut, SYSTEM.ADR(buf), in) END; + in := 0; +END Flush; PROCEDURE Open*; BEGIN END Open; PROCEDURE Char*(ch: CHAR); - VAR error: Platform.ErrorCode; BEGIN - error := Platform.Write(Platform.StdOut, SYSTEM.ADR(ch), 1) + IF in >= LEN(buf) THEN Flush END; + buf[in] := ch; INC(in); + IF ch = 0AX THEN Flush END; END Char; +PROCEDURE Length(VAR s: ARRAY OF CHAR): LONGINT; +VAR l: LONGINT; +BEGIN l := 0; WHILE (l < LEN(s)) & (s[l] # 0X) DO INC(l) END; RETURN l +END Length; + PROCEDURE String*(str: ARRAY OF CHAR); VAR l: LONGINT; error: Platform.ErrorCode; BEGIN - l := 0; WHILE (l < LEN(str)) & (str[l] # 0X) DO INC(l) END; - error := Platform.Write(Platform.StdOut, SYSTEM.ADR(str), l) + l := Length(str); + IF in + l > LEN(buf) THEN Flush END; + IF l > LEN(buf) THEN + (* Doesn't fit buf. Bypass buffering. *) + error := Platform.Write(Platform.StdOut, SYSTEM.ADR(str), l) + ELSE + SYSTEM.MOVE(SYSTEM.ADR(str), SYSTEM.ADR(buf[in]), l); INC(in, SHORT(l)); + END END String; + PROCEDURE Int*(x, n: HUGEINT); CONST zero = ORD('0'); VAR s: ARRAY 22 OF CHAR; i: INTEGER; negative: BOOLEAN; @@ -41,7 +63,7 @@ BEGIN END Int; PROCEDURE Ln*; -BEGIN String(Platform.NL) +BEGIN String(Platform.NL); Flush; END Ln; @@ -53,109 +75,27 @@ BEGIN END digit; PROCEDURE prepend(t: ARRAY OF CHAR; VAR s: ARRAY OF CHAR; VAR i: INTEGER); - VAR j, l: INTEGER; + VAR j: INTEGER; l: LONGINT; BEGIN - l := Strings.Length(t); IF l > i THEN l := i END; - DEC(i, l); j := 0; + l := Length(t); IF l > i THEN l := i END; + DEC(i, SHORT(l)); j := 0; WHILE j < l DO s[i+j] := t[j]; INC(j) END END prepend; -PROCEDURE Ten*(e: INTEGER): REAL; +PROCEDURE Ten*(e: INTEGER): LONGREAL; VAR r, power: LONGREAL; -BEGIN r := 1.0; power := 10.0; +BEGIN r := 1.0D0; power := 1.0D1; WHILE e > 0 DO IF ODD(e) THEN r := r*power END; power := power*power; e := e DIV 2 END; - RETURN SHORT(r) -END Ten; - -PROCEDURE -Entier32(x: REAL): SYSTEM.INT32 "(int32)(x)"; - -PROCEDURE Real*(x: REAL; n: INTEGER); - -(* Real(x, n) writes the real number x to the end of the output stream using an - exponential form. If the textual representation of x requires m characters (including a - two-digit signed exponent), x is right adjusted in a field of Max(n, m) characters padded - with blanks at the left end. A plus sign of the mantissa is not written. - REAL is 1/sign, 8/exponent, 23/significand *) - -CONST - maxsigdigits = 8; (* Max significant digits to display from mantissa *) - -VAR - e: INTEGER; (* Exponent field *) - f: SYSTEM.INT32; (* Fraction field *) - s: ARRAY 30 OF CHAR; (* Buffer built backwards *) - i: INTEGER; (* Index into s *) - x0: REAL; - nn: BOOLEAN; (* Number negative *) - en: BOOLEAN; (* Exponent negative *) - m: SYSTEM.INT32; (* Mantissa digits *) - d: INTEGER; (* Significant digit count to display *) - -BEGIN - nn := SYSTEM.VAL(SYSTEM.INT32, x) < 0; IF nn THEN DEC(n) END; - e := SYSTEM.VAL(INTEGER, (SYSTEM.VAL(SYSTEM.INT32, x) DIV 800000H) MOD 100H); - f := SYSTEM.VAL(SYSTEM.INT32, x) MOD 800000H; - - i := LEN(s); - IF e = 0FFH THEN (* NaN / Infinity *) - IF f = 0 THEN prepend("Infinity", s, i) ELSE prepend("NaN", s, i) END - ELSE - IF e = 0 THEN prepend("E+00", s, i); m := 0; - ELSE - IF nn THEN x := -x END; - - (* Scale e to be an exponent of 10 rather than 2 *) - e := (e - 127) * 77 DIV 256; - IF e >= 0 THEN x := x / Ten(e) ELSE x := Ten(-e) * x END ; - IF x >= 10.0 THEN x := 0.1 * x; INC(e) END; - - (* Generate the exponent digits *) - en := e < 0; IF en THEN e := - e END; - d := 2; WHILE d > 0 DO digit(e, s, i); e := e DIV 10; DEC(d) END; - IF en THEN prepend("E-", s, i) ELSE prepend("E+", s, i) END; - - (* Scale x to 8 significant digits *) - x0 := Ten(maxsigdigits-1); x := x0*x + 0.5; - IF x >= 10.0*x0 THEN x := 0.1*x; INC(e) END; - m := Entier32(x) - END; - - (* Drop trailing zeroes where we don't have room *) - d := maxsigdigits; - WHILE (d > 2) & (d > n-5) & (m MOD 10 = 0) DO m := m DIV 10; DEC(d) END; - - (* Render significant digits *) - WHILE d > 1 DO digit(m, s, i); m := m DIV 10; DEC(d) END; - DEC(i); s[i] := '.'; - digit(m, s, i); - END; - - (* Generate leading padding *) - DEC(n, LEN(s)-i); WHILE n > 0 DO Char(" "); DEC(n) END; - - (* Render prepared number from right end of buffer s *) - IF nn THEN Char("-") END; - WHILE i < LEN(s) DO Char(s[i]); INC(i) END -END Real; - - -PROCEDURE TenL(e: INTEGER): LONGREAL; - VAR r, power: LONGREAL; -BEGIN r := 1.0; power := 10.0; - WHILE e > 0 DO - IF ODD(e) THEN r := r*power END; - power := power*power; e := e DIV 2; - END; RETURN r -END TenL; +END Ten; PROCEDURE -Entier64(x: LONGREAL): SYSTEM.INT64 "(int64)(x)"; -PROCEDURE LongReal*(x: LONGREAL; n: INTEGER); +PROCEDURE RealP(x: LONGREAL; n, exponentdigits, maxsigdigits: INTEGER; exp: CHAR); (* LongReal(x, n) writes the long real number x to the end of the output stream using an exponential form. If the textual representation of x requires m characters (including a @@ -163,9 +103,6 @@ PROCEDURE LongReal*(x: LONGREAL; n: INTEGER); with blanks at the left end. A plus sign of the mantissa is not written. LONGREAL is 1/sign, 11/exponent, 52/significand *) -CONST - maxsigdigits = 16; (* Max significant digits to display from mantissa *) - VAR e: INTEGER; (* Exponent field *) f: HUGEINT; (* Fraction field *) @@ -176,6 +113,7 @@ VAR en: BOOLEAN; (* Exponent negative *) m: HUGEINT; (* Mantissa digits *) d: INTEGER; (* Significant digit count to display *) + dr: INTEGER; (* Number of insignificant digits that can be dropped *) BEGIN nn := SYSTEM.VAL(HUGEINT, x) < 0; IF nn THEN DEC(n) END; @@ -186,22 +124,32 @@ BEGIN IF e = 7FFH THEN (* NaN / Infinity *) IF f = 0 THEN prepend("Infinity", s, i) ELSE prepend("NaN", s, i) END ELSE - IF e = 0 THEN prepend("D+000", s, i); m := 0; + IF e = 0 THEN + d := i - exponentdigits; WHILE i > d DO DEC(i); s[i] := "0" END; + DEC(i); s[i] := "+"; + DEC(i); s[i] := exp; + m := 0; ELSE IF nn THEN x := -x END; (* Scale e to be an exponent of 10 rather than 2 *) e := SHORT(LONG(e - 1023) * 77 DIV 256); - IF e >= 0 THEN x := x / TenL(e) ELSE x := TenL(-e) * x END ; + IF e >= 0 THEN x := x / Ten(e) ELSE x := Ten(-e) * x END ; IF x >= 10.0D0 THEN x := 0.1D0 * x; INC(e) END; (* Generate the exponent digits *) en := e < 0; IF en THEN e := - e END; - d := 3; WHILE d > 0 DO digit(e, s, i); e := e DIV 10; DEC(d) END; - IF en THEN prepend("D-", s, i) ELSE prepend("D+", s, i) END; + d := exponentdigits; + WHILE d > 0 DO digit(e, s, i); e := e DIV 10; DEC(d) END; + DEC(i); IF en THEN s[i] := "-" ELSE s[i] := "+" END; + DEC(i); s[i] := exp; - (* Scale x to 15 significant digits *) - x0 := TenL(maxsigdigits-1); + (* Todo: generate more than maxsigdigits if we have room for them *) + + (* Scale x to enoughsignificant digits to reliably test for trailing + zeroes. + todo or to the amount of space available, if greater. *) + x0 := Ten(maxsigdigits-1); x := x0 * x + 0.5D0; IF x >= 10.0D0 * x0 THEN x := 0.1D0 * x; INC(e) END; m := Entier64(x) @@ -209,7 +157,9 @@ BEGIN (* Drop trailing zeroes where we don't have room *) d := maxsigdigits; - WHILE (d > 2) & (d > n-6) & (m MOD 10 = 0) DO m := m DIV 10; DEC(d) END; + dr := n - (exponentdigits + 3); (* 3 for '.', D/E and +/- *) + IF dr < 2 THEN dr := 2 END; + WHILE (d > dr) & (m MOD 10 = 0) DO m := m DIV 10; DEC(d) END; (* Render significant digits *) WHILE d > 1 DO digit(m, s, i); m := m DIV 10; DEC(d) END; @@ -223,7 +173,15 @@ BEGIN (* Render prepared number from right end of buffer s *) IF nn THEN Char("-") END; WHILE i < LEN(s) DO Char(s[i]); INC(i) END +END RealP; + + +PROCEDURE Real*(x: REAL; n: INTEGER); +BEGIN RealP(x, n, 2, 7, "E"); +END Real; + +PROCEDURE LongReal*(x: LONGREAL; n: INTEGER); +BEGIN RealP(x, n, 3, 16, "D"); END LongReal; - END Out. diff --git a/src/runtime/Strings.Mod b/src/runtime/Strings.Mod index e6fe12ac..0dcfa6d2 100644 --- a/src/runtime/Strings.Mod +++ b/src/runtime/Strings.Mod @@ -32,10 +32,10 @@ MODULE Strings; (*HM 94-06-22 / *) PROCEDURE Length* (s: ARRAY OF CHAR): INTEGER; - VAR i: INTEGER; + VAR i: LONGINT; BEGIN - i := 0; WHILE (i < LEN(s)) & (s[i] # 0X) DO INC(i) END ; - RETURN i + i := 0; WHILE (i < LEN(s)) & (s[i] # 0X) DO INC(i) END; + IF i <= MAX(INTEGER) THEN RETURN SHORT(i) ELSE RETURN MAX(INTEGER) END END Length; diff --git a/src/test/confidence/out/expected b/src/test/confidence/out/expected index 5343a884..b71feae8 100644 --- a/src/test/confidence/out/expected +++ b/src/test/confidence/out/expected @@ -80,15 +80,15 @@ Testing REAL. 1 2 3 123456789012345678901234567890 - 1.0E0: 1.0000000E+00 - 1.1E0: 1.1000000E+00 - 2.1E0: 2.1000000E+00 --1.1E0: -1.1000000E+00 - 1.1E3: 1.1000000E+03 - 1.1E-3: 1.1000000E-03 - 1.2345678987654321E3: 1.2345680E+03 - 0.0: 0.0000000E+00 - 0.000123E0: 1.2300000E-04 + 1.0E0: 1.000000E+00 + 1.1E0: 1.100000E+00 + 2.1E0: 2.100000E+00 +-1.1E0: -1.100000E+00 + 1.1E3: 1.100000E+03 + 1.1E-3: 1.100000E-03 + 1.2345678987654321E3: 1.234568E+03 + 0.0: 0.000000E+00 + 0.000123E0: 1.230000E-04 1/0.0: Infinity -1/0.0: -Infinity @@ -176,15 +176,15 @@ Testing REAL. 1 2 3 123456789012345678901234567890 - 1.0E0: 1.0000000E+00 - 1.1E0: 1.1000000E+00 - 2.1E0: 2.1000000E+00 --1.1E0: -1.1000000E+00 - 1.1E3: 1.1000000E+03 - 1.1E-3: 1.1000000E-03 - 1.2345678987654321E3: 1.2345680E+03 - 0.0: 0.0000000E+00 - 0.000123E0: 1.2300000E-04 + 1.0E0: 1.000000E+00 + 1.1E0: 1.100000E+00 + 2.1E0: 2.100000E+00 +-1.1E0: -1.100000E+00 + 1.1E3: 1.100000E+03 + 1.1E-3: 1.100000E-03 + 1.2345678987654321E3: 1.234568E+03 + 0.0: 0.000000E+00 + 0.000123E0: 1.230000E-04 1/0.0: Infinity -1/0.0: -Infinity diff --git a/src/test/confidence/out/result-O2 b/src/test/confidence/out/result-O2 index 1121e4ae..78548b4d 100644 --- a/src/test/confidence/out/result-O2 +++ b/src/test/confidence/out/result-O2 @@ -79,15 +79,15 @@ Testing REAL. 1 2 3 123456789012345678901234567890 - 1.0E0: 1.0000000E+00 - 1.1E0: 1.1000000E+00 - 2.1E0: 2.1000000E+00 --1.1E0: -1.1000000E+00 - 1.1E3: 1.1000000E+03 - 1.1E-3: 1.1000000E-03 - 1.2345678987654321E3: 1.2345680E+03 - 0.0: 0.0000000E+00 - 0.000123E0: 1.2300000E-04 + 1.0E0: 1.000000E+00 + 1.1E0: 1.100000E+00 + 2.1E0: 2.100000E+00 +-1.1E0: -1.100000E+00 + 1.1E3: 1.100000E+03 + 1.1E-3: 1.100000E-03 + 1.2345678987654321E3: 1.234568E+03 + 0.0: 0.000000E+00 + 0.000123E0: 1.230000E-04 1/0.0: Infinity -1/0.0: -Infinity diff --git a/src/test/confidence/out/result-OC b/src/test/confidence/out/result-OC index 8713aa8e..fc82e517 100644 --- a/src/test/confidence/out/result-OC +++ b/src/test/confidence/out/result-OC @@ -79,15 +79,15 @@ Testing REAL. 1 2 3 123456789012345678901234567890 - 1.0E0: 1.0000000E+00 - 1.1E0: 1.1000000E+00 - 2.1E0: 2.1000000E+00 --1.1E0: -1.1000000E+00 - 1.1E3: 1.1000000E+03 - 1.1E-3: 1.1000000E-03 - 1.2345678987654321E3: 1.2345680E+03 - 0.0: 0.0000000E+00 - 0.000123E0: 1.2300000E-04 + 1.0E0: 1.000000E+00 + 1.1E0: 1.100000E+00 + 2.1E0: 2.100000E+00 +-1.1E0: -1.100000E+00 + 1.1E3: 1.100000E+03 + 1.1E-3: 1.100000E-03 + 1.2345678987654321E3: 1.234568E+03 + 0.0: 0.000000E+00 + 0.000123E0: 1.230000E-04 1/0.0: Infinity -1/0.0: -Infinity