diff --git a/bootstrap/unix-44/Compiler.c b/bootstrap/unix-44/Compiler.c index f176c32c..2dd6f251 100644 --- a/bootstrap/unix-44/Compiler.c +++ b/bootstrap/unix-44/Compiler.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ +/* voc 1.95 [2016/10/08]. 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 cd60e0eb..3498204c 100644 --- a/bootstrap/unix-44/Configuration.c +++ b/bootstrap/unix-44/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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/04]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("1.95 [2016/10/08]. 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 51248a3a..14d86591 100644 --- a/bootstrap/unix-44/Configuration.h +++ b/bootstrap/unix-44/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 dcdaea0d..cb7920a3 100644 --- a/bootstrap/unix-44/Files.c +++ b/bootstrap/unix-44/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 d902e57e..4a49d744 100644 --- a/bootstrap/unix-44/Files.h +++ b/bootstrap/unix-44/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 bf247ca6..860107f9 100644 --- a/bootstrap/unix-44/Heap.c +++ b/bootstrap/unix-44/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. 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 2b27eb13..84c9bb20 100644 --- a/bootstrap/unix-44/Heap.h +++ b/bootstrap/unix-44/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. 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 19cf402a..ab3bb29b 100644 --- a/bootstrap/unix-44/Modules.c +++ b/bootstrap/unix-44/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 eb8d7d25..95fc4f94 100644 --- a/bootstrap/unix-44/Modules.h +++ b/bootstrap/unix-44/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 4df43c2a..bfc64251 100644 --- a/bootstrap/unix-44/OPB.c +++ b/bootstrap/unix-44/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 bab5adcc..d04325c7 100644 --- a/bootstrap/unix-44/OPB.h +++ b/bootstrap/unix-44/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 fd8f546f..54cd9a85 100644 --- a/bootstrap/unix-44/OPC.c +++ b/bootstrap/unix-44/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 662ac74a..69a5580c 100644 --- a/bootstrap/unix-44/OPC.h +++ b/bootstrap/unix-44/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 8430bf82..7da9b7b0 100644 --- a/bootstrap/unix-44/OPM.c +++ b/bootstrap/unix-44/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 d7aadb69..d2a06df9 100644 --- a/bootstrap/unix-44/OPM.h +++ b/bootstrap/unix-44/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 016b40ed..768bfd2c 100644 --- a/bootstrap/unix-44/OPP.c +++ b/bootstrap/unix-44/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 90da6ba9..ee87db69 100644 --- a/bootstrap/unix-44/OPP.h +++ b/bootstrap/unix-44/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 f7f892bf..02c301dc 100644 --- a/bootstrap/unix-44/OPS.c +++ b/bootstrap/unix-44/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 d97f3caa..98dd65e7 100644 --- a/bootstrap/unix-44/OPS.h +++ b/bootstrap/unix-44/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 b214554c..f9666e9a 100644 --- a/bootstrap/unix-44/OPT.c +++ b/bootstrap/unix-44/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 88225ce2..f5b615f8 100644 --- a/bootstrap/unix-44/OPT.h +++ b/bootstrap/unix-44/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 65f5d6d9..ce5e3036 100644 --- a/bootstrap/unix-44/OPV.c +++ b/bootstrap/unix-44/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 ab72377c..43fd6331 100644 --- a/bootstrap/unix-44/OPV.h +++ b/bootstrap/unix-44/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 66f4fc90..37cb4c91 100644 --- a/bootstrap/unix-44/Out.c +++ b/bootstrap/unix-44/Out.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -7,6 +7,7 @@ #include "SYSTEM.h" #include "Platform.h" +#include "Strings.h" @@ -18,7 +19,13 @@ export void Out_LongReal (LONGREAL x, int16 n); export void Out_Open (void); export void Out_Real (REAL x, int16 n); export void Out_String (CHAR *str, LONGINT str__len); +export REAL Out_Ten (int16 e); +static LONGREAL Out_TenL (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_Open (void) { @@ -36,7 +43,7 @@ void Out_String (CHAR *str, LONGINT str__len) int16 error; __DUP(str, str__len, CHAR); l = 0; - while ((l < str__len && str[l] != 0x00)) { + while ((l < str__len && str[__X(l, str__len)] != 0x00)) { l += 1; } error = Platform_Write(1, (address)str, l); @@ -60,13 +67,13 @@ void Out_Int (int64 x, int64 n) x = __DIV(x, 10); i = 1; while (x != 0) { - s[i] = (CHAR)(48 + __MOD(x, 10)); + s[__X(i, 22)] = (CHAR)(48 + __MOD(x, 10)); x = __DIV(x, 10); i += 1; } } if (negative) { - s[i] = '-'; + s[__X(i, 22)] = '-'; i += 1; } while (n > (int64)i) { @@ -75,28 +82,262 @@ void Out_Int (int64 x, int64 n) } while (i > 0) { i -= 1; - Out_Char(s[i]); + Out_Char(s[__X(i, 22)]); } } -void Out_Real (REAL x, int16 n) -{ -} - -void Out_LongReal (LONGREAL x, int16 n) -{ -} - void Out_Ln (void) { Out_String(Platform_NL, 3); } +static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i) +{ + *i -= 1; + s[__X(*i, s__len)] = (CHAR)(__MOD(n, 10) + 48); +} + +static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 *i) +{ + int16 j, l; + __DUP(t, t__len, CHAR); + l = Strings_Length(t, t__len); + if (l > *i) { + l = *i; + } + *i -= l; + j = 0; + while (j < l) { + s[__X(*i + j, s__len)] = t[__X(j, t__len)]; + j += 1; + } + __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 _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_LongReal (LONGREAL x, int16 n) +{ + int16 e; + int64 f; + CHAR s[30]; + int16 i; + LONGREAL x0; + BOOLEAN nn, en; + int64 m; + int16 d; + nn = __VAL(int64, x) < 0; + if (nn) { + n -= 1; + } + e = (int16)__MASK(__ASHR((__VAL(int64, x)), 52), -2048); + f = __MASK((__VAL(int64, x)), -4503599627370496); + i = 30; + if (e == 2047) { + 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*)"D+000", 6, (void*)s, 30, &i); + m = 0; + } else { + if (nn) { + x = -x; + } + e = (int16)__ASHR((e - 1023) * 77, 8); + if (e >= 0) { + x = x / (LONGREAL)Out_TenL(e); + } else { + x = Out_TenL(-e) * x; + } + if (x >= (LONGREAL)10) { + x = 1.00000000000000e-001 * x; + e += 1; + } + en = e < 0; + if (en) { + e = -e; + } + d = 3; + while (d > 0) { + Out_digit(e, (void*)s, 30, &i); + e = __DIV(e, 10); + d -= 1; + } + if (en) { + Out_prepend((CHAR*)"D-", 3, (void*)s, 30, &i); + } else { + Out_prepend((CHAR*)"D+", 3, (void*)s, 30, &i); + } + x0 = Out_TenL(15); + x = x0 * x + 5.00000000000000e-001; + if (x >= (LONGREAL)10 * x0) { + x = 1.00000000000000e-001 * x; + e += 1; + } + m = Out_Entier64(x); + } + d = 16; + while ((((d > 2 && d > n - 6)) && __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; + } +} + export void *Out__init(void) { __DEFMOD; __MODULE_IMPORT(Platform); + __MODULE_IMPORT(Strings); __REGMOD("Out", 0); __REGCMD("Ln", Out_Ln); __REGCMD("Open", Out_Open); diff --git a/bootstrap/unix-44/Out.h b/bootstrap/unix-44/Out.h index 4d3199e6..9076f6d1 100644 --- a/bootstrap/unix-44/Out.h +++ b/bootstrap/unix-44/Out.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Out__h #define Out__h @@ -15,6 +15,7 @@ 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 void *Out__init(void); diff --git a/bootstrap/unix-44/Platform.c b/bootstrap/unix-44/Platform.c index a550ad52..3ba187a5 100644 --- a/bootstrap/unix-44/Platform.c +++ b/bootstrap/unix-44/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 eee301c1..a96c77e9 100644 --- a/bootstrap/unix-44/Platform.h +++ b/bootstrap/unix-44/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 7d395538..4e18ac01 100644 --- a/bootstrap/unix-44/Reals.c +++ b/bootstrap/unix-44/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 98731ba9..5728d211 100644 --- a/bootstrap/unix-44/Reals.h +++ b/bootstrap/unix-44/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 7d4bf19a..37643e92 100644 --- a/bootstrap/unix-44/Strings.c +++ b/bootstrap/unix-44/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-44/Strings.h b/bootstrap/unix-44/Strings.h index 939e74d8..b7482150 100644 --- a/bootstrap/unix-44/Strings.h +++ b/bootstrap/unix-44/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 adb24e10..340d4654 100644 --- a/bootstrap/unix-44/Texts.c +++ b/bootstrap/unix-44/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 ca5c6c89..0992f4eb 100644 --- a/bootstrap/unix-44/Texts.h +++ b/bootstrap/unix-44/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 49c6425d..5ecfeea1 100644 --- a/bootstrap/unix-44/errors.c +++ b/bootstrap/unix-44/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 e7ecd052..20eeca0d 100644 --- a/bootstrap/unix-44/errors.h +++ b/bootstrap/unix-44/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 b58bcc2a..b1328b1c 100644 --- a/bootstrap/unix-44/extTools.c +++ b/bootstrap/unix-44/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 cb8a5a95..27684ca4 100644 --- a/bootstrap/unix-44/extTools.h +++ b/bootstrap/unix-44/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 92ed02e4..a2c7b023 100644 --- a/bootstrap/unix-44/vt100.c +++ b/bootstrap/unix-44/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 393203ef..83b8a893 100644 --- a/bootstrap/unix-44/vt100.h +++ b/bootstrap/unix-44/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 f176c32c..2dd6f251 100644 --- a/bootstrap/unix-48/Compiler.c +++ b/bootstrap/unix-48/Compiler.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ +/* voc 1.95 [2016/10/08]. 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 cd60e0eb..3498204c 100644 --- a/bootstrap/unix-48/Configuration.c +++ b/bootstrap/unix-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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/04]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("1.95 [2016/10/08]. 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 51248a3a..14d86591 100644 --- a/bootstrap/unix-48/Configuration.h +++ b/bootstrap/unix-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 dcdaea0d..cb7920a3 100644 --- a/bootstrap/unix-48/Files.c +++ b/bootstrap/unix-48/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 d902e57e..4a49d744 100644 --- a/bootstrap/unix-48/Files.h +++ b/bootstrap/unix-48/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 bf247ca6..860107f9 100644 --- a/bootstrap/unix-48/Heap.c +++ b/bootstrap/unix-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. 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 2b27eb13..84c9bb20 100644 --- a/bootstrap/unix-48/Heap.h +++ b/bootstrap/unix-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. 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 19cf402a..ab3bb29b 100644 --- a/bootstrap/unix-48/Modules.c +++ b/bootstrap/unix-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 eb8d7d25..95fc4f94 100644 --- a/bootstrap/unix-48/Modules.h +++ b/bootstrap/unix-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 4df43c2a..bfc64251 100644 --- a/bootstrap/unix-48/OPB.c +++ b/bootstrap/unix-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 bab5adcc..d04325c7 100644 --- a/bootstrap/unix-48/OPB.h +++ b/bootstrap/unix-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 fd8f546f..54cd9a85 100644 --- a/bootstrap/unix-48/OPC.c +++ b/bootstrap/unix-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 662ac74a..69a5580c 100644 --- a/bootstrap/unix-48/OPC.h +++ b/bootstrap/unix-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 8430bf82..7da9b7b0 100644 --- a/bootstrap/unix-48/OPM.c +++ b/bootstrap/unix-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 d7aadb69..d2a06df9 100644 --- a/bootstrap/unix-48/OPM.h +++ b/bootstrap/unix-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 016b40ed..768bfd2c 100644 --- a/bootstrap/unix-48/OPP.c +++ b/bootstrap/unix-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 90da6ba9..ee87db69 100644 --- a/bootstrap/unix-48/OPP.h +++ b/bootstrap/unix-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 f7f892bf..02c301dc 100644 --- a/bootstrap/unix-48/OPS.c +++ b/bootstrap/unix-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 d97f3caa..98dd65e7 100644 --- a/bootstrap/unix-48/OPS.h +++ b/bootstrap/unix-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 911d49ab..7ebdfd73 100644 --- a/bootstrap/unix-48/OPT.c +++ b/bootstrap/unix-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 88225ce2..f5b615f8 100644 --- a/bootstrap/unix-48/OPT.h +++ b/bootstrap/unix-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 65f5d6d9..ce5e3036 100644 --- a/bootstrap/unix-48/OPV.c +++ b/bootstrap/unix-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 ab72377c..43fd6331 100644 --- a/bootstrap/unix-48/OPV.h +++ b/bootstrap/unix-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 66f4fc90..37cb4c91 100644 --- a/bootstrap/unix-48/Out.c +++ b/bootstrap/unix-48/Out.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -7,6 +7,7 @@ #include "SYSTEM.h" #include "Platform.h" +#include "Strings.h" @@ -18,7 +19,13 @@ export void Out_LongReal (LONGREAL x, int16 n); export void Out_Open (void); export void Out_Real (REAL x, int16 n); export void Out_String (CHAR *str, LONGINT str__len); +export REAL Out_Ten (int16 e); +static LONGREAL Out_TenL (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_Open (void) { @@ -36,7 +43,7 @@ void Out_String (CHAR *str, LONGINT str__len) int16 error; __DUP(str, str__len, CHAR); l = 0; - while ((l < str__len && str[l] != 0x00)) { + while ((l < str__len && str[__X(l, str__len)] != 0x00)) { l += 1; } error = Platform_Write(1, (address)str, l); @@ -60,13 +67,13 @@ void Out_Int (int64 x, int64 n) x = __DIV(x, 10); i = 1; while (x != 0) { - s[i] = (CHAR)(48 + __MOD(x, 10)); + s[__X(i, 22)] = (CHAR)(48 + __MOD(x, 10)); x = __DIV(x, 10); i += 1; } } if (negative) { - s[i] = '-'; + s[__X(i, 22)] = '-'; i += 1; } while (n > (int64)i) { @@ -75,28 +82,262 @@ void Out_Int (int64 x, int64 n) } while (i > 0) { i -= 1; - Out_Char(s[i]); + Out_Char(s[__X(i, 22)]); } } -void Out_Real (REAL x, int16 n) -{ -} - -void Out_LongReal (LONGREAL x, int16 n) -{ -} - void Out_Ln (void) { Out_String(Platform_NL, 3); } +static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i) +{ + *i -= 1; + s[__X(*i, s__len)] = (CHAR)(__MOD(n, 10) + 48); +} + +static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 *i) +{ + int16 j, l; + __DUP(t, t__len, CHAR); + l = Strings_Length(t, t__len); + if (l > *i) { + l = *i; + } + *i -= l; + j = 0; + while (j < l) { + s[__X(*i + j, s__len)] = t[__X(j, t__len)]; + j += 1; + } + __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 _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_LongReal (LONGREAL x, int16 n) +{ + int16 e; + int64 f; + CHAR s[30]; + int16 i; + LONGREAL x0; + BOOLEAN nn, en; + int64 m; + int16 d; + nn = __VAL(int64, x) < 0; + if (nn) { + n -= 1; + } + e = (int16)__MASK(__ASHR((__VAL(int64, x)), 52), -2048); + f = __MASK((__VAL(int64, x)), -4503599627370496); + i = 30; + if (e == 2047) { + 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*)"D+000", 6, (void*)s, 30, &i); + m = 0; + } else { + if (nn) { + x = -x; + } + e = (int16)__ASHR((e - 1023) * 77, 8); + if (e >= 0) { + x = x / (LONGREAL)Out_TenL(e); + } else { + x = Out_TenL(-e) * x; + } + if (x >= (LONGREAL)10) { + x = 1.00000000000000e-001 * x; + e += 1; + } + en = e < 0; + if (en) { + e = -e; + } + d = 3; + while (d > 0) { + Out_digit(e, (void*)s, 30, &i); + e = __DIV(e, 10); + d -= 1; + } + if (en) { + Out_prepend((CHAR*)"D-", 3, (void*)s, 30, &i); + } else { + Out_prepend((CHAR*)"D+", 3, (void*)s, 30, &i); + } + x0 = Out_TenL(15); + x = x0 * x + 5.00000000000000e-001; + if (x >= (LONGREAL)10 * x0) { + x = 1.00000000000000e-001 * x; + e += 1; + } + m = Out_Entier64(x); + } + d = 16; + while ((((d > 2 && d > n - 6)) && __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; + } +} + export void *Out__init(void) { __DEFMOD; __MODULE_IMPORT(Platform); + __MODULE_IMPORT(Strings); __REGMOD("Out", 0); __REGCMD("Ln", Out_Ln); __REGCMD("Open", Out_Open); diff --git a/bootstrap/unix-48/Out.h b/bootstrap/unix-48/Out.h index 4d3199e6..9076f6d1 100644 --- a/bootstrap/unix-48/Out.h +++ b/bootstrap/unix-48/Out.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Out__h #define Out__h @@ -15,6 +15,7 @@ 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 void *Out__init(void); diff --git a/bootstrap/unix-48/Platform.c b/bootstrap/unix-48/Platform.c index a550ad52..3ba187a5 100644 --- a/bootstrap/unix-48/Platform.c +++ b/bootstrap/unix-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 eee301c1..a96c77e9 100644 --- a/bootstrap/unix-48/Platform.h +++ b/bootstrap/unix-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 7d395538..4e18ac01 100644 --- a/bootstrap/unix-48/Reals.c +++ b/bootstrap/unix-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 98731ba9..5728d211 100644 --- a/bootstrap/unix-48/Reals.h +++ b/bootstrap/unix-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 7d4bf19a..37643e92 100644 --- a/bootstrap/unix-48/Strings.c +++ b/bootstrap/unix-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-48/Strings.h b/bootstrap/unix-48/Strings.h index 939e74d8..b7482150 100644 --- a/bootstrap/unix-48/Strings.h +++ b/bootstrap/unix-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 f6698990..92376713 100644 --- a/bootstrap/unix-48/Texts.c +++ b/bootstrap/unix-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 baa9464f..107cdc6c 100644 --- a/bootstrap/unix-48/Texts.h +++ b/bootstrap/unix-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 49c6425d..5ecfeea1 100644 --- a/bootstrap/unix-48/errors.c +++ b/bootstrap/unix-48/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 e7ecd052..20eeca0d 100644 --- a/bootstrap/unix-48/errors.h +++ b/bootstrap/unix-48/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 b58bcc2a..b1328b1c 100644 --- a/bootstrap/unix-48/extTools.c +++ b/bootstrap/unix-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 cb8a5a95..27684ca4 100644 --- a/bootstrap/unix-48/extTools.h +++ b/bootstrap/unix-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 92ed02e4..a2c7b023 100644 --- a/bootstrap/unix-48/vt100.c +++ b/bootstrap/unix-48/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 393203ef..83b8a893 100644 --- a/bootstrap/unix-48/vt100.h +++ b/bootstrap/unix-48/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 f176c32c..2dd6f251 100644 --- a/bootstrap/unix-88/Compiler.c +++ b/bootstrap/unix-88/Compiler.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ +/* voc 1.95 [2016/10/08]. 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 cd60e0eb..3498204c 100644 --- a/bootstrap/unix-88/Configuration.c +++ b/bootstrap/unix-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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/04]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("1.95 [2016/10/08]. 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 51248a3a..14d86591 100644 --- a/bootstrap/unix-88/Configuration.h +++ b/bootstrap/unix-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 05693822..2324bd31 100644 --- a/bootstrap/unix-88/Files.c +++ b/bootstrap/unix-88/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 74b0c2ac..5156a13d 100644 --- a/bootstrap/unix-88/Files.h +++ b/bootstrap/unix-88/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 d929bf31..e3aceaf6 100644 --- a/bootstrap/unix-88/Heap.c +++ b/bootstrap/unix-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. 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 c0f06627..29ed6e2f 100644 --- a/bootstrap/unix-88/Heap.h +++ b/bootstrap/unix-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. 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 3f625202..273f6c11 100644 --- a/bootstrap/unix-88/Modules.c +++ b/bootstrap/unix-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 eb8d7d25..95fc4f94 100644 --- a/bootstrap/unix-88/Modules.h +++ b/bootstrap/unix-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 4df43c2a..bfc64251 100644 --- a/bootstrap/unix-88/OPB.c +++ b/bootstrap/unix-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 bab5adcc..d04325c7 100644 --- a/bootstrap/unix-88/OPB.h +++ b/bootstrap/unix-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 fd8f546f..54cd9a85 100644 --- a/bootstrap/unix-88/OPC.c +++ b/bootstrap/unix-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 662ac74a..69a5580c 100644 --- a/bootstrap/unix-88/OPC.h +++ b/bootstrap/unix-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 69eb0109..ec6acf95 100644 --- a/bootstrap/unix-88/OPM.c +++ b/bootstrap/unix-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 d7aadb69..d2a06df9 100644 --- a/bootstrap/unix-88/OPM.h +++ b/bootstrap/unix-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 aa541ba7..ddd0d49c 100644 --- a/bootstrap/unix-88/OPP.c +++ b/bootstrap/unix-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 90da6ba9..ee87db69 100644 --- a/bootstrap/unix-88/OPP.h +++ b/bootstrap/unix-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 f7f892bf..02c301dc 100644 --- a/bootstrap/unix-88/OPS.c +++ b/bootstrap/unix-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 d97f3caa..98dd65e7 100644 --- a/bootstrap/unix-88/OPS.h +++ b/bootstrap/unix-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 5adea265..60915d55 100644 --- a/bootstrap/unix-88/OPT.c +++ b/bootstrap/unix-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 88225ce2..f5b615f8 100644 --- a/bootstrap/unix-88/OPT.h +++ b/bootstrap/unix-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 8a61c677..e3b8aff9 100644 --- a/bootstrap/unix-88/OPV.c +++ b/bootstrap/unix-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 ab72377c..43fd6331 100644 --- a/bootstrap/unix-88/OPV.h +++ b/bootstrap/unix-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 66f4fc90..37cb4c91 100644 --- a/bootstrap/unix-88/Out.c +++ b/bootstrap/unix-88/Out.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -7,6 +7,7 @@ #include "SYSTEM.h" #include "Platform.h" +#include "Strings.h" @@ -18,7 +19,13 @@ export void Out_LongReal (LONGREAL x, int16 n); export void Out_Open (void); export void Out_Real (REAL x, int16 n); export void Out_String (CHAR *str, LONGINT str__len); +export REAL Out_Ten (int16 e); +static LONGREAL Out_TenL (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_Open (void) { @@ -36,7 +43,7 @@ void Out_String (CHAR *str, LONGINT str__len) int16 error; __DUP(str, str__len, CHAR); l = 0; - while ((l < str__len && str[l] != 0x00)) { + while ((l < str__len && str[__X(l, str__len)] != 0x00)) { l += 1; } error = Platform_Write(1, (address)str, l); @@ -60,13 +67,13 @@ void Out_Int (int64 x, int64 n) x = __DIV(x, 10); i = 1; while (x != 0) { - s[i] = (CHAR)(48 + __MOD(x, 10)); + s[__X(i, 22)] = (CHAR)(48 + __MOD(x, 10)); x = __DIV(x, 10); i += 1; } } if (negative) { - s[i] = '-'; + s[__X(i, 22)] = '-'; i += 1; } while (n > (int64)i) { @@ -75,28 +82,262 @@ void Out_Int (int64 x, int64 n) } while (i > 0) { i -= 1; - Out_Char(s[i]); + Out_Char(s[__X(i, 22)]); } } -void Out_Real (REAL x, int16 n) -{ -} - -void Out_LongReal (LONGREAL x, int16 n) -{ -} - void Out_Ln (void) { Out_String(Platform_NL, 3); } +static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i) +{ + *i -= 1; + s[__X(*i, s__len)] = (CHAR)(__MOD(n, 10) + 48); +} + +static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 *i) +{ + int16 j, l; + __DUP(t, t__len, CHAR); + l = Strings_Length(t, t__len); + if (l > *i) { + l = *i; + } + *i -= l; + j = 0; + while (j < l) { + s[__X(*i + j, s__len)] = t[__X(j, t__len)]; + j += 1; + } + __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 _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_LongReal (LONGREAL x, int16 n) +{ + int16 e; + int64 f; + CHAR s[30]; + int16 i; + LONGREAL x0; + BOOLEAN nn, en; + int64 m; + int16 d; + nn = __VAL(int64, x) < 0; + if (nn) { + n -= 1; + } + e = (int16)__MASK(__ASHR((__VAL(int64, x)), 52), -2048); + f = __MASK((__VAL(int64, x)), -4503599627370496); + i = 30; + if (e == 2047) { + 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*)"D+000", 6, (void*)s, 30, &i); + m = 0; + } else { + if (nn) { + x = -x; + } + e = (int16)__ASHR((e - 1023) * 77, 8); + if (e >= 0) { + x = x / (LONGREAL)Out_TenL(e); + } else { + x = Out_TenL(-e) * x; + } + if (x >= (LONGREAL)10) { + x = 1.00000000000000e-001 * x; + e += 1; + } + en = e < 0; + if (en) { + e = -e; + } + d = 3; + while (d > 0) { + Out_digit(e, (void*)s, 30, &i); + e = __DIV(e, 10); + d -= 1; + } + if (en) { + Out_prepend((CHAR*)"D-", 3, (void*)s, 30, &i); + } else { + Out_prepend((CHAR*)"D+", 3, (void*)s, 30, &i); + } + x0 = Out_TenL(15); + x = x0 * x + 5.00000000000000e-001; + if (x >= (LONGREAL)10 * x0) { + x = 1.00000000000000e-001 * x; + e += 1; + } + m = Out_Entier64(x); + } + d = 16; + while ((((d > 2 && d > n - 6)) && __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; + } +} + export void *Out__init(void) { __DEFMOD; __MODULE_IMPORT(Platform); + __MODULE_IMPORT(Strings); __REGMOD("Out", 0); __REGCMD("Ln", Out_Ln); __REGCMD("Open", Out_Open); diff --git a/bootstrap/unix-88/Out.h b/bootstrap/unix-88/Out.h index 4d3199e6..9076f6d1 100644 --- a/bootstrap/unix-88/Out.h +++ b/bootstrap/unix-88/Out.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Out__h #define Out__h @@ -15,6 +15,7 @@ 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 void *Out__init(void); diff --git a/bootstrap/unix-88/Platform.c b/bootstrap/unix-88/Platform.c index 79765125..feddb176 100644 --- a/bootstrap/unix-88/Platform.c +++ b/bootstrap/unix-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 ff4f1129..ffacb767 100644 --- a/bootstrap/unix-88/Platform.h +++ b/bootstrap/unix-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 7d395538..4e18ac01 100644 --- a/bootstrap/unix-88/Reals.c +++ b/bootstrap/unix-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 98731ba9..5728d211 100644 --- a/bootstrap/unix-88/Reals.h +++ b/bootstrap/unix-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 7d4bf19a..37643e92 100644 --- a/bootstrap/unix-88/Strings.c +++ b/bootstrap/unix-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/unix-88/Strings.h b/bootstrap/unix-88/Strings.h index 939e74d8..b7482150 100644 --- a/bootstrap/unix-88/Strings.h +++ b/bootstrap/unix-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 ebb0ff54..0d2f319e 100644 --- a/bootstrap/unix-88/Texts.c +++ b/bootstrap/unix-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 b75c50d4..4b01b650 100644 --- a/bootstrap/unix-88/Texts.h +++ b/bootstrap/unix-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 49c6425d..5ecfeea1 100644 --- a/bootstrap/unix-88/errors.c +++ b/bootstrap/unix-88/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 e7ecd052..20eeca0d 100644 --- a/bootstrap/unix-88/errors.h +++ b/bootstrap/unix-88/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 b58bcc2a..b1328b1c 100644 --- a/bootstrap/unix-88/extTools.c +++ b/bootstrap/unix-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 cb8a5a95..27684ca4 100644 --- a/bootstrap/unix-88/extTools.h +++ b/bootstrap/unix-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 92ed02e4..a2c7b023 100644 --- a/bootstrap/unix-88/vt100.c +++ b/bootstrap/unix-88/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 393203ef..83b8a893 100644 --- a/bootstrap/unix-88/vt100.h +++ b/bootstrap/unix-88/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 f176c32c..2dd6f251 100644 --- a/bootstrap/windows-48/Compiler.c +++ b/bootstrap/windows-48/Compiler.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ +/* voc 1.95 [2016/10/08]. 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 cd60e0eb..3498204c 100644 --- a/bootstrap/windows-48/Configuration.c +++ b/bootstrap/windows-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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/04]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("1.95 [2016/10/08]. 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 51248a3a..14d86591 100644 --- a/bootstrap/windows-48/Configuration.h +++ b/bootstrap/windows-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 d994f80e..a444fff2 100644 --- a/bootstrap/windows-48/Files.c +++ b/bootstrap/windows-48/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 ee2c6a91..a447dbad 100644 --- a/bootstrap/windows-48/Files.h +++ b/bootstrap/windows-48/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 bf247ca6..860107f9 100644 --- a/bootstrap/windows-48/Heap.c +++ b/bootstrap/windows-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. 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 2b27eb13..84c9bb20 100644 --- a/bootstrap/windows-48/Heap.h +++ b/bootstrap/windows-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. 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 19cf402a..ab3bb29b 100644 --- a/bootstrap/windows-48/Modules.c +++ b/bootstrap/windows-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 eb8d7d25..95fc4f94 100644 --- a/bootstrap/windows-48/Modules.h +++ b/bootstrap/windows-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 4df43c2a..bfc64251 100644 --- a/bootstrap/windows-48/OPB.c +++ b/bootstrap/windows-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 bab5adcc..d04325c7 100644 --- a/bootstrap/windows-48/OPB.h +++ b/bootstrap/windows-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 fd8f546f..54cd9a85 100644 --- a/bootstrap/windows-48/OPC.c +++ b/bootstrap/windows-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 662ac74a..69a5580c 100644 --- a/bootstrap/windows-48/OPC.h +++ b/bootstrap/windows-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 8430bf82..7da9b7b0 100644 --- a/bootstrap/windows-48/OPM.c +++ b/bootstrap/windows-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 d7aadb69..d2a06df9 100644 --- a/bootstrap/windows-48/OPM.h +++ b/bootstrap/windows-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 016b40ed..768bfd2c 100644 --- a/bootstrap/windows-48/OPP.c +++ b/bootstrap/windows-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 90da6ba9..ee87db69 100644 --- a/bootstrap/windows-48/OPP.h +++ b/bootstrap/windows-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 f7f892bf..02c301dc 100644 --- a/bootstrap/windows-48/OPS.c +++ b/bootstrap/windows-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 d97f3caa..98dd65e7 100644 --- a/bootstrap/windows-48/OPS.h +++ b/bootstrap/windows-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 911d49ab..7ebdfd73 100644 --- a/bootstrap/windows-48/OPT.c +++ b/bootstrap/windows-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 88225ce2..f5b615f8 100644 --- a/bootstrap/windows-48/OPT.h +++ b/bootstrap/windows-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 65f5d6d9..ce5e3036 100644 --- a/bootstrap/windows-48/OPV.c +++ b/bootstrap/windows-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 ab72377c..43fd6331 100644 --- a/bootstrap/windows-48/OPV.h +++ b/bootstrap/windows-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 6ea96ec6..790b4f75 100644 --- a/bootstrap/windows-48/Out.c +++ b/bootstrap/windows-48/Out.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -7,6 +7,7 @@ #include "SYSTEM.h" #include "Platform.h" +#include "Strings.h" @@ -18,7 +19,13 @@ export void Out_LongReal (LONGREAL x, int16 n); export void Out_Open (void); export void Out_Real (REAL x, int16 n); export void Out_String (CHAR *str, LONGINT str__len); +export REAL Out_Ten (int16 e); +static LONGREAL Out_TenL (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_Open (void) { @@ -36,7 +43,7 @@ void Out_String (CHAR *str, LONGINT str__len) int16 error; __DUP(str, str__len, CHAR); l = 0; - while ((l < str__len && str[l] != 0x00)) { + while ((l < str__len && str[__X(l, str__len)] != 0x00)) { l += 1; } error = Platform_Write(Platform_StdOut, (address)str, l); @@ -60,13 +67,13 @@ void Out_Int (int64 x, int64 n) x = __DIV(x, 10); i = 1; while (x != 0) { - s[i] = (CHAR)(48 + __MOD(x, 10)); + s[__X(i, 22)] = (CHAR)(48 + __MOD(x, 10)); x = __DIV(x, 10); i += 1; } } if (negative) { - s[i] = '-'; + s[__X(i, 22)] = '-'; i += 1; } while (n > (int64)i) { @@ -75,28 +82,262 @@ void Out_Int (int64 x, int64 n) } while (i > 0) { i -= 1; - Out_Char(s[i]); + Out_Char(s[__X(i, 22)]); } } -void Out_Real (REAL x, int16 n) -{ -} - -void Out_LongReal (LONGREAL x, int16 n) -{ -} - void Out_Ln (void) { Out_String(Platform_NL, 3); } +static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i) +{ + *i -= 1; + s[__X(*i, s__len)] = (CHAR)(__MOD(n, 10) + 48); +} + +static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 *i) +{ + int16 j, l; + __DUP(t, t__len, CHAR); + l = Strings_Length(t, t__len); + if (l > *i) { + l = *i; + } + *i -= l; + j = 0; + while (j < l) { + s[__X(*i + j, s__len)] = t[__X(j, t__len)]; + j += 1; + } + __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 _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_LongReal (LONGREAL x, int16 n) +{ + int16 e; + int64 f; + CHAR s[30]; + int16 i; + LONGREAL x0; + BOOLEAN nn, en; + int64 m; + int16 d; + nn = __VAL(int64, x) < 0; + if (nn) { + n -= 1; + } + e = (int16)__MASK(__ASHR((__VAL(int64, x)), 52), -2048); + f = __MASK((__VAL(int64, x)), -4503599627370496); + i = 30; + if (e == 2047) { + 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*)"D+000", 6, (void*)s, 30, &i); + m = 0; + } else { + if (nn) { + x = -x; + } + e = (int16)__ASHR((e - 1023) * 77, 8); + if (e >= 0) { + x = x / (LONGREAL)Out_TenL(e); + } else { + x = Out_TenL(-e) * x; + } + if (x >= (LONGREAL)10) { + x = 1.00000000000000e-001 * x; + e += 1; + } + en = e < 0; + if (en) { + e = -e; + } + d = 3; + while (d > 0) { + Out_digit(e, (void*)s, 30, &i); + e = __DIV(e, 10); + d -= 1; + } + if (en) { + Out_prepend((CHAR*)"D-", 3, (void*)s, 30, &i); + } else { + Out_prepend((CHAR*)"D+", 3, (void*)s, 30, &i); + } + x0 = Out_TenL(15); + x = x0 * x + 5.00000000000000e-001; + if (x >= (LONGREAL)10 * x0) { + x = 1.00000000000000e-001 * x; + e += 1; + } + m = Out_Entier64(x); + } + d = 16; + while ((((d > 2 && d > n - 6)) && __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; + } +} + export void *Out__init(void) { __DEFMOD; __MODULE_IMPORT(Platform); + __MODULE_IMPORT(Strings); __REGMOD("Out", 0); __REGCMD("Ln", Out_Ln); __REGCMD("Open", Out_Open); diff --git a/bootstrap/windows-48/Out.h b/bootstrap/windows-48/Out.h index 4d3199e6..9076f6d1 100644 --- a/bootstrap/windows-48/Out.h +++ b/bootstrap/windows-48/Out.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Out__h #define Out__h @@ -15,6 +15,7 @@ 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 void *Out__init(void); diff --git a/bootstrap/windows-48/Platform.c b/bootstrap/windows-48/Platform.c index f88bbad9..3e82ab82 100644 --- a/bootstrap/windows-48/Platform.c +++ b/bootstrap/windows-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 e1231b49..c5ff14b6 100644 --- a/bootstrap/windows-48/Platform.h +++ b/bootstrap/windows-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 7d395538..4e18ac01 100644 --- a/bootstrap/windows-48/Reals.c +++ b/bootstrap/windows-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 98731ba9..5728d211 100644 --- a/bootstrap/windows-48/Reals.h +++ b/bootstrap/windows-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 7d4bf19a..37643e92 100644 --- a/bootstrap/windows-48/Strings.c +++ b/bootstrap/windows-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-48/Strings.h b/bootstrap/windows-48/Strings.h index 939e74d8..b7482150 100644 --- a/bootstrap/windows-48/Strings.h +++ b/bootstrap/windows-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 f6698990..92376713 100644 --- a/bootstrap/windows-48/Texts.c +++ b/bootstrap/windows-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 baa9464f..107cdc6c 100644 --- a/bootstrap/windows-48/Texts.h +++ b/bootstrap/windows-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 49c6425d..5ecfeea1 100644 --- a/bootstrap/windows-48/errors.c +++ b/bootstrap/windows-48/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 e7ecd052..20eeca0d 100644 --- a/bootstrap/windows-48/errors.h +++ b/bootstrap/windows-48/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 b58bcc2a..b1328b1c 100644 --- a/bootstrap/windows-48/extTools.c +++ b/bootstrap/windows-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 cb8a5a95..27684ca4 100644 --- a/bootstrap/windows-48/extTools.h +++ b/bootstrap/windows-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 92ed02e4..a2c7b023 100644 --- a/bootstrap/windows-48/vt100.c +++ b/bootstrap/windows-48/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 393203ef..83b8a893 100644 --- a/bootstrap/windows-48/vt100.h +++ b/bootstrap/windows-48/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 f176c32c..2dd6f251 100644 --- a/bootstrap/windows-88/Compiler.c +++ b/bootstrap/windows-88/Compiler.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspamSf */ +/* voc 1.95 [2016/10/08]. 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 cd60e0eb..3498204c 100644 --- a/bootstrap/windows-88/Configuration.c +++ b/bootstrap/windows-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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/04]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 75); + __MOVE("1.95 [2016/10/08]. 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 51248a3a..14d86591 100644 --- a/bootstrap/windows-88/Configuration.h +++ b/bootstrap/windows-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 06562971..dd50c47a 100644 --- a/bootstrap/windows-88/Files.c +++ b/bootstrap/windows-88/Files.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 f2adf7f8..99068de9 100644 --- a/bootstrap/windows-88/Files.h +++ b/bootstrap/windows-88/Files.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 d929bf31..e3aceaf6 100644 --- a/bootstrap/windows-88/Heap.c +++ b/bootstrap/windows-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. 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 c0f06627..29ed6e2f 100644 --- a/bootstrap/windows-88/Heap.h +++ b/bootstrap/windows-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. 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 3f625202..273f6c11 100644 --- a/bootstrap/windows-88/Modules.c +++ b/bootstrap/windows-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 eb8d7d25..95fc4f94 100644 --- a/bootstrap/windows-88/Modules.h +++ b/bootstrap/windows-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 4df43c2a..bfc64251 100644 --- a/bootstrap/windows-88/OPB.c +++ b/bootstrap/windows-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 bab5adcc..d04325c7 100644 --- a/bootstrap/windows-88/OPB.h +++ b/bootstrap/windows-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 fd8f546f..54cd9a85 100644 --- a/bootstrap/windows-88/OPC.c +++ b/bootstrap/windows-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 662ac74a..69a5580c 100644 --- a/bootstrap/windows-88/OPC.h +++ b/bootstrap/windows-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 69eb0109..ec6acf95 100644 --- a/bootstrap/windows-88/OPM.c +++ b/bootstrap/windows-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 d7aadb69..d2a06df9 100644 --- a/bootstrap/windows-88/OPM.h +++ b/bootstrap/windows-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 aa541ba7..ddd0d49c 100644 --- a/bootstrap/windows-88/OPP.c +++ b/bootstrap/windows-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 90da6ba9..ee87db69 100644 --- a/bootstrap/windows-88/OPP.h +++ b/bootstrap/windows-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 f7f892bf..02c301dc 100644 --- a/bootstrap/windows-88/OPS.c +++ b/bootstrap/windows-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 d97f3caa..98dd65e7 100644 --- a/bootstrap/windows-88/OPS.h +++ b/bootstrap/windows-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tspaSfF */ +/* voc 1.95 [2016/10/08]. 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 5adea265..60915d55 100644 --- a/bootstrap/windows-88/OPT.c +++ b/bootstrap/windows-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 88225ce2..f5b615f8 100644 --- a/bootstrap/windows-88/OPT.h +++ b/bootstrap/windows-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 8a61c677..e3b8aff9 100644 --- a/bootstrap/windows-88/OPV.c +++ b/bootstrap/windows-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 ab72377c..43fd6331 100644 --- a/bootstrap/windows-88/OPV.h +++ b/bootstrap/windows-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 6ea96ec6..790b4f75 100644 --- a/bootstrap/windows-88/Out.c +++ b/bootstrap/windows-88/Out.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 @@ -7,6 +7,7 @@ #include "SYSTEM.h" #include "Platform.h" +#include "Strings.h" @@ -18,7 +19,13 @@ export void Out_LongReal (LONGREAL x, int16 n); export void Out_Open (void); export void Out_Real (REAL x, int16 n); export void Out_String (CHAR *str, LONGINT str__len); +export REAL Out_Ten (int16 e); +static LONGREAL Out_TenL (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_Open (void) { @@ -36,7 +43,7 @@ void Out_String (CHAR *str, LONGINT str__len) int16 error; __DUP(str, str__len, CHAR); l = 0; - while ((l < str__len && str[l] != 0x00)) { + while ((l < str__len && str[__X(l, str__len)] != 0x00)) { l += 1; } error = Platform_Write(Platform_StdOut, (address)str, l); @@ -60,13 +67,13 @@ void Out_Int (int64 x, int64 n) x = __DIV(x, 10); i = 1; while (x != 0) { - s[i] = (CHAR)(48 + __MOD(x, 10)); + s[__X(i, 22)] = (CHAR)(48 + __MOD(x, 10)); x = __DIV(x, 10); i += 1; } } if (negative) { - s[i] = '-'; + s[__X(i, 22)] = '-'; i += 1; } while (n > (int64)i) { @@ -75,28 +82,262 @@ void Out_Int (int64 x, int64 n) } while (i > 0) { i -= 1; - Out_Char(s[i]); + Out_Char(s[__X(i, 22)]); } } -void Out_Real (REAL x, int16 n) -{ -} - -void Out_LongReal (LONGREAL x, int16 n) -{ -} - void Out_Ln (void) { Out_String(Platform_NL, 3); } +static void Out_digit (int64 n, CHAR *s, LONGINT s__len, int16 *i) +{ + *i -= 1; + s[__X(*i, s__len)] = (CHAR)(__MOD(n, 10) + 48); +} + +static void Out_prepend (CHAR *t, LONGINT t__len, CHAR *s, LONGINT s__len, int16 *i) +{ + int16 j, l; + __DUP(t, t__len, CHAR); + l = Strings_Length(t, t__len); + if (l > *i) { + l = *i; + } + *i -= l; + j = 0; + while (j < l) { + s[__X(*i + j, s__len)] = t[__X(j, t__len)]; + j += 1; + } + __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 _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_LongReal (LONGREAL x, int16 n) +{ + int16 e; + int64 f; + CHAR s[30]; + int16 i; + LONGREAL x0; + BOOLEAN nn, en; + int64 m; + int16 d; + nn = __VAL(int64, x) < 0; + if (nn) { + n -= 1; + } + e = (int16)__MASK(__ASHR((__VAL(int64, x)), 52), -2048); + f = __MASK((__VAL(int64, x)), -4503599627370496); + i = 30; + if (e == 2047) { + 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*)"D+000", 6, (void*)s, 30, &i); + m = 0; + } else { + if (nn) { + x = -x; + } + e = (int16)__ASHR((e - 1023) * 77, 8); + if (e >= 0) { + x = x / (LONGREAL)Out_TenL(e); + } else { + x = Out_TenL(-e) * x; + } + if (x >= (LONGREAL)10) { + x = 1.00000000000000e-001 * x; + e += 1; + } + en = e < 0; + if (en) { + e = -e; + } + d = 3; + while (d > 0) { + Out_digit(e, (void*)s, 30, &i); + e = __DIV(e, 10); + d -= 1; + } + if (en) { + Out_prepend((CHAR*)"D-", 3, (void*)s, 30, &i); + } else { + Out_prepend((CHAR*)"D+", 3, (void*)s, 30, &i); + } + x0 = Out_TenL(15); + x = x0 * x + 5.00000000000000e-001; + if (x >= (LONGREAL)10 * x0) { + x = 1.00000000000000e-001 * x; + e += 1; + } + m = Out_Entier64(x); + } + d = 16; + while ((((d > 2 && d > n - 6)) && __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; + } +} + export void *Out__init(void) { __DEFMOD; __MODULE_IMPORT(Platform); + __MODULE_IMPORT(Strings); __REGMOD("Out", 0); __REGCMD("Ln", Out_Ln); __REGCMD("Open", Out_Open); diff --git a/bootstrap/windows-88/Out.h b/bootstrap/windows-88/Out.h index 4d3199e6..9076f6d1 100644 --- a/bootstrap/windows-88/Out.h +++ b/bootstrap/windows-88/Out.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. tsSfF */ +/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef Out__h #define Out__h @@ -15,6 +15,7 @@ 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 void *Out__init(void); diff --git a/bootstrap/windows-88/Platform.c b/bootstrap/windows-88/Platform.c index e99e1be2..6f3c4e4f 100644 --- a/bootstrap/windows-88/Platform.c +++ b/bootstrap/windows-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 04c87a8c..1008cc4b 100644 --- a/bootstrap/windows-88/Platform.h +++ b/bootstrap/windows-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 7d395538..4e18ac01 100644 --- a/bootstrap/windows-88/Reals.c +++ b/bootstrap/windows-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 98731ba9..5728d211 100644 --- a/bootstrap/windows-88/Reals.h +++ b/bootstrap/windows-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 7d4bf19a..37643e92 100644 --- a/bootstrap/windows-88/Strings.c +++ b/bootstrap/windows-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #define SHORTINT int8 #define INTEGER int16 diff --git a/bootstrap/windows-88/Strings.h b/bootstrap/windows-88/Strings.h index 939e74d8..b7482150 100644 --- a/bootstrap/windows-88/Strings.h +++ b/bootstrap/windows-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 ebb0ff54..0d2f319e 100644 --- a/bootstrap/windows-88/Texts.c +++ b/bootstrap/windows-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 b75c50d4..4b01b650 100644 --- a/bootstrap/windows-88/Texts.h +++ b/bootstrap/windows-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 49c6425d..5ecfeea1 100644 --- a/bootstrap/windows-88/errors.c +++ b/bootstrap/windows-88/errors.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 e7ecd052..20eeca0d 100644 --- a/bootstrap/windows-88/errors.h +++ b/bootstrap/windows-88/errors.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 b58bcc2a..b1328b1c 100644 --- a/bootstrap/windows-88/extTools.c +++ b/bootstrap/windows-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 cb8a5a95..27684ca4 100644 --- a/bootstrap/windows-88/extTools.h +++ b/bootstrap/windows-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 92ed02e4..a2c7b023 100644 --- a/bootstrap/windows-88/vt100.c +++ b/bootstrap/windows-88/vt100.c @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. 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 393203ef..83b8a893 100644 --- a/bootstrap/windows-88/vt100.h +++ b/bootstrap/windows-88/vt100.h @@ -1,4 +1,4 @@ -/* voc 1.95 [2016/10/04]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ +/* voc 1.95 [2016/10/08]. Bootstrapping compiler for address size 8, alignment 8. xtspaSfF */ #ifndef vt100__h #define vt100__h diff --git a/src/runtime/Math.Mod b/src/runtime/Math.Mod index 216275ef..b3ca4e6a 100644 --- a/src/runtime/Math.Mod +++ b/src/runtime/Math.Mod @@ -271,7 +271,7 @@ END div; PROCEDURE^ arctan2* (xn, xd: REAL): REAL; PROCEDURE^ sincos* (x: REAL; VAR Sin, Cos: REAL); -PROCEDURE round * (x: REAL): LONGINT; +PROCEDURE round* (x: REAL): LONGINT; (* Returns the value of x rounded to the nearest integer *) BEGIN IF x < ZERO THEN RETURN -ENTIER(HALF - x) @@ -279,7 +279,7 @@ BEGIN END END round; -PROCEDURE sqrt * (x: REAL): REAL; +PROCEDURE sqrt* (x: REAL): REAL; (* Returns the positive square root of x where x >= 0 *) CONST P0 = 0.41731; P1 = 0.59016; @@ -306,7 +306,7 @@ BEGIN RETURN scale(yEst, xExp DIV 2) END sqrt; -PROCEDURE exp * (x: REAL): REAL; +PROCEDURE exp* (x: REAL): REAL; (* Returns the exponential of x for x < Ln(MAX(REAL)) *) CONST ln2 = 0.6931471805599453094172321D0; @@ -328,7 +328,7 @@ BEGIN RETURN scale(HALF + p/(q - p), SHORT(n + 1)) END exp; -PROCEDURE ln * (x: REAL): REAL; +PROCEDURE ln* (x: REAL): REAL; (* Returns the natural logarithm of x for x > 0 *) CONST c1 = 355.0/512.0; c2 = -2.121944400546905827679E-4; @@ -354,7 +354,7 @@ END ln; (* The angle in all trigonometric functions is measured in radians *) -PROCEDURE sin * (x: REAL): REAL; +PROCEDURE sin* (x: REAL): REAL; (* Returns the sine of x for all x *) BEGIN IF x < ZERO THEN RETURN SinCos(x, -x, -ONE) @@ -362,13 +362,13 @@ BEGIN END END sin; -PROCEDURE cos * (x: REAL): REAL; +PROCEDURE cos* (x: REAL): REAL; (* Returns the cosine of x for all x *) BEGIN RETURN SinCos(x, ABS(x) + piByTwo, ONE) END cos; -PROCEDURE tan * (x: REAL): REAL; +PROCEDURE tan* (x: REAL): REAL; (* Returns the tangent of x where x cannot be an odd multiple of pi/2 *) CONST ymax = 6434; (* ENTIER(2 * *(MantBits/2) * pi/2) *) @@ -428,7 +428,7 @@ BEGIN END END asincos; -PROCEDURE arcsin * (x: REAL): REAL; +PROCEDURE arcsin* (x: REAL): REAL; (* Returns the arcsine of x, in the range [ - pi/2, pi/2] where -1 <= x <= 1 *) VAR res: REAL; i: LONGINT; @@ -442,7 +442,7 @@ BEGIN RETURN res END arcsin; -PROCEDURE arccos * (x: REAL): REAL; +PROCEDURE arccos* (x: REAL): REAL; (* Returns the arccosine of x, in the range [0, pi] where -1 <= x <= 1 *) VAR res: REAL; i: LONGINT; @@ -497,7 +497,7 @@ BEGIN RETURN res END atan; -PROCEDURE arctan * (x: REAL): REAL; +PROCEDURE arctan* (x: REAL): REAL; (* Returns the arctangent of x, in the range [ - pi/2, pi/2] for all x *) BEGIN IF x < 0 THEN RETURN -atan( - x) @@ -505,7 +505,7 @@ BEGIN END END arctan; -PROCEDURE power * (base, exp: REAL): REAL; +PROCEDURE power* (base, exp: REAL): REAL; (* Returns the value of the number base raised to the power exponent for base > 0 *) CONST P1 = 0.83357541E-1; K = 0.4426950409; @@ -558,7 +558,7 @@ BEGIN RETURN scale(z, SHORT(mp)) END power; -PROCEDURE IsRMathException * (): BOOLEAN; +PROCEDURE IsRMathException* (): BOOLEAN; (* Returns TRUE if the current coroutine is in the exceptional execution state because of the raising of the RealMath exception; otherwise returns FALSE. *) diff --git a/src/runtime/MathL.Mod b/src/runtime/MathL.Mod index c3355d2e..69f994bb 100644 --- a/src/runtime/MathL.Mod +++ b/src/runtime/MathL.Mod @@ -96,7 +96,7 @@ CONST ONE = 1.0D0; HALF = 0.5D0; TWO = 2.0D0; - miny = ONE/large; (* Smallest number this package accepts *) + miny = ONE/large; (* Smallest number this package accepts *) sqrtHalf = 0.70710678118654752440D0; Limit = 1.0536712D-8; (* 2**(-MantBits/2) *) eps = 5.5511151D-17; (* 2**(-MantBits-1) *) diff --git a/src/runtime/Out.Mod b/src/runtime/Out.Mod index 66db1944..72287c56 100644 --- a/src/runtime/Out.Mod +++ b/src/runtime/Out.Mod @@ -1,6 +1,6 @@ -MODULE Out; (* D C W Brown. 2016-09-27 *) +MODULE Out; (* DCW Brown. 2016-09-27 *) - IMPORT SYSTEM, Platform; +IMPORT SYSTEM, Platform, Strings; PROCEDURE Open*; BEGIN @@ -40,16 +40,190 @@ BEGIN WHILE i > 0 DO DEC(i); Char(s[i]) END END Int; -PROCEDURE Real*(x: REAL; n: INTEGER); -BEGIN -END Real; - -PROCEDURE LongReal*(x: LONGREAL; n: INTEGER); -BEGIN -END LongReal; - PROCEDURE Ln*; BEGIN String(Platform.NL) END Ln; + +(* Real and Longreal display *) + +PROCEDURE digit(n: HUGEINT; VAR s: ARRAY OF CHAR; VAR i: INTEGER); +BEGIN + DEC(i); s[i] := CHR(n MOD 10 + 48); +END digit; + +PROCEDURE prepend(t: ARRAY OF CHAR; VAR s: ARRAY OF CHAR; VAR i: INTEGER); + VAR j, l: INTEGER; +BEGIN + l := Strings.Length(t); IF l > i THEN l := i END; + DEC(i, l); j := 0; + WHILE j < l DO s[i+j] := t[j]; INC(j) END +END prepend; + + +PROCEDURE Ten*(e: INTEGER): REAL; +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 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; + +PROCEDURE -Entier64(x: LONGREAL): SYSTEM.INT64 "(int64)(x)"; + +PROCEDURE LongReal*(x: LONGREAL; n: INTEGER); + +(* 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 + three-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. + 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 *) + s: ARRAY 30 OF CHAR; (* Buffer built backwards *) + i: INTEGER; (* Index into s *) + x0: LONGREAL; + nn: BOOLEAN; (* Number negative *) + en: BOOLEAN; (* Exponent negative *) + m: HUGEINT; (* Mantissa digits *) + d: INTEGER; (* Significant digit count to display *) + +BEGIN + nn := SYSTEM.VAL(HUGEINT, x) < 0; IF nn THEN DEC(n) END; + e := SYSTEM.VAL(INTEGER, (SYSTEM.VAL(HUGEINT, x) DIV 10000000000000H) MOD 800H); + f := SYSTEM.VAL(HUGEINT, x) MOD 10000000000000H; + + i := LEN(s); + 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; + 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 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; + + (* Scale x to 15 significant digits *) + x0 := TenL(maxsigdigits-1); + x := x0 * x + 0.5D0; + IF x >= 10.0D0 * x0 THEN x := 0.1D0 * x; INC(e) END; + m := Entier64(x) + END; + + (* 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; + + (* 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 LongReal; + + END Out. diff --git a/src/tools/make/oberon.mk b/src/tools/make/oberon.mk index 4e054338..b8688337 100644 --- a/src/tools/make/oberon.mk +++ b/src/tools/make/oberon.mk @@ -104,8 +104,8 @@ translate: cd $(BUILDDIR); $(ROOTDIR)/$(OBECOMP) -SsfF -A$(ADRSIZE)$(ALIGNMENT) -O$(MODEL) ../../Configuration.Mod cd $(BUILDDIR); $(ROOTDIR)/$(OBECOMP) -SsfF -A$(ADRSIZE)$(ALIGNMENT) -O$(MODEL) ../../src/runtime/Platform$(PLATFORM).Mod cd $(BUILDDIR); $(ROOTDIR)/$(OBECOMP) -SsfFapx -A$(ADRSIZE)$(ALIGNMENT) -O$(MODEL) ../../src/runtime/Heap.Mod - cd $(BUILDDIR); $(ROOTDIR)/$(OBECOMP) -SsfFapx -A$(ADRSIZE)$(ALIGNMENT) -O$(MODEL) ../../src/runtime/Out.Mod cd $(BUILDDIR); $(ROOTDIR)/$(OBECOMP) -SsfF -A$(ADRSIZE)$(ALIGNMENT) -O$(MODEL) ../../src/runtime/Strings.Mod + cd $(BUILDDIR); $(ROOTDIR)/$(OBECOMP) -SsfF -A$(ADRSIZE)$(ALIGNMENT) -O$(MODEL) ../../src/runtime/Out.Mod cd $(BUILDDIR); $(ROOTDIR)/$(OBECOMP) -SsfF -A$(ADRSIZE)$(ALIGNMENT) -O$(MODEL) ../../src/runtime/Modules.Mod cd $(BUILDDIR); $(ROOTDIR)/$(OBECOMP) -SsfFx -A$(ADRSIZE)$(ALIGNMENT) -O$(MODEL) ../../src/runtime/Files.Mod cd $(BUILDDIR); $(ROOTDIR)/$(OBECOMP) -SsfF -A$(ADRSIZE)$(ALIGNMENT) -O$(MODEL) ../../src/runtime/Reals.Mod @@ -195,9 +195,9 @@ runtime: cd $(BUILDDIR)/$(MODEL) && $(COMPILE) -c SYSTEM.c cd $(BUILDDIR)/$(MODEL); $(ROOTDIR)/$(OBECOMP) -Ffs -O$(MODEL) ../../../src/runtime/Platform$(PLATFORM).Mod cd $(BUILDDIR)/$(MODEL); $(ROOTDIR)/$(OBECOMP) -Ffs -O$(MODEL) ../../../src/runtime/Heap.Mod - cd $(BUILDDIR)/$(MODEL); $(ROOTDIR)/$(OBECOMP) -Ffs -O$(MODEL) ../../../src/runtime/Out.Mod cd $(BUILDDIR)/$(MODEL); $(ROOTDIR)/$(OBECOMP) -Ffs -O$(MODEL) ../../../src/runtime/Modules.Mod cd $(BUILDDIR)/$(MODEL); $(ROOTDIR)/$(OBECOMP) -Ffs -O$(MODEL) ../../../src/runtime/Strings.Mod + cd $(BUILDDIR)/$(MODEL); $(ROOTDIR)/$(OBECOMP) -Ffs -O$(MODEL) ../../../src/runtime/Out.Mod cd $(BUILDDIR)/$(MODEL); $(ROOTDIR)/$(OBECOMP) -Ffs -O$(MODEL) ../../../src/runtime/Files.Mod cd $(BUILDDIR)/$(MODEL); $(ROOTDIR)/$(OBECOMP) -Ffs -O$(MODEL) ../../../src/runtime/Math.Mod cd $(BUILDDIR)/$(MODEL); $(ROOTDIR)/$(OBECOMP) -Ffs -O$(MODEL) ../../../src/runtime/MathL.Mod @@ -387,6 +387,7 @@ RUNTEST = COMPILER=$(COMPILER) OBECOMP="$(OBECOMP) -O$(MODEL)" FLAVOUR=$(FLAVOUR confidence: @printf "\n\n--- Confidence tests ---\n\n" +# cd src/test/confidence/math; $(RUNTEST) cd src/test/confidence/hello; $(RUNTEST) cd src/test/confidence/intsyntax; $(RUNTEST) cd src/test/confidence/language; $(RUNTEST)