From 4dd3c395fedef083a306481c55af980de05cca0d Mon Sep 17 00:00:00 2001 From: Norayr Chilingarian Date: Sun, 12 Jul 2026 18:16:58 +0400 Subject: [PATCH] adding big-endian support across compiler, runtime, and library modules - adding Platform.LittleEndian to centralize endianness detection - using SYSTEM.GET with correct byte offset for HUGEINT to smaller type reads on big-endian - fixing Reals.BytesToHex iteration direction and InitEndian for big-endian - fixing oocLowReal fraction, IsInfinity, IsNaN using Reals.Expo/SetExpo - fixing Math.ToREAL and MathL.exponent for big-endian - fixing In.Int and In.LongInt for big-endian - fixing outtest.wh byte iteration direction for big-endian - regenerating all bootstrap C sources - tested on ppc32 --- bootstrap/unix-44/Compiler.c | 2 +- bootstrap/unix-44/Configuration.c | 4 +- bootstrap/unix-44/Configuration.h | 2 +- bootstrap/unix-44/Files.c | 12 ++-- bootstrap/unix-44/Files.h | 2 +- bootstrap/unix-44/Heap.c | 2 +- bootstrap/unix-44/Heap.h | 2 +- bootstrap/unix-44/Modules.c | 4 +- bootstrap/unix-44/Modules.h | 2 +- bootstrap/unix-44/OPB.c | 10 ++- bootstrap/unix-44/OPB.h | 2 +- bootstrap/unix-44/OPC.c | 2 +- bootstrap/unix-44/OPC.h | 2 +- bootstrap/unix-44/OPM.c | 18 +++++- bootstrap/unix-44/OPM.h | 2 +- bootstrap/unix-44/OPP.c | 2 +- bootstrap/unix-44/OPP.h | 2 +- bootstrap/unix-44/OPS.c | 2 +- bootstrap/unix-44/OPS.h | 2 +- bootstrap/unix-44/OPT.c | 2 +- bootstrap/unix-44/OPT.h | 2 +- bootstrap/unix-44/OPV.c | 2 +- bootstrap/unix-44/OPV.h | 2 +- bootstrap/unix-44/Out.c | 2 +- bootstrap/unix-44/Out.h | 2 +- bootstrap/unix-44/Platform.c | 2 +- bootstrap/unix-44/Platform.h | 2 +- bootstrap/unix-44/Reals.c | 79 ++++++++++++++++------ bootstrap/unix-44/Reals.h | 3 +- bootstrap/unix-44/Strings.c | 2 +- bootstrap/unix-44/Strings.h | 2 +- bootstrap/unix-44/Texts.c | 2 +- bootstrap/unix-44/Texts.h | 2 +- bootstrap/unix-44/VT100.c | 2 +- bootstrap/unix-44/VT100.h | 2 +- bootstrap/unix-44/extTools.c | 2 +- bootstrap/unix-44/extTools.h | 2 +- bootstrap/unix-48/Compiler.c | 2 +- bootstrap/unix-48/Configuration.c | 4 +- bootstrap/unix-48/Configuration.h | 2 +- bootstrap/unix-48/Files.c | 12 ++-- bootstrap/unix-48/Files.h | 2 +- bootstrap/unix-48/Heap.c | 2 +- bootstrap/unix-48/Heap.h | 2 +- bootstrap/unix-48/Modules.c | 4 +- bootstrap/unix-48/Modules.h | 2 +- bootstrap/unix-48/OPB.c | 10 ++- bootstrap/unix-48/OPB.h | 2 +- bootstrap/unix-48/OPC.c | 2 +- bootstrap/unix-48/OPC.h | 2 +- bootstrap/unix-48/OPM.c | 18 +++++- bootstrap/unix-48/OPM.h | 2 +- bootstrap/unix-48/OPP.c | 2 +- bootstrap/unix-48/OPP.h | 2 +- bootstrap/unix-48/OPS.c | 2 +- bootstrap/unix-48/OPS.h | 2 +- bootstrap/unix-48/OPT.c | 2 +- bootstrap/unix-48/OPT.h | 2 +- bootstrap/unix-48/OPV.c | 2 +- bootstrap/unix-48/OPV.h | 2 +- bootstrap/unix-48/Out.c | 2 +- bootstrap/unix-48/Out.h | 2 +- bootstrap/unix-48/Platform.c | 2 +- bootstrap/unix-48/Platform.h | 2 +- bootstrap/unix-48/Reals.c | 79 ++++++++++++++++------ bootstrap/unix-48/Reals.h | 3 +- bootstrap/unix-48/Strings.c | 2 +- bootstrap/unix-48/Strings.h | 2 +- bootstrap/unix-48/Texts.c | 2 +- bootstrap/unix-48/Texts.h | 2 +- bootstrap/unix-48/VT100.c | 2 +- bootstrap/unix-48/VT100.h | 2 +- bootstrap/unix-48/extTools.c | 2 +- bootstrap/unix-48/extTools.h | 2 +- bootstrap/unix-88/Compiler.c | 2 +- bootstrap/unix-88/Configuration.c | 4 +- bootstrap/unix-88/Configuration.h | 2 +- bootstrap/unix-88/Files.c | 12 ++-- bootstrap/unix-88/Files.h | 2 +- bootstrap/unix-88/Heap.c | 2 +- bootstrap/unix-88/Heap.h | 2 +- bootstrap/unix-88/Modules.c | 4 +- bootstrap/unix-88/Modules.h | 2 +- bootstrap/unix-88/OPB.c | 10 ++- bootstrap/unix-88/OPB.h | 2 +- bootstrap/unix-88/OPC.c | 2 +- bootstrap/unix-88/OPC.h | 2 +- bootstrap/unix-88/OPM.c | 18 +++++- bootstrap/unix-88/OPM.h | 2 +- bootstrap/unix-88/OPP.c | 2 +- bootstrap/unix-88/OPP.h | 2 +- bootstrap/unix-88/OPS.c | 2 +- bootstrap/unix-88/OPS.h | 2 +- bootstrap/unix-88/OPT.c | 2 +- bootstrap/unix-88/OPT.h | 2 +- bootstrap/unix-88/OPV.c | 2 +- bootstrap/unix-88/OPV.h | 2 +- bootstrap/unix-88/Out.c | 2 +- bootstrap/unix-88/Out.h | 2 +- bootstrap/unix-88/Platform.c | 2 +- bootstrap/unix-88/Platform.h | 2 +- bootstrap/unix-88/Reals.c | 79 ++++++++++++++++------ bootstrap/unix-88/Reals.h | 3 +- bootstrap/unix-88/Strings.c | 2 +- bootstrap/unix-88/Strings.h | 2 +- bootstrap/unix-88/Texts.c | 2 +- bootstrap/unix-88/Texts.h | 2 +- bootstrap/unix-88/VT100.c | 2 +- bootstrap/unix-88/VT100.h | 2 +- bootstrap/unix-88/extTools.c | 2 +- bootstrap/unix-88/extTools.h | 2 +- bootstrap/windows-48/Compiler.c | 2 +- bootstrap/windows-48/Configuration.c | 4 +- bootstrap/windows-48/Configuration.h | 2 +- bootstrap/windows-48/Files.c | 12 ++-- bootstrap/windows-48/Files.h | 2 +- bootstrap/windows-48/Heap.c | 2 +- bootstrap/windows-48/Heap.h | 2 +- bootstrap/windows-48/Modules.c | 4 +- bootstrap/windows-48/Modules.h | 2 +- bootstrap/windows-48/OPB.c | 10 ++- bootstrap/windows-48/OPB.h | 2 +- bootstrap/windows-48/OPC.c | 2 +- bootstrap/windows-48/OPC.h | 2 +- bootstrap/windows-48/OPM.c | 18 +++++- bootstrap/windows-48/OPM.h | 2 +- bootstrap/windows-48/OPP.c | 2 +- bootstrap/windows-48/OPP.h | 2 +- bootstrap/windows-48/OPS.c | 2 +- bootstrap/windows-48/OPS.h | 2 +- bootstrap/windows-48/OPT.c | 2 +- bootstrap/windows-48/OPT.h | 2 +- bootstrap/windows-48/OPV.c | 2 +- bootstrap/windows-48/OPV.h | 2 +- bootstrap/windows-48/Out.c | 2 +- bootstrap/windows-48/Out.h | 2 +- bootstrap/windows-48/Platform.c | 2 +- bootstrap/windows-48/Platform.h | 2 +- bootstrap/windows-48/Reals.c | 79 ++++++++++++++++------ bootstrap/windows-48/Reals.h | 3 +- bootstrap/windows-48/Strings.c | 2 +- bootstrap/windows-48/Strings.h | 2 +- bootstrap/windows-48/Texts.c | 2 +- bootstrap/windows-48/Texts.h | 2 +- bootstrap/windows-48/VT100.c | 2 +- bootstrap/windows-48/VT100.h | 2 +- bootstrap/windows-48/extTools.c | 2 +- bootstrap/windows-48/extTools.h | 2 +- bootstrap/windows-88/Compiler.c | 2 +- bootstrap/windows-88/Configuration.c | 4 +- bootstrap/windows-88/Configuration.h | 2 +- bootstrap/windows-88/Files.c | 12 ++-- bootstrap/windows-88/Files.h | 2 +- bootstrap/windows-88/Heap.c | 2 +- bootstrap/windows-88/Heap.h | 2 +- bootstrap/windows-88/Modules.c | 4 +- bootstrap/windows-88/Modules.h | 2 +- bootstrap/windows-88/OPB.c | 10 ++- bootstrap/windows-88/OPB.h | 2 +- bootstrap/windows-88/OPC.c | 2 +- bootstrap/windows-88/OPC.h | 2 +- bootstrap/windows-88/OPM.c | 18 +++++- bootstrap/windows-88/OPM.h | 2 +- bootstrap/windows-88/OPP.c | 2 +- bootstrap/windows-88/OPP.h | 2 +- bootstrap/windows-88/OPS.c | 2 +- bootstrap/windows-88/OPS.h | 2 +- bootstrap/windows-88/OPT.c | 2 +- bootstrap/windows-88/OPT.h | 2 +- bootstrap/windows-88/OPV.c | 2 +- bootstrap/windows-88/OPV.h | 2 +- bootstrap/windows-88/Out.c | 2 +- bootstrap/windows-88/Out.h | 2 +- bootstrap/windows-88/Platform.c | 2 +- bootstrap/windows-88/Platform.h | 2 +- bootstrap/windows-88/Reals.c | 79 ++++++++++++++++------ bootstrap/windows-88/Reals.h | 3 +- bootstrap/windows-88/Strings.c | 2 +- bootstrap/windows-88/Strings.h | 2 +- bootstrap/windows-88/Texts.c | 2 +- bootstrap/windows-88/Texts.h | 2 +- bootstrap/windows-88/VT100.c | 2 +- bootstrap/windows-88/VT100.h | 2 +- bootstrap/windows-88/extTools.c | 2 +- bootstrap/windows-88/extTools.h | 2 +- src/compiler/OPB.Mod | 9 ++- src/compiler/OPM.Mod | 27 +++++++- src/library/ooc/oocLowReal.Mod | 33 +--------- src/library/ulm/ulmTypes.Mod | 12 +++- src/runtime/Files.Mod | 10 +-- src/runtime/In.Mod | 16 ++++- src/runtime/Math.Mod | 11 +++- src/runtime/MathL.Mod | 11 +++- src/runtime/Modules.Mod | 2 +- src/runtime/Reals.Mod | 97 +++++++++++++++++++--------- src/test/confidence/out/outtest.mod | 12 ++-- src/tools/make/configure.c | 3 +- src/tools/make/oberon.mk | 4 +- 198 files changed, 788 insertions(+), 409 deletions(-) diff --git a/bootstrap/unix-44/Compiler.c b/bootstrap/unix-44/Compiler.c index 5fb197fa..bb8b6f66 100644 --- a/bootstrap/unix-44/Compiler.c +++ b/bootstrap/unix-44/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Configuration.c b/bootstrap/unix-44/Configuration.c index 28930ae6..ffabe11c 100644 --- a/bootstrap/unix-44/Configuration.c +++ b/bootstrap/unix-44/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); + __MOVE("2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); __ENDMOD; } diff --git a/bootstrap/unix-44/Configuration.h b/bootstrap/unix-44/Configuration.h index 06b2322e..4da616f3 100644 --- a/bootstrap/unix-44/Configuration.h +++ b/bootstrap/unix-44/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-44/Files.c b/bootstrap/unix-44/Files.c index ba5910fd..de296e47 100644 --- a/bootstrap/unix-44/Files.c +++ b/bootstrap/unix-44/Files.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -942,7 +942,11 @@ void Files_ReadNum (Files_Rider *R, ADDRESS *R__typ, SYSTEM_BYTE *x, ADDRESS x__ } q += (INT64)__ASH((__MASK(b, -64) - __ASHL(__ASHR(b, 6), 6)), s); Files_Assert(x__len <= 8); - __MOVE((ADDRESS)&q, (ADDRESS)x, x__len); + if (Platform_LittleEndian) { + __MOVE((ADDRESS)&q, (ADDRESS)x, x__len); + } else { + __MOVE(((ADDRESS)&q + 8) - (__SHORT(x__len, 32768)), (ADDRESS)x, x__len); + } } void Files_WriteBool (Files_Rider *R, ADDRESS *R__typ, BOOLEAN x) @@ -972,9 +976,7 @@ void Files_WriteSet (Files_Rider *R, ADDRESS *R__typ, UINT32 x) { CHAR b[4]; INT32 i; - UINT64 y; - y = x; - i = __VAL(INT32, y); + i = (INT32)x; b[0] = __CHR(i); b[1] = __CHR(__ASHR(i, 8)); b[2] = __CHR(__ASHR(i, 16)); diff --git a/bootstrap/unix-44/Files.h b/bootstrap/unix-44/Files.h index 8966b74a..c7037d93 100644 --- a/bootstrap/unix-44/Files.h +++ b/bootstrap/unix-44/Files.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-44/Heap.c b/bootstrap/unix-44/Heap.c index d00d1bec..3394b9ca 100644 --- a/bootstrap/unix-44/Heap.c +++ b/bootstrap/unix-44/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Heap.h b/bootstrap/unix-44/Heap.h index 3064651b..0b2056a8 100644 --- a/bootstrap/unix-44/Heap.h +++ b/bootstrap/unix-44/Heap.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-44/Modules.c b/bootstrap/unix-44/Modules.c index 0612b10d..d3df5c25 100644 --- a/bootstrap/unix-44/Modules.c +++ b/bootstrap/unix-44/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -52,7 +52,7 @@ extern void *Modules__init(void); void Modules_Init (INT32 argc, INT32 argvadr) { Modules_MainStackFrame = argvadr; - Modules_ArgCount = __VAL(INT16, argc); + Modules_ArgCount = __SHORT(argc, 32768); __GET(argvadr, Modules_ArgVector, INT32); Modules_InitHeap(); Modules_ModulesInit(); diff --git a/bootstrap/unix-44/Modules.h b/bootstrap/unix-44/Modules.h index 23f2dd74..f18e2955 100644 --- a/bootstrap/unix-44/Modules.h +++ b/bootstrap/unix-44/Modules.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/unix-44/OPB.c b/bootstrap/unix-44/OPB.c index 5a53405b..4db48170 100644 --- a/bootstrap/unix-44/OPB.c +++ b/bootstrap/unix-44/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -9,6 +9,7 @@ #include "OPM.h" #include "OPS.h" #include "OPT.h" +#include "Platform.h" static INT16 OPB_exp; @@ -216,7 +217,11 @@ static void OPB_SetIntType (OPT_Node node) static void OPB_SetSetType (OPT_Node node) { INT32 i32; - __GET((ADDRESS)&node->conval->setval + 4, i32, INT32); + if (Platform_LittleEndian) { + __GET((ADDRESS)&node->conval->setval + 4, i32, INT32); + } else { + __GET((ADDRESS)&node->conval->setval, i32, INT32); + } if (i32 == 0) { node->typ = OPT_set32typ; } else { @@ -2584,6 +2589,7 @@ export void *OPB__init(void) __MODULE_IMPORT(OPM); __MODULE_IMPORT(OPS); __MODULE_IMPORT(OPT); + __MODULE_IMPORT(Platform); __REGMOD("OPB", 0); /* BEGIN */ OPB_maxExp = OPB_log(4611686018427387904LL); diff --git a/bootstrap/unix-44/OPB.h b/bootstrap/unix-44/OPB.h index 0872ee74..bc2cc5d8 100644 --- a/bootstrap/unix-44/OPB.h +++ b/bootstrap/unix-44/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-44/OPC.c b/bootstrap/unix-44/OPC.c index 061511af..cb155ecb 100644 --- a/bootstrap/unix-44/OPC.c +++ b/bootstrap/unix-44/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPC.h b/bootstrap/unix-44/OPC.h index 5642d227..34544d76 100644 --- a/bootstrap/unix-44/OPC.h +++ b/bootstrap/unix-44/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-44/OPM.c b/bootstrap/unix-44/OPM.c index 0ad16dc2..2736a880 100644 --- a/bootstrap/unix-44/OPM.c +++ b/bootstrap/unix-44/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -206,12 +206,24 @@ INT64 OPM_SignedMinimum (INT32 bytecount) INT32 OPM_Longint (INT64 n) { - return __VAL(INT32, n); + INT32 r; + if (!Platform_LittleEndian) { + __GET((ADDRESS)&n + 4, r, INT32); + } else { + __GET((ADDRESS)&n, r, INT32); + } + return r; } INT16 OPM_Integer (INT64 n) { - return __VAL(INT16, n); + INT16 r; + if (!Platform_LittleEndian) { + __GET((ADDRESS)&n + 6, r, INT16); + } else { + __GET((ADDRESS)&n, r, INT16); + } + return r; } static void OPM_ScanOptions (CHAR *s, ADDRESS s__len) diff --git a/bootstrap/unix-44/OPM.h b/bootstrap/unix-44/OPM.h index f6ffb505..2d1b3434 100644 --- a/bootstrap/unix-44/OPM.h +++ b/bootstrap/unix-44/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-44/OPP.c b/bootstrap/unix-44/OPP.c index 73f219fe..84429ea8 100644 --- a/bootstrap/unix-44/OPP.c +++ b/bootstrap/unix-44/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPP.h b/bootstrap/unix-44/OPP.h index 8d5b805a..5d9d5e47 100644 --- a/bootstrap/unix-44/OPP.h +++ b/bootstrap/unix-44/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-44/OPS.c b/bootstrap/unix-44/OPS.c index 30e0c23a..66aa52f6 100644 --- a/bootstrap/unix-44/OPS.c +++ b/bootstrap/unix-44/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPS.h b/bootstrap/unix-44/OPS.h index 23609a77..d2acd451 100644 --- a/bootstrap/unix-44/OPS.h +++ b/bootstrap/unix-44/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-44/OPT.c b/bootstrap/unix-44/OPT.c index cd5fcdc8..0c717d86 100644 --- a/bootstrap/unix-44/OPT.c +++ b/bootstrap/unix-44/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPT.h b/bootstrap/unix-44/OPT.h index ae1b41ca..131fac37 100644 --- a/bootstrap/unix-44/OPT.h +++ b/bootstrap/unix-44/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-44/OPV.c b/bootstrap/unix-44/OPV.c index fe8d0057..1f220831 100644 --- a/bootstrap/unix-44/OPV.c +++ b/bootstrap/unix-44/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/OPV.h b/bootstrap/unix-44/OPV.h index 259d2274..85d2c9c4 100644 --- a/bootstrap/unix-44/OPV.h +++ b/bootstrap/unix-44/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-44/Out.c b/bootstrap/unix-44/Out.c index a58df1bd..3e4cf629 100644 --- a/bootstrap/unix-44/Out.c +++ b/bootstrap/unix-44/Out.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Out.h b/bootstrap/unix-44/Out.h index da4c375e..2e4d3247 100644 --- a/bootstrap/unix-44/Out.h +++ b/bootstrap/unix-44/Out.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/unix-44/Platform.c b/bootstrap/unix-44/Platform.c index 031b76f2..3a70c716 100644 --- a/bootstrap/unix-44/Platform.c +++ b/bootstrap/unix-44/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Platform.h b/bootstrap/unix-44/Platform.h index d05e1a4b..8d5dec41 100644 --- a/bootstrap/unix-44/Platform.h +++ b/bootstrap/unix-44/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-44/Reals.c b/bootstrap/unix-44/Reals.c index 17e02efc..d316e1ba 100644 --- a/bootstrap/unix-44/Reals.c +++ b/bootstrap/unix-44/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -6,8 +6,10 @@ #define SET UINT32 #include "SYSTEM.h" +#include "Platform.h" +static INT16 Reals_realExpHi, Reals_realExpLo, Reals_lrealExpHi, Reals_lrealExpLo; static void Reals_BytesToHex (SYSTEM_BYTE *b, ADDRESS b__len, SYSTEM_BYTE *d, ADDRESS d__len); @@ -17,7 +19,9 @@ export void Reals_ConvertHL (LONGREAL x, CHAR *d, ADDRESS d__len); export void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len); export INT16 Reals_Expo (REAL x); export INT16 Reals_ExpoL (LONGREAL x); +static void Reals_InitEndian (void); export void Reals_SetExpo (REAL *x, INT16 ex); +export void Reals_SetExpoL (LONGREAL *x, INT16 ex); export REAL Reals_Ten (INT16 e); export LONGREAL Reals_TenL (INT16 e); static CHAR Reals_ToHex (INT16 i); @@ -58,25 +62,36 @@ LONGREAL Reals_TenL (INT16 e) INT16 Reals_Expo (REAL x) { - INT16 i; - __GET((ADDRESS)&x + 2, i, INT16); - return __MASK(__ASHR(i, 7), -256); + CHAR hi, lo; + __GET((ADDRESS)&x + Reals_realExpHi, hi, CHAR); + __GET((ADDRESS)&x + Reals_realExpLo, lo, CHAR); + return __MASK(__ASHL((INT16)hi, 1) + __ASHR((INT16)lo, 7), -256); } void Reals_SetExpo (REAL *x, INT16 ex) { CHAR c; - __GET((ADDRESS)x + 3, c, CHAR); - __PUT((ADDRESS)x + 3, __CHR(__ASHL(__ASHR((INT16)c, 7), 7) + __MASK(__ASHR(ex, 1), -128)), CHAR); - __GET((ADDRESS)x + 2, c, CHAR); - __PUT((ADDRESS)x + 2, __CHR(__MASK((INT16)c, -128) + __ASHL(__MASK(ex, -2), 7)), CHAR); + __GET((ADDRESS)x + Reals_realExpHi, c, CHAR); + __PUT((ADDRESS)x + Reals_realExpHi, __CHR(__ASHL(__ASHR((INT16)c, 7), 7) + __MASK(__ASHR(ex, 1), -128)), CHAR); + __GET((ADDRESS)x + Reals_realExpLo, c, CHAR); + __PUT((ADDRESS)x + Reals_realExpLo, __CHR(__MASK((INT16)c, -128) + __ASHL(__MASK(ex, -2), 7)), CHAR); } INT16 Reals_ExpoL (LONGREAL x) { - INT16 i; - __GET((ADDRESS)&x + 6, i, INT16); - return __MASK(__ASHR(i, 4), -2048); + CHAR hi, lo; + __GET((ADDRESS)&x + Reals_lrealExpHi, hi, CHAR); + __GET((ADDRESS)&x + Reals_lrealExpLo, lo, CHAR); + return __MASK(__ASHL((INT16)hi, 4) + __ASHR((INT16)lo, 4), -2048); +} + +void Reals_SetExpoL (LONGREAL *x, INT16 ex) +{ + CHAR c; + __GET((ADDRESS)x + Reals_lrealExpHi, c, CHAR); + __PUT((ADDRESS)x + Reals_lrealExpHi, __CHR(__ASHL(__ASHR((INT16)c, 7), 7) + __MASK(__ASHR(ex, 4), -128)), CHAR); + __GET((ADDRESS)x + Reals_lrealExpLo, c, CHAR); + __PUT((ADDRESS)x + Reals_lrealExpLo, __CHR(__ASHL(__MASK(ex, -16), 4) + __MASK((INT16)c, -16)), CHAR); } void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len) @@ -124,16 +139,25 @@ static CHAR Reals_ToHex (INT16 i) static void Reals_BytesToHex (SYSTEM_BYTE *b, ADDRESS b__len, SYSTEM_BYTE *d, ADDRESS d__len) { - INT16 i; - INT32 l; + INT16 i, j, len; CHAR by; - i = 0; - l = b__len; - while (i < l) { + len = __SHORT(b__len, 32768); + if (Platform_LittleEndian) { + i = 0; + } else { + i = len - 1; + } + j = 0; + while ((i >= 0 && i < len)) { by = __VAL(CHAR, b[__X(i, b__len)]); - d[__X(__ASHL(i, 1), d__len)] = Reals_ToHex(__ASHR((INT16)by, 4)); - d[__X(__ASHL(i, 1) + 1, d__len)] = Reals_ToHex(__MASK((INT16)by, -16)); - i += 1; + d[__X(__ASHL(j, 1), d__len)] = Reals_ToHex(__ASHR((INT16)by, 4)); + d[__X(__ASHL(j, 1) + 1, d__len)] = Reals_ToHex(__MASK((INT16)by, -16)); + j += 1; + if (Platform_LittleEndian) { + i += 1; + } else { + i -= 1; + } } } @@ -147,11 +171,28 @@ void Reals_ConvertHL (LONGREAL x, CHAR *d, ADDRESS d__len) Reals_BytesToHex((void*)&x, 8, (void*)d, d__len * 1); } +static void Reals_InitEndian (void) +{ + if (Platform_LittleEndian) { + Reals_realExpHi = 3; + Reals_realExpLo = 2; + Reals_lrealExpHi = 7; + Reals_lrealExpLo = 6; + } else { + Reals_realExpHi = 0; + Reals_realExpLo = 1; + Reals_lrealExpHi = 0; + Reals_lrealExpLo = 1; + } +} + export void *Reals__init(void) { __DEFMOD; + __MODULE_IMPORT(Platform); __REGMOD("Reals", 0); /* BEGIN */ + Reals_InitEndian(); __ENDMOD; } diff --git a/bootstrap/unix-44/Reals.h b/bootstrap/unix-44/Reals.h index 72cdeac9..dc156476 100644 --- a/bootstrap/unix-44/Reals.h +++ b/bootstrap/unix-44/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Reals__h #define Reals__h @@ -15,6 +15,7 @@ import void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len); import INT16 Reals_Expo (REAL x); import INT16 Reals_ExpoL (LONGREAL x); import void Reals_SetExpo (REAL *x, INT16 ex); +import void Reals_SetExpoL (LONGREAL *x, INT16 ex); import REAL Reals_Ten (INT16 e); import LONGREAL Reals_TenL (INT16 e); import void *Reals__init(void); diff --git a/bootstrap/unix-44/Strings.c b/bootstrap/unix-44/Strings.c index 33402210..89734392 100644 --- a/bootstrap/unix-44/Strings.c +++ b/bootstrap/unix-44/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Strings.h b/bootstrap/unix-44/Strings.h index 94c330de..e15d3f0a 100644 --- a/bootstrap/unix-44/Strings.h +++ b/bootstrap/unix-44/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-44/Texts.c b/bootstrap/unix-44/Texts.c index 54ead86f..0f40e2a8 100644 --- a/bootstrap/unix-44/Texts.c +++ b/bootstrap/unix-44/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/Texts.h b/bootstrap/unix-44/Texts.h index beb22949..5cb65b28 100644 --- a/bootstrap/unix-44/Texts.h +++ b/bootstrap/unix-44/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-44/VT100.c b/bootstrap/unix-44/VT100.c index 2dbabfac..edb28fa4 100644 --- a/bootstrap/unix-44/VT100.c +++ b/bootstrap/unix-44/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/VT100.h b/bootstrap/unix-44/VT100.h index d93196f4..536d7d6f 100644 --- a/bootstrap/unix-44/VT100.h +++ b/bootstrap/unix-44/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/unix-44/extTools.c b/bootstrap/unix-44/extTools.c index b927caed..04925dbb 100644 --- a/bootstrap/unix-44/extTools.c +++ b/bootstrap/unix-44/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-44/extTools.h b/bootstrap/unix-44/extTools.h index 7b30a000..0297454c 100644 --- a/bootstrap/unix-44/extTools.h +++ b/bootstrap/unix-44/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-48/Compiler.c b/bootstrap/unix-48/Compiler.c index 5fb197fa..bb8b6f66 100644 --- a/bootstrap/unix-48/Compiler.c +++ b/bootstrap/unix-48/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Configuration.c b/bootstrap/unix-48/Configuration.c index 28930ae6..ffabe11c 100644 --- a/bootstrap/unix-48/Configuration.c +++ b/bootstrap/unix-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); + __MOVE("2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); __ENDMOD; } diff --git a/bootstrap/unix-48/Configuration.h b/bootstrap/unix-48/Configuration.h index 06b2322e..4da616f3 100644 --- a/bootstrap/unix-48/Configuration.h +++ b/bootstrap/unix-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-48/Files.c b/bootstrap/unix-48/Files.c index ba5910fd..de296e47 100644 --- a/bootstrap/unix-48/Files.c +++ b/bootstrap/unix-48/Files.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -942,7 +942,11 @@ void Files_ReadNum (Files_Rider *R, ADDRESS *R__typ, SYSTEM_BYTE *x, ADDRESS x__ } q += (INT64)__ASH((__MASK(b, -64) - __ASHL(__ASHR(b, 6), 6)), s); Files_Assert(x__len <= 8); - __MOVE((ADDRESS)&q, (ADDRESS)x, x__len); + if (Platform_LittleEndian) { + __MOVE((ADDRESS)&q, (ADDRESS)x, x__len); + } else { + __MOVE(((ADDRESS)&q + 8) - (__SHORT(x__len, 32768)), (ADDRESS)x, x__len); + } } void Files_WriteBool (Files_Rider *R, ADDRESS *R__typ, BOOLEAN x) @@ -972,9 +976,7 @@ void Files_WriteSet (Files_Rider *R, ADDRESS *R__typ, UINT32 x) { CHAR b[4]; INT32 i; - UINT64 y; - y = x; - i = __VAL(INT32, y); + i = (INT32)x; b[0] = __CHR(i); b[1] = __CHR(__ASHR(i, 8)); b[2] = __CHR(__ASHR(i, 16)); diff --git a/bootstrap/unix-48/Files.h b/bootstrap/unix-48/Files.h index 8966b74a..c7037d93 100644 --- a/bootstrap/unix-48/Files.h +++ b/bootstrap/unix-48/Files.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-48/Heap.c b/bootstrap/unix-48/Heap.c index d00d1bec..3394b9ca 100644 --- a/bootstrap/unix-48/Heap.c +++ b/bootstrap/unix-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Heap.h b/bootstrap/unix-48/Heap.h index 3064651b..0b2056a8 100644 --- a/bootstrap/unix-48/Heap.h +++ b/bootstrap/unix-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-48/Modules.c b/bootstrap/unix-48/Modules.c index 0612b10d..d3df5c25 100644 --- a/bootstrap/unix-48/Modules.c +++ b/bootstrap/unix-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -52,7 +52,7 @@ extern void *Modules__init(void); void Modules_Init (INT32 argc, INT32 argvadr) { Modules_MainStackFrame = argvadr; - Modules_ArgCount = __VAL(INT16, argc); + Modules_ArgCount = __SHORT(argc, 32768); __GET(argvadr, Modules_ArgVector, INT32); Modules_InitHeap(); Modules_ModulesInit(); diff --git a/bootstrap/unix-48/Modules.h b/bootstrap/unix-48/Modules.h index 23f2dd74..f18e2955 100644 --- a/bootstrap/unix-48/Modules.h +++ b/bootstrap/unix-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/unix-48/OPB.c b/bootstrap/unix-48/OPB.c index 5a53405b..4db48170 100644 --- a/bootstrap/unix-48/OPB.c +++ b/bootstrap/unix-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -9,6 +9,7 @@ #include "OPM.h" #include "OPS.h" #include "OPT.h" +#include "Platform.h" static INT16 OPB_exp; @@ -216,7 +217,11 @@ static void OPB_SetIntType (OPT_Node node) static void OPB_SetSetType (OPT_Node node) { INT32 i32; - __GET((ADDRESS)&node->conval->setval + 4, i32, INT32); + if (Platform_LittleEndian) { + __GET((ADDRESS)&node->conval->setval + 4, i32, INT32); + } else { + __GET((ADDRESS)&node->conval->setval, i32, INT32); + } if (i32 == 0) { node->typ = OPT_set32typ; } else { @@ -2584,6 +2589,7 @@ export void *OPB__init(void) __MODULE_IMPORT(OPM); __MODULE_IMPORT(OPS); __MODULE_IMPORT(OPT); + __MODULE_IMPORT(Platform); __REGMOD("OPB", 0); /* BEGIN */ OPB_maxExp = OPB_log(4611686018427387904LL); diff --git a/bootstrap/unix-48/OPB.h b/bootstrap/unix-48/OPB.h index 0872ee74..bc2cc5d8 100644 --- a/bootstrap/unix-48/OPB.h +++ b/bootstrap/unix-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-48/OPC.c b/bootstrap/unix-48/OPC.c index 061511af..cb155ecb 100644 --- a/bootstrap/unix-48/OPC.c +++ b/bootstrap/unix-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPC.h b/bootstrap/unix-48/OPC.h index 5642d227..34544d76 100644 --- a/bootstrap/unix-48/OPC.h +++ b/bootstrap/unix-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-48/OPM.c b/bootstrap/unix-48/OPM.c index 0ad16dc2..2736a880 100644 --- a/bootstrap/unix-48/OPM.c +++ b/bootstrap/unix-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -206,12 +206,24 @@ INT64 OPM_SignedMinimum (INT32 bytecount) INT32 OPM_Longint (INT64 n) { - return __VAL(INT32, n); + INT32 r; + if (!Platform_LittleEndian) { + __GET((ADDRESS)&n + 4, r, INT32); + } else { + __GET((ADDRESS)&n, r, INT32); + } + return r; } INT16 OPM_Integer (INT64 n) { - return __VAL(INT16, n); + INT16 r; + if (!Platform_LittleEndian) { + __GET((ADDRESS)&n + 6, r, INT16); + } else { + __GET((ADDRESS)&n, r, INT16); + } + return r; } static void OPM_ScanOptions (CHAR *s, ADDRESS s__len) diff --git a/bootstrap/unix-48/OPM.h b/bootstrap/unix-48/OPM.h index f6ffb505..2d1b3434 100644 --- a/bootstrap/unix-48/OPM.h +++ b/bootstrap/unix-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-48/OPP.c b/bootstrap/unix-48/OPP.c index 73f219fe..84429ea8 100644 --- a/bootstrap/unix-48/OPP.c +++ b/bootstrap/unix-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPP.h b/bootstrap/unix-48/OPP.h index 8d5b805a..5d9d5e47 100644 --- a/bootstrap/unix-48/OPP.h +++ b/bootstrap/unix-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-48/OPS.c b/bootstrap/unix-48/OPS.c index 30e0c23a..66aa52f6 100644 --- a/bootstrap/unix-48/OPS.c +++ b/bootstrap/unix-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPS.h b/bootstrap/unix-48/OPS.h index 23609a77..d2acd451 100644 --- a/bootstrap/unix-48/OPS.h +++ b/bootstrap/unix-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-48/OPT.c b/bootstrap/unix-48/OPT.c index 73f8eef3..ef2702ef 100644 --- a/bootstrap/unix-48/OPT.c +++ b/bootstrap/unix-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPT.h b/bootstrap/unix-48/OPT.h index ae1b41ca..131fac37 100644 --- a/bootstrap/unix-48/OPT.h +++ b/bootstrap/unix-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-48/OPV.c b/bootstrap/unix-48/OPV.c index fe8d0057..1f220831 100644 --- a/bootstrap/unix-48/OPV.c +++ b/bootstrap/unix-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/OPV.h b/bootstrap/unix-48/OPV.h index 259d2274..85d2c9c4 100644 --- a/bootstrap/unix-48/OPV.h +++ b/bootstrap/unix-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-48/Out.c b/bootstrap/unix-48/Out.c index a58df1bd..3e4cf629 100644 --- a/bootstrap/unix-48/Out.c +++ b/bootstrap/unix-48/Out.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Out.h b/bootstrap/unix-48/Out.h index da4c375e..2e4d3247 100644 --- a/bootstrap/unix-48/Out.h +++ b/bootstrap/unix-48/Out.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/unix-48/Platform.c b/bootstrap/unix-48/Platform.c index 031b76f2..3a70c716 100644 --- a/bootstrap/unix-48/Platform.c +++ b/bootstrap/unix-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Platform.h b/bootstrap/unix-48/Platform.h index d05e1a4b..8d5dec41 100644 --- a/bootstrap/unix-48/Platform.h +++ b/bootstrap/unix-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-48/Reals.c b/bootstrap/unix-48/Reals.c index 17e02efc..d316e1ba 100644 --- a/bootstrap/unix-48/Reals.c +++ b/bootstrap/unix-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -6,8 +6,10 @@ #define SET UINT32 #include "SYSTEM.h" +#include "Platform.h" +static INT16 Reals_realExpHi, Reals_realExpLo, Reals_lrealExpHi, Reals_lrealExpLo; static void Reals_BytesToHex (SYSTEM_BYTE *b, ADDRESS b__len, SYSTEM_BYTE *d, ADDRESS d__len); @@ -17,7 +19,9 @@ export void Reals_ConvertHL (LONGREAL x, CHAR *d, ADDRESS d__len); export void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len); export INT16 Reals_Expo (REAL x); export INT16 Reals_ExpoL (LONGREAL x); +static void Reals_InitEndian (void); export void Reals_SetExpo (REAL *x, INT16 ex); +export void Reals_SetExpoL (LONGREAL *x, INT16 ex); export REAL Reals_Ten (INT16 e); export LONGREAL Reals_TenL (INT16 e); static CHAR Reals_ToHex (INT16 i); @@ -58,25 +62,36 @@ LONGREAL Reals_TenL (INT16 e) INT16 Reals_Expo (REAL x) { - INT16 i; - __GET((ADDRESS)&x + 2, i, INT16); - return __MASK(__ASHR(i, 7), -256); + CHAR hi, lo; + __GET((ADDRESS)&x + Reals_realExpHi, hi, CHAR); + __GET((ADDRESS)&x + Reals_realExpLo, lo, CHAR); + return __MASK(__ASHL((INT16)hi, 1) + __ASHR((INT16)lo, 7), -256); } void Reals_SetExpo (REAL *x, INT16 ex) { CHAR c; - __GET((ADDRESS)x + 3, c, CHAR); - __PUT((ADDRESS)x + 3, __CHR(__ASHL(__ASHR((INT16)c, 7), 7) + __MASK(__ASHR(ex, 1), -128)), CHAR); - __GET((ADDRESS)x + 2, c, CHAR); - __PUT((ADDRESS)x + 2, __CHR(__MASK((INT16)c, -128) + __ASHL(__MASK(ex, -2), 7)), CHAR); + __GET((ADDRESS)x + Reals_realExpHi, c, CHAR); + __PUT((ADDRESS)x + Reals_realExpHi, __CHR(__ASHL(__ASHR((INT16)c, 7), 7) + __MASK(__ASHR(ex, 1), -128)), CHAR); + __GET((ADDRESS)x + Reals_realExpLo, c, CHAR); + __PUT((ADDRESS)x + Reals_realExpLo, __CHR(__MASK((INT16)c, -128) + __ASHL(__MASK(ex, -2), 7)), CHAR); } INT16 Reals_ExpoL (LONGREAL x) { - INT16 i; - __GET((ADDRESS)&x + 6, i, INT16); - return __MASK(__ASHR(i, 4), -2048); + CHAR hi, lo; + __GET((ADDRESS)&x + Reals_lrealExpHi, hi, CHAR); + __GET((ADDRESS)&x + Reals_lrealExpLo, lo, CHAR); + return __MASK(__ASHL((INT16)hi, 4) + __ASHR((INT16)lo, 4), -2048); +} + +void Reals_SetExpoL (LONGREAL *x, INT16 ex) +{ + CHAR c; + __GET((ADDRESS)x + Reals_lrealExpHi, c, CHAR); + __PUT((ADDRESS)x + Reals_lrealExpHi, __CHR(__ASHL(__ASHR((INT16)c, 7), 7) + __MASK(__ASHR(ex, 4), -128)), CHAR); + __GET((ADDRESS)x + Reals_lrealExpLo, c, CHAR); + __PUT((ADDRESS)x + Reals_lrealExpLo, __CHR(__ASHL(__MASK(ex, -16), 4) + __MASK((INT16)c, -16)), CHAR); } void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len) @@ -124,16 +139,25 @@ static CHAR Reals_ToHex (INT16 i) static void Reals_BytesToHex (SYSTEM_BYTE *b, ADDRESS b__len, SYSTEM_BYTE *d, ADDRESS d__len) { - INT16 i; - INT32 l; + INT16 i, j, len; CHAR by; - i = 0; - l = b__len; - while (i < l) { + len = __SHORT(b__len, 32768); + if (Platform_LittleEndian) { + i = 0; + } else { + i = len - 1; + } + j = 0; + while ((i >= 0 && i < len)) { by = __VAL(CHAR, b[__X(i, b__len)]); - d[__X(__ASHL(i, 1), d__len)] = Reals_ToHex(__ASHR((INT16)by, 4)); - d[__X(__ASHL(i, 1) + 1, d__len)] = Reals_ToHex(__MASK((INT16)by, -16)); - i += 1; + d[__X(__ASHL(j, 1), d__len)] = Reals_ToHex(__ASHR((INT16)by, 4)); + d[__X(__ASHL(j, 1) + 1, d__len)] = Reals_ToHex(__MASK((INT16)by, -16)); + j += 1; + if (Platform_LittleEndian) { + i += 1; + } else { + i -= 1; + } } } @@ -147,11 +171,28 @@ void Reals_ConvertHL (LONGREAL x, CHAR *d, ADDRESS d__len) Reals_BytesToHex((void*)&x, 8, (void*)d, d__len * 1); } +static void Reals_InitEndian (void) +{ + if (Platform_LittleEndian) { + Reals_realExpHi = 3; + Reals_realExpLo = 2; + Reals_lrealExpHi = 7; + Reals_lrealExpLo = 6; + } else { + Reals_realExpHi = 0; + Reals_realExpLo = 1; + Reals_lrealExpHi = 0; + Reals_lrealExpLo = 1; + } +} + export void *Reals__init(void) { __DEFMOD; + __MODULE_IMPORT(Platform); __REGMOD("Reals", 0); /* BEGIN */ + Reals_InitEndian(); __ENDMOD; } diff --git a/bootstrap/unix-48/Reals.h b/bootstrap/unix-48/Reals.h index 72cdeac9..dc156476 100644 --- a/bootstrap/unix-48/Reals.h +++ b/bootstrap/unix-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Reals__h #define Reals__h @@ -15,6 +15,7 @@ import void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len); import INT16 Reals_Expo (REAL x); import INT16 Reals_ExpoL (LONGREAL x); import void Reals_SetExpo (REAL *x, INT16 ex); +import void Reals_SetExpoL (LONGREAL *x, INT16 ex); import REAL Reals_Ten (INT16 e); import LONGREAL Reals_TenL (INT16 e); import void *Reals__init(void); diff --git a/bootstrap/unix-48/Strings.c b/bootstrap/unix-48/Strings.c index 33402210..89734392 100644 --- a/bootstrap/unix-48/Strings.c +++ b/bootstrap/unix-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Strings.h b/bootstrap/unix-48/Strings.h index 94c330de..e15d3f0a 100644 --- a/bootstrap/unix-48/Strings.h +++ b/bootstrap/unix-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-48/Texts.c b/bootstrap/unix-48/Texts.c index 322ce28b..ecda3377 100644 --- a/bootstrap/unix-48/Texts.c +++ b/bootstrap/unix-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/Texts.h b/bootstrap/unix-48/Texts.h index d1d92b87..cc2fb2d7 100644 --- a/bootstrap/unix-48/Texts.h +++ b/bootstrap/unix-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-48/VT100.c b/bootstrap/unix-48/VT100.c index 2dbabfac..edb28fa4 100644 --- a/bootstrap/unix-48/VT100.c +++ b/bootstrap/unix-48/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/VT100.h b/bootstrap/unix-48/VT100.h index d93196f4..536d7d6f 100644 --- a/bootstrap/unix-48/VT100.h +++ b/bootstrap/unix-48/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/unix-48/extTools.c b/bootstrap/unix-48/extTools.c index b927caed..04925dbb 100644 --- a/bootstrap/unix-48/extTools.c +++ b/bootstrap/unix-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-48/extTools.h b/bootstrap/unix-48/extTools.h index 7b30a000..0297454c 100644 --- a/bootstrap/unix-48/extTools.h +++ b/bootstrap/unix-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/unix-88/Compiler.c b/bootstrap/unix-88/Compiler.c index 5fb197fa..bb8b6f66 100644 --- a/bootstrap/unix-88/Compiler.c +++ b/bootstrap/unix-88/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Configuration.c b/bootstrap/unix-88/Configuration.c index 28930ae6..ffabe11c 100644 --- a/bootstrap/unix-88/Configuration.c +++ b/bootstrap/unix-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); + __MOVE("2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); __ENDMOD; } diff --git a/bootstrap/unix-88/Configuration.h b/bootstrap/unix-88/Configuration.h index 06b2322e..4da616f3 100644 --- a/bootstrap/unix-88/Configuration.h +++ b/bootstrap/unix-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/unix-88/Files.c b/bootstrap/unix-88/Files.c index 4cec8d13..b1d8df68 100644 --- a/bootstrap/unix-88/Files.c +++ b/bootstrap/unix-88/Files.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -942,7 +942,11 @@ void Files_ReadNum (Files_Rider *R, ADDRESS *R__typ, SYSTEM_BYTE *x, ADDRESS x__ } q += (INT64)__ASH((__MASK(b, -64) - __ASHL(__ASHR(b, 6), 6)), s); Files_Assert(x__len <= 8); - __MOVE((ADDRESS)&q, (ADDRESS)x, x__len); + if (Platform_LittleEndian) { + __MOVE((ADDRESS)&q, (ADDRESS)x, x__len); + } else { + __MOVE(((ADDRESS)&q + 8) - (INT64)(__SHORT(x__len, 32768)), (ADDRESS)x, x__len); + } } void Files_WriteBool (Files_Rider *R, ADDRESS *R__typ, BOOLEAN x) @@ -972,9 +976,7 @@ void Files_WriteSet (Files_Rider *R, ADDRESS *R__typ, UINT32 x) { CHAR b[4]; INT32 i; - UINT64 y; - y = x; - i = __VAL(INT32, y); + i = (INT32)x; b[0] = __CHR(i); b[1] = __CHR(__ASHR(i, 8)); b[2] = __CHR(__ASHR(i, 16)); diff --git a/bootstrap/unix-88/Files.h b/bootstrap/unix-88/Files.h index 9d0b8b12..8abfe1bd 100644 --- a/bootstrap/unix-88/Files.h +++ b/bootstrap/unix-88/Files.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/unix-88/Heap.c b/bootstrap/unix-88/Heap.c index 15a6e3b6..1513c9b1 100644 --- a/bootstrap/unix-88/Heap.c +++ b/bootstrap/unix-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Heap.h b/bootstrap/unix-88/Heap.h index ec34eede..782a3a52 100644 --- a/bootstrap/unix-88/Heap.h +++ b/bootstrap/unix-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/unix-88/Modules.c b/bootstrap/unix-88/Modules.c index 32b7cccc..4a99f51f 100644 --- a/bootstrap/unix-88/Modules.c +++ b/bootstrap/unix-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -52,7 +52,7 @@ extern void *Modules__init(void); void Modules_Init (INT32 argc, INT64 argvadr) { Modules_MainStackFrame = argvadr; - Modules_ArgCount = __VAL(INT16, argc); + Modules_ArgCount = __SHORT(argc, 32768); __GET(argvadr, Modules_ArgVector, INT64); Modules_InitHeap(); Modules_ModulesInit(); diff --git a/bootstrap/unix-88/Modules.h b/bootstrap/unix-88/Modules.h index 8a333379..f559ace4 100644 --- a/bootstrap/unix-88/Modules.h +++ b/bootstrap/unix-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/unix-88/OPB.c b/bootstrap/unix-88/OPB.c index 5a53405b..4db48170 100644 --- a/bootstrap/unix-88/OPB.c +++ b/bootstrap/unix-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -9,6 +9,7 @@ #include "OPM.h" #include "OPS.h" #include "OPT.h" +#include "Platform.h" static INT16 OPB_exp; @@ -216,7 +217,11 @@ static void OPB_SetIntType (OPT_Node node) static void OPB_SetSetType (OPT_Node node) { INT32 i32; - __GET((ADDRESS)&node->conval->setval + 4, i32, INT32); + if (Platform_LittleEndian) { + __GET((ADDRESS)&node->conval->setval + 4, i32, INT32); + } else { + __GET((ADDRESS)&node->conval->setval, i32, INT32); + } if (i32 == 0) { node->typ = OPT_set32typ; } else { @@ -2584,6 +2589,7 @@ export void *OPB__init(void) __MODULE_IMPORT(OPM); __MODULE_IMPORT(OPS); __MODULE_IMPORT(OPT); + __MODULE_IMPORT(Platform); __REGMOD("OPB", 0); /* BEGIN */ OPB_maxExp = OPB_log(4611686018427387904LL); diff --git a/bootstrap/unix-88/OPB.h b/bootstrap/unix-88/OPB.h index 0872ee74..bc2cc5d8 100644 --- a/bootstrap/unix-88/OPB.h +++ b/bootstrap/unix-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/unix-88/OPC.c b/bootstrap/unix-88/OPC.c index 061511af..cb155ecb 100644 --- a/bootstrap/unix-88/OPC.c +++ b/bootstrap/unix-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPC.h b/bootstrap/unix-88/OPC.h index 5642d227..34544d76 100644 --- a/bootstrap/unix-88/OPC.h +++ b/bootstrap/unix-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/unix-88/OPM.c b/bootstrap/unix-88/OPM.c index 6f26cfe8..6f18df61 100644 --- a/bootstrap/unix-88/OPM.c +++ b/bootstrap/unix-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -206,12 +206,24 @@ INT64 OPM_SignedMinimum (INT32 bytecount) INT32 OPM_Longint (INT64 n) { - return __VAL(INT32, n); + INT32 r; + if (!Platform_LittleEndian) { + __GET((ADDRESS)&n + 4, r, INT32); + } else { + __GET((ADDRESS)&n, r, INT32); + } + return r; } INT16 OPM_Integer (INT64 n) { - return __VAL(INT16, n); + INT16 r; + if (!Platform_LittleEndian) { + __GET((ADDRESS)&n + 6, r, INT16); + } else { + __GET((ADDRESS)&n, r, INT16); + } + return r; } static void OPM_ScanOptions (CHAR *s, ADDRESS s__len) diff --git a/bootstrap/unix-88/OPM.h b/bootstrap/unix-88/OPM.h index f6ffb505..2d1b3434 100644 --- a/bootstrap/unix-88/OPM.h +++ b/bootstrap/unix-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/unix-88/OPP.c b/bootstrap/unix-88/OPP.c index b4f5f6bb..0629ae67 100644 --- a/bootstrap/unix-88/OPP.c +++ b/bootstrap/unix-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPP.h b/bootstrap/unix-88/OPP.h index 8d5b805a..5d9d5e47 100644 --- a/bootstrap/unix-88/OPP.h +++ b/bootstrap/unix-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/unix-88/OPS.c b/bootstrap/unix-88/OPS.c index 30e0c23a..66aa52f6 100644 --- a/bootstrap/unix-88/OPS.c +++ b/bootstrap/unix-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPS.h b/bootstrap/unix-88/OPS.h index 23609a77..d2acd451 100644 --- a/bootstrap/unix-88/OPS.h +++ b/bootstrap/unix-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/unix-88/OPT.c b/bootstrap/unix-88/OPT.c index 53898c63..7b562383 100644 --- a/bootstrap/unix-88/OPT.c +++ b/bootstrap/unix-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPT.h b/bootstrap/unix-88/OPT.h index ae1b41ca..131fac37 100644 --- a/bootstrap/unix-88/OPT.h +++ b/bootstrap/unix-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/unix-88/OPV.c b/bootstrap/unix-88/OPV.c index 82ed398e..86061443 100644 --- a/bootstrap/unix-88/OPV.c +++ b/bootstrap/unix-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/OPV.h b/bootstrap/unix-88/OPV.h index 259d2274..85d2c9c4 100644 --- a/bootstrap/unix-88/OPV.h +++ b/bootstrap/unix-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/unix-88/Out.c b/bootstrap/unix-88/Out.c index a58df1bd..3e4cf629 100644 --- a/bootstrap/unix-88/Out.c +++ b/bootstrap/unix-88/Out.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Out.h b/bootstrap/unix-88/Out.h index da4c375e..2e4d3247 100644 --- a/bootstrap/unix-88/Out.h +++ b/bootstrap/unix-88/Out.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/unix-88/Platform.c b/bootstrap/unix-88/Platform.c index 7cac29f9..bbd79b73 100644 --- a/bootstrap/unix-88/Platform.c +++ b/bootstrap/unix-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Platform.h b/bootstrap/unix-88/Platform.h index 31339f8c..61db15eb 100644 --- a/bootstrap/unix-88/Platform.h +++ b/bootstrap/unix-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/unix-88/Reals.c b/bootstrap/unix-88/Reals.c index 17e02efc..cdfbd7ce 100644 --- a/bootstrap/unix-88/Reals.c +++ b/bootstrap/unix-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -6,8 +6,10 @@ #define SET UINT32 #include "SYSTEM.h" +#include "Platform.h" +static INT16 Reals_realExpHi, Reals_realExpLo, Reals_lrealExpHi, Reals_lrealExpLo; static void Reals_BytesToHex (SYSTEM_BYTE *b, ADDRESS b__len, SYSTEM_BYTE *d, ADDRESS d__len); @@ -17,7 +19,9 @@ export void Reals_ConvertHL (LONGREAL x, CHAR *d, ADDRESS d__len); export void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len); export INT16 Reals_Expo (REAL x); export INT16 Reals_ExpoL (LONGREAL x); +static void Reals_InitEndian (void); export void Reals_SetExpo (REAL *x, INT16 ex); +export void Reals_SetExpoL (LONGREAL *x, INT16 ex); export REAL Reals_Ten (INT16 e); export LONGREAL Reals_TenL (INT16 e); static CHAR Reals_ToHex (INT16 i); @@ -58,25 +62,36 @@ LONGREAL Reals_TenL (INT16 e) INT16 Reals_Expo (REAL x) { - INT16 i; - __GET((ADDRESS)&x + 2, i, INT16); - return __MASK(__ASHR(i, 7), -256); + CHAR hi, lo; + __GET((ADDRESS)&x + (INT64)Reals_realExpHi, hi, CHAR); + __GET((ADDRESS)&x + (INT64)Reals_realExpLo, lo, CHAR); + return __MASK(__ASHL((INT16)hi, 1) + __ASHR((INT16)lo, 7), -256); } void Reals_SetExpo (REAL *x, INT16 ex) { CHAR c; - __GET((ADDRESS)x + 3, c, CHAR); - __PUT((ADDRESS)x + 3, __CHR(__ASHL(__ASHR((INT16)c, 7), 7) + __MASK(__ASHR(ex, 1), -128)), CHAR); - __GET((ADDRESS)x + 2, c, CHAR); - __PUT((ADDRESS)x + 2, __CHR(__MASK((INT16)c, -128) + __ASHL(__MASK(ex, -2), 7)), CHAR); + __GET((ADDRESS)x + (INT64)Reals_realExpHi, c, CHAR); + __PUT((ADDRESS)x + (INT64)Reals_realExpHi, __CHR(__ASHL(__ASHR((INT16)c, 7), 7) + __MASK(__ASHR(ex, 1), -128)), CHAR); + __GET((ADDRESS)x + (INT64)Reals_realExpLo, c, CHAR); + __PUT((ADDRESS)x + (INT64)Reals_realExpLo, __CHR(__MASK((INT16)c, -128) + __ASHL(__MASK(ex, -2), 7)), CHAR); } INT16 Reals_ExpoL (LONGREAL x) { - INT16 i; - __GET((ADDRESS)&x + 6, i, INT16); - return __MASK(__ASHR(i, 4), -2048); + CHAR hi, lo; + __GET((ADDRESS)&x + (INT64)Reals_lrealExpHi, hi, CHAR); + __GET((ADDRESS)&x + (INT64)Reals_lrealExpLo, lo, CHAR); + return __MASK(__ASHL((INT16)hi, 4) + __ASHR((INT16)lo, 4), -2048); +} + +void Reals_SetExpoL (LONGREAL *x, INT16 ex) +{ + CHAR c; + __GET((ADDRESS)x + (INT64)Reals_lrealExpHi, c, CHAR); + __PUT((ADDRESS)x + (INT64)Reals_lrealExpHi, __CHR(__ASHL(__ASHR((INT16)c, 7), 7) + __MASK(__ASHR(ex, 4), -128)), CHAR); + __GET((ADDRESS)x + (INT64)Reals_lrealExpLo, c, CHAR); + __PUT((ADDRESS)x + (INT64)Reals_lrealExpLo, __CHR(__ASHL(__MASK(ex, -16), 4) + __MASK((INT16)c, -16)), CHAR); } void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len) @@ -124,16 +139,25 @@ static CHAR Reals_ToHex (INT16 i) static void Reals_BytesToHex (SYSTEM_BYTE *b, ADDRESS b__len, SYSTEM_BYTE *d, ADDRESS d__len) { - INT16 i; - INT32 l; + INT16 i, j, len; CHAR by; - i = 0; - l = b__len; - while (i < l) { + len = __SHORT(b__len, 32768); + if (Platform_LittleEndian) { + i = 0; + } else { + i = len - 1; + } + j = 0; + while ((i >= 0 && i < len)) { by = __VAL(CHAR, b[__X(i, b__len)]); - d[__X(__ASHL(i, 1), d__len)] = Reals_ToHex(__ASHR((INT16)by, 4)); - d[__X(__ASHL(i, 1) + 1, d__len)] = Reals_ToHex(__MASK((INT16)by, -16)); - i += 1; + d[__X(__ASHL(j, 1), d__len)] = Reals_ToHex(__ASHR((INT16)by, 4)); + d[__X(__ASHL(j, 1) + 1, d__len)] = Reals_ToHex(__MASK((INT16)by, -16)); + j += 1; + if (Platform_LittleEndian) { + i += 1; + } else { + i -= 1; + } } } @@ -147,11 +171,28 @@ void Reals_ConvertHL (LONGREAL x, CHAR *d, ADDRESS d__len) Reals_BytesToHex((void*)&x, 8, (void*)d, d__len * 1); } +static void Reals_InitEndian (void) +{ + if (Platform_LittleEndian) { + Reals_realExpHi = 3; + Reals_realExpLo = 2; + Reals_lrealExpHi = 7; + Reals_lrealExpLo = 6; + } else { + Reals_realExpHi = 0; + Reals_realExpLo = 1; + Reals_lrealExpHi = 0; + Reals_lrealExpLo = 1; + } +} + export void *Reals__init(void) { __DEFMOD; + __MODULE_IMPORT(Platform); __REGMOD("Reals", 0); /* BEGIN */ + Reals_InitEndian(); __ENDMOD; } diff --git a/bootstrap/unix-88/Reals.h b/bootstrap/unix-88/Reals.h index 72cdeac9..dc156476 100644 --- a/bootstrap/unix-88/Reals.h +++ b/bootstrap/unix-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Reals__h #define Reals__h @@ -15,6 +15,7 @@ import void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len); import INT16 Reals_Expo (REAL x); import INT16 Reals_ExpoL (LONGREAL x); import void Reals_SetExpo (REAL *x, INT16 ex); +import void Reals_SetExpoL (LONGREAL *x, INT16 ex); import REAL Reals_Ten (INT16 e); import LONGREAL Reals_TenL (INT16 e); import void *Reals__init(void); diff --git a/bootstrap/unix-88/Strings.c b/bootstrap/unix-88/Strings.c index 33402210..89734392 100644 --- a/bootstrap/unix-88/Strings.c +++ b/bootstrap/unix-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Strings.h b/bootstrap/unix-88/Strings.h index 94c330de..e15d3f0a 100644 --- a/bootstrap/unix-88/Strings.h +++ b/bootstrap/unix-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/unix-88/Texts.c b/bootstrap/unix-88/Texts.c index 667cd440..9378df02 100644 --- a/bootstrap/unix-88/Texts.c +++ b/bootstrap/unix-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/Texts.h b/bootstrap/unix-88/Texts.h index b39a4f55..9d0b3ec8 100644 --- a/bootstrap/unix-88/Texts.h +++ b/bootstrap/unix-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/unix-88/VT100.c b/bootstrap/unix-88/VT100.c index 2dbabfac..edb28fa4 100644 --- a/bootstrap/unix-88/VT100.c +++ b/bootstrap/unix-88/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/VT100.h b/bootstrap/unix-88/VT100.h index d93196f4..536d7d6f 100644 --- a/bootstrap/unix-88/VT100.h +++ b/bootstrap/unix-88/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/unix-88/extTools.c b/bootstrap/unix-88/extTools.c index b927caed..04925dbb 100644 --- a/bootstrap/unix-88/extTools.c +++ b/bootstrap/unix-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/unix-88/extTools.h b/bootstrap/unix-88/extTools.h index 7b30a000..0297454c 100644 --- a/bootstrap/unix-88/extTools.h +++ b/bootstrap/unix-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/windows-48/Compiler.c b/bootstrap/windows-48/Compiler.c index 5fb197fa..bb8b6f66 100644 --- a/bootstrap/windows-48/Compiler.c +++ b/bootstrap/windows-48/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Configuration.c b/bootstrap/windows-48/Configuration.c index 28930ae6..ffabe11c 100644 --- a/bootstrap/windows-48/Configuration.c +++ b/bootstrap/windows-48/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); + __MOVE("2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); __ENDMOD; } diff --git a/bootstrap/windows-48/Configuration.h b/bootstrap/windows-48/Configuration.h index 06b2322e..4da616f3 100644 --- a/bootstrap/windows-48/Configuration.h +++ b/bootstrap/windows-48/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/windows-48/Files.c b/bootstrap/windows-48/Files.c index ba84e061..0a560a90 100644 --- a/bootstrap/windows-48/Files.c +++ b/bootstrap/windows-48/Files.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -944,7 +944,11 @@ void Files_ReadNum (Files_Rider *R, ADDRESS *R__typ, SYSTEM_BYTE *x, ADDRESS x__ } q += (INT64)__ASH((__MASK(b, -64) - __ASHL(__ASHR(b, 6), 6)), s); Files_Assert(x__len <= 8); - __MOVE((ADDRESS)&q, (ADDRESS)x, x__len); + if (Platform_LittleEndian) { + __MOVE((ADDRESS)&q, (ADDRESS)x, x__len); + } else { + __MOVE(((ADDRESS)&q + 8) - (__SHORT(x__len, 32768)), (ADDRESS)x, x__len); + } } void Files_WriteBool (Files_Rider *R, ADDRESS *R__typ, BOOLEAN x) @@ -974,9 +978,7 @@ void Files_WriteSet (Files_Rider *R, ADDRESS *R__typ, UINT32 x) { CHAR b[4]; INT32 i; - UINT64 y; - y = x; - i = __VAL(INT32, y); + i = (INT32)x; b[0] = __CHR(i); b[1] = __CHR(__ASHR(i, 8)); b[2] = __CHR(__ASHR(i, 16)); diff --git a/bootstrap/windows-48/Files.h b/bootstrap/windows-48/Files.h index 9228f5c8..ca476c45 100644 --- a/bootstrap/windows-48/Files.h +++ b/bootstrap/windows-48/Files.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/windows-48/Heap.c b/bootstrap/windows-48/Heap.c index d00d1bec..3394b9ca 100644 --- a/bootstrap/windows-48/Heap.c +++ b/bootstrap/windows-48/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Heap.h b/bootstrap/windows-48/Heap.h index 3064651b..0b2056a8 100644 --- a/bootstrap/windows-48/Heap.h +++ b/bootstrap/windows-48/Heap.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/windows-48/Modules.c b/bootstrap/windows-48/Modules.c index 5afcfa92..4040a8d5 100644 --- a/bootstrap/windows-48/Modules.c +++ b/bootstrap/windows-48/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -52,7 +52,7 @@ extern void *Modules__init(void); void Modules_Init (INT32 argc, INT32 argvadr) { Modules_MainStackFrame = argvadr; - Modules_ArgCount = __VAL(INT16, argc); + Modules_ArgCount = __SHORT(argc, 32768); __GET(argvadr, Modules_ArgVector, INT32); Modules_InitHeap(); Modules_ModulesInit(); diff --git a/bootstrap/windows-48/Modules.h b/bootstrap/windows-48/Modules.h index 23f2dd74..f18e2955 100644 --- a/bootstrap/windows-48/Modules.h +++ b/bootstrap/windows-48/Modules.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/windows-48/OPB.c b/bootstrap/windows-48/OPB.c index 5a53405b..4db48170 100644 --- a/bootstrap/windows-48/OPB.c +++ b/bootstrap/windows-48/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -9,6 +9,7 @@ #include "OPM.h" #include "OPS.h" #include "OPT.h" +#include "Platform.h" static INT16 OPB_exp; @@ -216,7 +217,11 @@ static void OPB_SetIntType (OPT_Node node) static void OPB_SetSetType (OPT_Node node) { INT32 i32; - __GET((ADDRESS)&node->conval->setval + 4, i32, INT32); + if (Platform_LittleEndian) { + __GET((ADDRESS)&node->conval->setval + 4, i32, INT32); + } else { + __GET((ADDRESS)&node->conval->setval, i32, INT32); + } if (i32 == 0) { node->typ = OPT_set32typ; } else { @@ -2584,6 +2589,7 @@ export void *OPB__init(void) __MODULE_IMPORT(OPM); __MODULE_IMPORT(OPS); __MODULE_IMPORT(OPT); + __MODULE_IMPORT(Platform); __REGMOD("OPB", 0); /* BEGIN */ OPB_maxExp = OPB_log(4611686018427387904LL); diff --git a/bootstrap/windows-48/OPB.h b/bootstrap/windows-48/OPB.h index 0872ee74..bc2cc5d8 100644 --- a/bootstrap/windows-48/OPB.h +++ b/bootstrap/windows-48/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/windows-48/OPC.c b/bootstrap/windows-48/OPC.c index 061511af..cb155ecb 100644 --- a/bootstrap/windows-48/OPC.c +++ b/bootstrap/windows-48/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPC.h b/bootstrap/windows-48/OPC.h index 5642d227..34544d76 100644 --- a/bootstrap/windows-48/OPC.h +++ b/bootstrap/windows-48/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/windows-48/OPM.c b/bootstrap/windows-48/OPM.c index 0ad16dc2..2736a880 100644 --- a/bootstrap/windows-48/OPM.c +++ b/bootstrap/windows-48/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -206,12 +206,24 @@ INT64 OPM_SignedMinimum (INT32 bytecount) INT32 OPM_Longint (INT64 n) { - return __VAL(INT32, n); + INT32 r; + if (!Platform_LittleEndian) { + __GET((ADDRESS)&n + 4, r, INT32); + } else { + __GET((ADDRESS)&n, r, INT32); + } + return r; } INT16 OPM_Integer (INT64 n) { - return __VAL(INT16, n); + INT16 r; + if (!Platform_LittleEndian) { + __GET((ADDRESS)&n + 6, r, INT16); + } else { + __GET((ADDRESS)&n, r, INT16); + } + return r; } static void OPM_ScanOptions (CHAR *s, ADDRESS s__len) diff --git a/bootstrap/windows-48/OPM.h b/bootstrap/windows-48/OPM.h index f6ffb505..2d1b3434 100644 --- a/bootstrap/windows-48/OPM.h +++ b/bootstrap/windows-48/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/windows-48/OPP.c b/bootstrap/windows-48/OPP.c index 73f219fe..84429ea8 100644 --- a/bootstrap/windows-48/OPP.c +++ b/bootstrap/windows-48/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPP.h b/bootstrap/windows-48/OPP.h index 8d5b805a..5d9d5e47 100644 --- a/bootstrap/windows-48/OPP.h +++ b/bootstrap/windows-48/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/windows-48/OPS.c b/bootstrap/windows-48/OPS.c index 30e0c23a..66aa52f6 100644 --- a/bootstrap/windows-48/OPS.c +++ b/bootstrap/windows-48/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPS.h b/bootstrap/windows-48/OPS.h index 23609a77..d2acd451 100644 --- a/bootstrap/windows-48/OPS.h +++ b/bootstrap/windows-48/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/windows-48/OPT.c b/bootstrap/windows-48/OPT.c index 73f8eef3..ef2702ef 100644 --- a/bootstrap/windows-48/OPT.c +++ b/bootstrap/windows-48/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPT.h b/bootstrap/windows-48/OPT.h index ae1b41ca..131fac37 100644 --- a/bootstrap/windows-48/OPT.h +++ b/bootstrap/windows-48/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/windows-48/OPV.c b/bootstrap/windows-48/OPV.c index fe8d0057..1f220831 100644 --- a/bootstrap/windows-48/OPV.c +++ b/bootstrap/windows-48/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/OPV.h b/bootstrap/windows-48/OPV.h index 259d2274..85d2c9c4 100644 --- a/bootstrap/windows-48/OPV.h +++ b/bootstrap/windows-48/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/windows-48/Out.c b/bootstrap/windows-48/Out.c index acf43c6e..99bd7be4 100644 --- a/bootstrap/windows-48/Out.c +++ b/bootstrap/windows-48/Out.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Out.h b/bootstrap/windows-48/Out.h index da4c375e..2e4d3247 100644 --- a/bootstrap/windows-48/Out.h +++ b/bootstrap/windows-48/Out.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/windows-48/Platform.c b/bootstrap/windows-48/Platform.c index e3e23663..1f7b29c2 100644 --- a/bootstrap/windows-48/Platform.c +++ b/bootstrap/windows-48/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Platform.h b/bootstrap/windows-48/Platform.h index 7fc5f72f..11c84089 100644 --- a/bootstrap/windows-48/Platform.h +++ b/bootstrap/windows-48/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/windows-48/Reals.c b/bootstrap/windows-48/Reals.c index 17e02efc..d316e1ba 100644 --- a/bootstrap/windows-48/Reals.c +++ b/bootstrap/windows-48/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -6,8 +6,10 @@ #define SET UINT32 #include "SYSTEM.h" +#include "Platform.h" +static INT16 Reals_realExpHi, Reals_realExpLo, Reals_lrealExpHi, Reals_lrealExpLo; static void Reals_BytesToHex (SYSTEM_BYTE *b, ADDRESS b__len, SYSTEM_BYTE *d, ADDRESS d__len); @@ -17,7 +19,9 @@ export void Reals_ConvertHL (LONGREAL x, CHAR *d, ADDRESS d__len); export void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len); export INT16 Reals_Expo (REAL x); export INT16 Reals_ExpoL (LONGREAL x); +static void Reals_InitEndian (void); export void Reals_SetExpo (REAL *x, INT16 ex); +export void Reals_SetExpoL (LONGREAL *x, INT16 ex); export REAL Reals_Ten (INT16 e); export LONGREAL Reals_TenL (INT16 e); static CHAR Reals_ToHex (INT16 i); @@ -58,25 +62,36 @@ LONGREAL Reals_TenL (INT16 e) INT16 Reals_Expo (REAL x) { - INT16 i; - __GET((ADDRESS)&x + 2, i, INT16); - return __MASK(__ASHR(i, 7), -256); + CHAR hi, lo; + __GET((ADDRESS)&x + Reals_realExpHi, hi, CHAR); + __GET((ADDRESS)&x + Reals_realExpLo, lo, CHAR); + return __MASK(__ASHL((INT16)hi, 1) + __ASHR((INT16)lo, 7), -256); } void Reals_SetExpo (REAL *x, INT16 ex) { CHAR c; - __GET((ADDRESS)x + 3, c, CHAR); - __PUT((ADDRESS)x + 3, __CHR(__ASHL(__ASHR((INT16)c, 7), 7) + __MASK(__ASHR(ex, 1), -128)), CHAR); - __GET((ADDRESS)x + 2, c, CHAR); - __PUT((ADDRESS)x + 2, __CHR(__MASK((INT16)c, -128) + __ASHL(__MASK(ex, -2), 7)), CHAR); + __GET((ADDRESS)x + Reals_realExpHi, c, CHAR); + __PUT((ADDRESS)x + Reals_realExpHi, __CHR(__ASHL(__ASHR((INT16)c, 7), 7) + __MASK(__ASHR(ex, 1), -128)), CHAR); + __GET((ADDRESS)x + Reals_realExpLo, c, CHAR); + __PUT((ADDRESS)x + Reals_realExpLo, __CHR(__MASK((INT16)c, -128) + __ASHL(__MASK(ex, -2), 7)), CHAR); } INT16 Reals_ExpoL (LONGREAL x) { - INT16 i; - __GET((ADDRESS)&x + 6, i, INT16); - return __MASK(__ASHR(i, 4), -2048); + CHAR hi, lo; + __GET((ADDRESS)&x + Reals_lrealExpHi, hi, CHAR); + __GET((ADDRESS)&x + Reals_lrealExpLo, lo, CHAR); + return __MASK(__ASHL((INT16)hi, 4) + __ASHR((INT16)lo, 4), -2048); +} + +void Reals_SetExpoL (LONGREAL *x, INT16 ex) +{ + CHAR c; + __GET((ADDRESS)x + Reals_lrealExpHi, c, CHAR); + __PUT((ADDRESS)x + Reals_lrealExpHi, __CHR(__ASHL(__ASHR((INT16)c, 7), 7) + __MASK(__ASHR(ex, 4), -128)), CHAR); + __GET((ADDRESS)x + Reals_lrealExpLo, c, CHAR); + __PUT((ADDRESS)x + Reals_lrealExpLo, __CHR(__ASHL(__MASK(ex, -16), 4) + __MASK((INT16)c, -16)), CHAR); } void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len) @@ -124,16 +139,25 @@ static CHAR Reals_ToHex (INT16 i) static void Reals_BytesToHex (SYSTEM_BYTE *b, ADDRESS b__len, SYSTEM_BYTE *d, ADDRESS d__len) { - INT16 i; - INT32 l; + INT16 i, j, len; CHAR by; - i = 0; - l = b__len; - while (i < l) { + len = __SHORT(b__len, 32768); + if (Platform_LittleEndian) { + i = 0; + } else { + i = len - 1; + } + j = 0; + while ((i >= 0 && i < len)) { by = __VAL(CHAR, b[__X(i, b__len)]); - d[__X(__ASHL(i, 1), d__len)] = Reals_ToHex(__ASHR((INT16)by, 4)); - d[__X(__ASHL(i, 1) + 1, d__len)] = Reals_ToHex(__MASK((INT16)by, -16)); - i += 1; + d[__X(__ASHL(j, 1), d__len)] = Reals_ToHex(__ASHR((INT16)by, 4)); + d[__X(__ASHL(j, 1) + 1, d__len)] = Reals_ToHex(__MASK((INT16)by, -16)); + j += 1; + if (Platform_LittleEndian) { + i += 1; + } else { + i -= 1; + } } } @@ -147,11 +171,28 @@ void Reals_ConvertHL (LONGREAL x, CHAR *d, ADDRESS d__len) Reals_BytesToHex((void*)&x, 8, (void*)d, d__len * 1); } +static void Reals_InitEndian (void) +{ + if (Platform_LittleEndian) { + Reals_realExpHi = 3; + Reals_realExpLo = 2; + Reals_lrealExpHi = 7; + Reals_lrealExpLo = 6; + } else { + Reals_realExpHi = 0; + Reals_realExpLo = 1; + Reals_lrealExpHi = 0; + Reals_lrealExpLo = 1; + } +} + export void *Reals__init(void) { __DEFMOD; + __MODULE_IMPORT(Platform); __REGMOD("Reals", 0); /* BEGIN */ + Reals_InitEndian(); __ENDMOD; } diff --git a/bootstrap/windows-48/Reals.h b/bootstrap/windows-48/Reals.h index 72cdeac9..dc156476 100644 --- a/bootstrap/windows-48/Reals.h +++ b/bootstrap/windows-48/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Reals__h #define Reals__h @@ -15,6 +15,7 @@ import void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len); import INT16 Reals_Expo (REAL x); import INT16 Reals_ExpoL (LONGREAL x); import void Reals_SetExpo (REAL *x, INT16 ex); +import void Reals_SetExpoL (LONGREAL *x, INT16 ex); import REAL Reals_Ten (INT16 e); import LONGREAL Reals_TenL (INT16 e); import void *Reals__init(void); diff --git a/bootstrap/windows-48/Strings.c b/bootstrap/windows-48/Strings.c index 33402210..89734392 100644 --- a/bootstrap/windows-48/Strings.c +++ b/bootstrap/windows-48/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Strings.h b/bootstrap/windows-48/Strings.h index 94c330de..e15d3f0a 100644 --- a/bootstrap/windows-48/Strings.h +++ b/bootstrap/windows-48/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/windows-48/Texts.c b/bootstrap/windows-48/Texts.c index 322ce28b..ecda3377 100644 --- a/bootstrap/windows-48/Texts.c +++ b/bootstrap/windows-48/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/Texts.h b/bootstrap/windows-48/Texts.h index d1d92b87..cc2fb2d7 100644 --- a/bootstrap/windows-48/Texts.h +++ b/bootstrap/windows-48/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/windows-48/VT100.c b/bootstrap/windows-48/VT100.c index 2dbabfac..edb28fa4 100644 --- a/bootstrap/windows-48/VT100.c +++ b/bootstrap/windows-48/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/VT100.h b/bootstrap/windows-48/VT100.h index d93196f4..536d7d6f 100644 --- a/bootstrap/windows-48/VT100.h +++ b/bootstrap/windows-48/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/windows-48/extTools.c b/bootstrap/windows-48/extTools.c index b927caed..04925dbb 100644 --- a/bootstrap/windows-48/extTools.c +++ b/bootstrap/windows-48/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-48/extTools.h b/bootstrap/windows-48/extTools.h index 7b30a000..0297454c 100644 --- a/bootstrap/windows-48/extTools.h +++ b/bootstrap/windows-48/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/bootstrap/windows-88/Compiler.c b/bootstrap/windows-88/Compiler.c index 5fb197fa..bb8b6f66 100644 --- a/bootstrap/windows-88/Compiler.c +++ b/bootstrap/windows-88/Compiler.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspamS */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Configuration.c b/bootstrap/windows-88/Configuration.c index 28930ae6..ffabe11c 100644 --- a/bootstrap/windows-88/Configuration.c +++ b/bootstrap/windows-88/Configuration.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -19,6 +19,6 @@ export void *Configuration__init(void) __DEFMOD; __REGMOD("Configuration", 0); /* BEGIN */ - __MOVE("2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); + __MOVE("2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8.", Configuration_versionLong, 76); __ENDMOD; } diff --git a/bootstrap/windows-88/Configuration.h b/bootstrap/windows-88/Configuration.h index 06b2322e..4da616f3 100644 --- a/bootstrap/windows-88/Configuration.h +++ b/bootstrap/windows-88/Configuration.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Configuration__h #define Configuration__h diff --git a/bootstrap/windows-88/Files.c b/bootstrap/windows-88/Files.c index 3f3d514c..f2e1d8d1 100644 --- a/bootstrap/windows-88/Files.c +++ b/bootstrap/windows-88/Files.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -944,7 +944,11 @@ void Files_ReadNum (Files_Rider *R, ADDRESS *R__typ, SYSTEM_BYTE *x, ADDRESS x__ } q += (INT64)__ASH((__MASK(b, -64) - __ASHL(__ASHR(b, 6), 6)), s); Files_Assert(x__len <= 8); - __MOVE((ADDRESS)&q, (ADDRESS)x, x__len); + if (Platform_LittleEndian) { + __MOVE((ADDRESS)&q, (ADDRESS)x, x__len); + } else { + __MOVE(((ADDRESS)&q + 8) - (INT64)(__SHORT(x__len, 32768)), (ADDRESS)x, x__len); + } } void Files_WriteBool (Files_Rider *R, ADDRESS *R__typ, BOOLEAN x) @@ -974,9 +978,7 @@ void Files_WriteSet (Files_Rider *R, ADDRESS *R__typ, UINT32 x) { CHAR b[4]; INT32 i; - UINT64 y; - y = x; - i = __VAL(INT32, y); + i = (INT32)x; b[0] = __CHR(i); b[1] = __CHR(__ASHR(i, 8)); b[2] = __CHR(__ASHR(i, 16)); diff --git a/bootstrap/windows-88/Files.h b/bootstrap/windows-88/Files.h index 6074566d..04de8bb1 100644 --- a/bootstrap/windows-88/Files.h +++ b/bootstrap/windows-88/Files.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Files__h #define Files__h diff --git a/bootstrap/windows-88/Heap.c b/bootstrap/windows-88/Heap.c index 15a6e3b6..1513c9b1 100644 --- a/bootstrap/windows-88/Heap.c +++ b/bootstrap/windows-88/Heap.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Heap.h b/bootstrap/windows-88/Heap.h index ec34eede..782a3a52 100644 --- a/bootstrap/windows-88/Heap.h +++ b/bootstrap/windows-88/Heap.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. rtsSF */ #ifndef Heap__h #define Heap__h diff --git a/bootstrap/windows-88/Modules.c b/bootstrap/windows-88/Modules.c index aa5708c8..11eb3b92 100644 --- a/bootstrap/windows-88/Modules.c +++ b/bootstrap/windows-88/Modules.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -52,7 +52,7 @@ extern void *Modules__init(void); void Modules_Init (INT32 argc, INT64 argvadr) { Modules_MainStackFrame = argvadr; - Modules_ArgCount = __VAL(INT16, argc); + Modules_ArgCount = __SHORT(argc, 32768); __GET(argvadr, Modules_ArgVector, INT64); Modules_InitHeap(); Modules_ModulesInit(); diff --git a/bootstrap/windows-88/Modules.h b/bootstrap/windows-88/Modules.h index 8a333379..f559ace4 100644 --- a/bootstrap/windows-88/Modules.h +++ b/bootstrap/windows-88/Modules.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Modules__h #define Modules__h diff --git a/bootstrap/windows-88/OPB.c b/bootstrap/windows-88/OPB.c index 5a53405b..4db48170 100644 --- a/bootstrap/windows-88/OPB.c +++ b/bootstrap/windows-88/OPB.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -9,6 +9,7 @@ #include "OPM.h" #include "OPS.h" #include "OPT.h" +#include "Platform.h" static INT16 OPB_exp; @@ -216,7 +217,11 @@ static void OPB_SetIntType (OPT_Node node) static void OPB_SetSetType (OPT_Node node) { INT32 i32; - __GET((ADDRESS)&node->conval->setval + 4, i32, INT32); + if (Platform_LittleEndian) { + __GET((ADDRESS)&node->conval->setval + 4, i32, INT32); + } else { + __GET((ADDRESS)&node->conval->setval, i32, INT32); + } if (i32 == 0) { node->typ = OPT_set32typ; } else { @@ -2584,6 +2589,7 @@ export void *OPB__init(void) __MODULE_IMPORT(OPM); __MODULE_IMPORT(OPS); __MODULE_IMPORT(OPT); + __MODULE_IMPORT(Platform); __REGMOD("OPB", 0); /* BEGIN */ OPB_maxExp = OPB_log(4611686018427387904LL); diff --git a/bootstrap/windows-88/OPB.h b/bootstrap/windows-88/OPB.h index 0872ee74..bc2cc5d8 100644 --- a/bootstrap/windows-88/OPB.h +++ b/bootstrap/windows-88/OPB.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPB__h #define OPB__h diff --git a/bootstrap/windows-88/OPC.c b/bootstrap/windows-88/OPC.c index 061511af..cb155ecb 100644 --- a/bootstrap/windows-88/OPC.c +++ b/bootstrap/windows-88/OPC.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPC.h b/bootstrap/windows-88/OPC.h index 5642d227..34544d76 100644 --- a/bootstrap/windows-88/OPC.h +++ b/bootstrap/windows-88/OPC.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPC__h #define OPC__h diff --git a/bootstrap/windows-88/OPM.c b/bootstrap/windows-88/OPM.c index 6f26cfe8..6f18df61 100644 --- a/bootstrap/windows-88/OPM.c +++ b/bootstrap/windows-88/OPM.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -206,12 +206,24 @@ INT64 OPM_SignedMinimum (INT32 bytecount) INT32 OPM_Longint (INT64 n) { - return __VAL(INT32, n); + INT32 r; + if (!Platform_LittleEndian) { + __GET((ADDRESS)&n + 4, r, INT32); + } else { + __GET((ADDRESS)&n, r, INT32); + } + return r; } INT16 OPM_Integer (INT64 n) { - return __VAL(INT16, n); + INT16 r; + if (!Platform_LittleEndian) { + __GET((ADDRESS)&n + 6, r, INT16); + } else { + __GET((ADDRESS)&n, r, INT16); + } + return r; } static void OPM_ScanOptions (CHAR *s, ADDRESS s__len) diff --git a/bootstrap/windows-88/OPM.h b/bootstrap/windows-88/OPM.h index f6ffb505..2d1b3434 100644 --- a/bootstrap/windows-88/OPM.h +++ b/bootstrap/windows-88/OPM.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPM__h #define OPM__h diff --git a/bootstrap/windows-88/OPP.c b/bootstrap/windows-88/OPP.c index b4f5f6bb..0629ae67 100644 --- a/bootstrap/windows-88/OPP.c +++ b/bootstrap/windows-88/OPP.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPP.h b/bootstrap/windows-88/OPP.h index 8d5b805a..5d9d5e47 100644 --- a/bootstrap/windows-88/OPP.h +++ b/bootstrap/windows-88/OPP.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPP__h #define OPP__h diff --git a/bootstrap/windows-88/OPS.c b/bootstrap/windows-88/OPS.c index 30e0c23a..66aa52f6 100644 --- a/bootstrap/windows-88/OPS.c +++ b/bootstrap/windows-88/OPS.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPS.h b/bootstrap/windows-88/OPS.h index 23609a77..d2acd451 100644 --- a/bootstrap/windows-88/OPS.h +++ b/bootstrap/windows-88/OPS.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPS__h #define OPS__h diff --git a/bootstrap/windows-88/OPT.c b/bootstrap/windows-88/OPT.c index 53898c63..7b562383 100644 --- a/bootstrap/windows-88/OPT.c +++ b/bootstrap/windows-88/OPT.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPT.h b/bootstrap/windows-88/OPT.h index ae1b41ca..131fac37 100644 --- a/bootstrap/windows-88/OPT.h +++ b/bootstrap/windows-88/OPT.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPT__h #define OPT__h diff --git a/bootstrap/windows-88/OPV.c b/bootstrap/windows-88/OPV.c index 82ed398e..86061443 100644 --- a/bootstrap/windows-88/OPV.c +++ b/bootstrap/windows-88/OPV.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/OPV.h b/bootstrap/windows-88/OPV.h index 259d2274..85d2c9c4 100644 --- a/bootstrap/windows-88/OPV.h +++ b/bootstrap/windows-88/OPV.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef OPV__h #define OPV__h diff --git a/bootstrap/windows-88/Out.c b/bootstrap/windows-88/Out.c index acf43c6e..99bd7be4 100644 --- a/bootstrap/windows-88/Out.c +++ b/bootstrap/windows-88/Out.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Out.h b/bootstrap/windows-88/Out.h index da4c375e..2e4d3247 100644 --- a/bootstrap/windows-88/Out.h +++ b/bootstrap/windows-88/Out.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Out__h #define Out__h diff --git a/bootstrap/windows-88/Platform.c b/bootstrap/windows-88/Platform.c index 11bc33ff..594c4175 100644 --- a/bootstrap/windows-88/Platform.c +++ b/bootstrap/windows-88/Platform.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Platform.h b/bootstrap/windows-88/Platform.h index d708716a..61c14ebf 100644 --- a/bootstrap/windows-88/Platform.h +++ b/bootstrap/windows-88/Platform.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Platform__h #define Platform__h diff --git a/bootstrap/windows-88/Reals.c b/bootstrap/windows-88/Reals.c index 17e02efc..cdfbd7ce 100644 --- a/bootstrap/windows-88/Reals.c +++ b/bootstrap/windows-88/Reals.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 @@ -6,8 +6,10 @@ #define SET UINT32 #include "SYSTEM.h" +#include "Platform.h" +static INT16 Reals_realExpHi, Reals_realExpLo, Reals_lrealExpHi, Reals_lrealExpLo; static void Reals_BytesToHex (SYSTEM_BYTE *b, ADDRESS b__len, SYSTEM_BYTE *d, ADDRESS d__len); @@ -17,7 +19,9 @@ export void Reals_ConvertHL (LONGREAL x, CHAR *d, ADDRESS d__len); export void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len); export INT16 Reals_Expo (REAL x); export INT16 Reals_ExpoL (LONGREAL x); +static void Reals_InitEndian (void); export void Reals_SetExpo (REAL *x, INT16 ex); +export void Reals_SetExpoL (LONGREAL *x, INT16 ex); export REAL Reals_Ten (INT16 e); export LONGREAL Reals_TenL (INT16 e); static CHAR Reals_ToHex (INT16 i); @@ -58,25 +62,36 @@ LONGREAL Reals_TenL (INT16 e) INT16 Reals_Expo (REAL x) { - INT16 i; - __GET((ADDRESS)&x + 2, i, INT16); - return __MASK(__ASHR(i, 7), -256); + CHAR hi, lo; + __GET((ADDRESS)&x + (INT64)Reals_realExpHi, hi, CHAR); + __GET((ADDRESS)&x + (INT64)Reals_realExpLo, lo, CHAR); + return __MASK(__ASHL((INT16)hi, 1) + __ASHR((INT16)lo, 7), -256); } void Reals_SetExpo (REAL *x, INT16 ex) { CHAR c; - __GET((ADDRESS)x + 3, c, CHAR); - __PUT((ADDRESS)x + 3, __CHR(__ASHL(__ASHR((INT16)c, 7), 7) + __MASK(__ASHR(ex, 1), -128)), CHAR); - __GET((ADDRESS)x + 2, c, CHAR); - __PUT((ADDRESS)x + 2, __CHR(__MASK((INT16)c, -128) + __ASHL(__MASK(ex, -2), 7)), CHAR); + __GET((ADDRESS)x + (INT64)Reals_realExpHi, c, CHAR); + __PUT((ADDRESS)x + (INT64)Reals_realExpHi, __CHR(__ASHL(__ASHR((INT16)c, 7), 7) + __MASK(__ASHR(ex, 1), -128)), CHAR); + __GET((ADDRESS)x + (INT64)Reals_realExpLo, c, CHAR); + __PUT((ADDRESS)x + (INT64)Reals_realExpLo, __CHR(__MASK((INT16)c, -128) + __ASHL(__MASK(ex, -2), 7)), CHAR); } INT16 Reals_ExpoL (LONGREAL x) { - INT16 i; - __GET((ADDRESS)&x + 6, i, INT16); - return __MASK(__ASHR(i, 4), -2048); + CHAR hi, lo; + __GET((ADDRESS)&x + (INT64)Reals_lrealExpHi, hi, CHAR); + __GET((ADDRESS)&x + (INT64)Reals_lrealExpLo, lo, CHAR); + return __MASK(__ASHL((INT16)hi, 4) + __ASHR((INT16)lo, 4), -2048); +} + +void Reals_SetExpoL (LONGREAL *x, INT16 ex) +{ + CHAR c; + __GET((ADDRESS)x + (INT64)Reals_lrealExpHi, c, CHAR); + __PUT((ADDRESS)x + (INT64)Reals_lrealExpHi, __CHR(__ASHL(__ASHR((INT16)c, 7), 7) + __MASK(__ASHR(ex, 4), -128)), CHAR); + __GET((ADDRESS)x + (INT64)Reals_lrealExpLo, c, CHAR); + __PUT((ADDRESS)x + (INT64)Reals_lrealExpLo, __CHR(__ASHL(__MASK(ex, -16), 4) + __MASK((INT16)c, -16)), CHAR); } void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len) @@ -124,16 +139,25 @@ static CHAR Reals_ToHex (INT16 i) static void Reals_BytesToHex (SYSTEM_BYTE *b, ADDRESS b__len, SYSTEM_BYTE *d, ADDRESS d__len) { - INT16 i; - INT32 l; + INT16 i, j, len; CHAR by; - i = 0; - l = b__len; - while (i < l) { + len = __SHORT(b__len, 32768); + if (Platform_LittleEndian) { + i = 0; + } else { + i = len - 1; + } + j = 0; + while ((i >= 0 && i < len)) { by = __VAL(CHAR, b[__X(i, b__len)]); - d[__X(__ASHL(i, 1), d__len)] = Reals_ToHex(__ASHR((INT16)by, 4)); - d[__X(__ASHL(i, 1) + 1, d__len)] = Reals_ToHex(__MASK((INT16)by, -16)); - i += 1; + d[__X(__ASHL(j, 1), d__len)] = Reals_ToHex(__ASHR((INT16)by, 4)); + d[__X(__ASHL(j, 1) + 1, d__len)] = Reals_ToHex(__MASK((INT16)by, -16)); + j += 1; + if (Platform_LittleEndian) { + i += 1; + } else { + i -= 1; + } } } @@ -147,11 +171,28 @@ void Reals_ConvertHL (LONGREAL x, CHAR *d, ADDRESS d__len) Reals_BytesToHex((void*)&x, 8, (void*)d, d__len * 1); } +static void Reals_InitEndian (void) +{ + if (Platform_LittleEndian) { + Reals_realExpHi = 3; + Reals_realExpLo = 2; + Reals_lrealExpHi = 7; + Reals_lrealExpLo = 6; + } else { + Reals_realExpHi = 0; + Reals_realExpLo = 1; + Reals_lrealExpHi = 0; + Reals_lrealExpLo = 1; + } +} + export void *Reals__init(void) { __DEFMOD; + __MODULE_IMPORT(Platform); __REGMOD("Reals", 0); /* BEGIN */ + Reals_InitEndian(); __ENDMOD; } diff --git a/bootstrap/windows-88/Reals.h b/bootstrap/windows-88/Reals.h index 72cdeac9..dc156476 100644 --- a/bootstrap/windows-88/Reals.h +++ b/bootstrap/windows-88/Reals.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Reals__h #define Reals__h @@ -15,6 +15,7 @@ import void Reals_ConvertL (LONGREAL x, INT16 n, CHAR *d, ADDRESS d__len); import INT16 Reals_Expo (REAL x); import INT16 Reals_ExpoL (LONGREAL x); import void Reals_SetExpo (REAL *x, INT16 ex); +import void Reals_SetExpoL (LONGREAL *x, INT16 ex); import REAL Reals_Ten (INT16 e); import LONGREAL Reals_TenL (INT16 e); import void *Reals__init(void); diff --git a/bootstrap/windows-88/Strings.c b/bootstrap/windows-88/Strings.c index 33402210..89734392 100644 --- a/bootstrap/windows-88/Strings.c +++ b/bootstrap/windows-88/Strings.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Strings.h b/bootstrap/windows-88/Strings.h index 94c330de..e15d3f0a 100644 --- a/bootstrap/windows-88/Strings.h +++ b/bootstrap/windows-88/Strings.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Strings__h #define Strings__h diff --git a/bootstrap/windows-88/Texts.c b/bootstrap/windows-88/Texts.c index 667cd440..9378df02 100644 --- a/bootstrap/windows-88/Texts.c +++ b/bootstrap/windows-88/Texts.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/Texts.h b/bootstrap/windows-88/Texts.h index b39a4f55..9d0b3ec8 100644 --- a/bootstrap/windows-88/Texts.h +++ b/bootstrap/windows-88/Texts.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef Texts__h #define Texts__h diff --git a/bootstrap/windows-88/VT100.c b/bootstrap/windows-88/VT100.c index 2dbabfac..edb28fa4 100644 --- a/bootstrap/windows-88/VT100.c +++ b/bootstrap/windows-88/VT100.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/VT100.h b/bootstrap/windows-88/VT100.h index d93196f4..536d7d6f 100644 --- a/bootstrap/windows-88/VT100.h +++ b/bootstrap/windows-88/VT100.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef VT100__h #define VT100__h diff --git a/bootstrap/windows-88/extTools.c b/bootstrap/windows-88/extTools.c index b927caed..04925dbb 100644 --- a/bootstrap/windows-88/extTools.c +++ b/bootstrap/windows-88/extTools.c @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #define SHORTINT INT8 #define INTEGER INT16 diff --git a/bootstrap/windows-88/extTools.h b/bootstrap/windows-88/extTools.h index 7b30a000..0297454c 100644 --- a/bootstrap/windows-88/extTools.h +++ b/bootstrap/windows-88/extTools.h @@ -1,4 +1,4 @@ -/* voc 2.1.0 [2026/07/10]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ +/* voc 2.1.0 [2026/07/12]. Bootstrapping compiler for address size 8, alignment 8. xrtspaSF */ #ifndef extTools__h #define extTools__h diff --git a/src/compiler/OPB.Mod b/src/compiler/OPB.Mod index 8dedaaaa..1c7debe6 100644 --- a/src/compiler/OPB.Mod +++ b/src/compiler/OPB.Mod @@ -1,7 +1,7 @@ (* Oberon Portable build parse tree (front end) *) MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *) - IMPORT OPT, OPS, OPM, SYSTEM; + IMPORT OPT, OPS, OPM, Platform, SYSTEM; CONST @@ -109,7 +109,12 @@ MODULE OPB; (* RC 6.3.89 / 21.2.94 *) (* object model 17.1.93 *) PROCEDURE SetSetType(node: OPT.Node); VAR i32: SYSTEM.INT32; - BEGIN SYSTEM.GET(SYSTEM.ADR(node.conval.setval)+4, i32); (* See if upper 32 bits are zero *) + BEGIN + IF Platform.LittleEndian THEN + SYSTEM.GET(SYSTEM.ADR(node.conval.setval) + 4, i32) + ELSE + SYSTEM.GET(SYSTEM.ADR(node.conval.setval), i32) + END; IF i32 = 0 THEN node.typ := OPT.set32typ ELSE node.typ := OPT.set64typ END END SetSetType; diff --git a/src/compiler/OPM.Mod b/src/compiler/OPM.Mod index ab3d7dae..84678d6c 100755 --- a/src/compiler/OPM.Mod +++ b/src/compiler/OPM.Mod @@ -195,10 +195,31 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *) END SignedMinimum; - (* Unchecked conversion of any size integer to INTEGER or LONGINT *) + (* Unchecked conversion of any size integer to INTEGER or LONGINT. + Uses endian-neutral byte extraction since SYSTEM.VAL across different + sizes reads the wrong bytes on big-endian platforms. *) - PROCEDURE Longint* (n: SYSTEM.INT64): LONGINT; BEGIN RETURN SYSTEM.VAL(LONGINT, n) END Longint; - PROCEDURE Integer* (n: SYSTEM.INT64): INTEGER; BEGIN RETURN SYSTEM.VAL(INTEGER, n) END Integer; + PROCEDURE Longint* (n: SYSTEM.INT64): LONGINT; + VAR r: LONGINT; + BEGIN + IF ~Platform.LittleEndian THEN + SYSTEM.GET(SYSTEM.ADR(n) + (SIZE(HUGEINT) - SIZE(LONGINT)), r) + ELSE + SYSTEM.GET(SYSTEM.ADR(n), r) + END; + RETURN r + END Longint; + + PROCEDURE Integer* (n: SYSTEM.INT64): INTEGER; + VAR r: INTEGER; + BEGIN + IF ~Platform.LittleEndian THEN + SYSTEM.GET(SYSTEM.ADR(n) + (SIZE(HUGEINT) - SIZE(INTEGER)), r) + ELSE + SYSTEM.GET(SYSTEM.ADR(n), r) + END; + RETURN r + END Integer; diff --git a/src/library/ooc/oocLowReal.Mod b/src/library/ooc/oocLowReal.Mod index 7319794f..5bbd5fb3 100644 --- a/src/library/ooc/oocLowReal.Mod +++ b/src/library/ooc/oocLowReal.Mod @@ -161,49 +161,22 @@ PROCEDURE fraction*(x: REAL): REAL; significant) part of `x'. Hence the following relationship shall hold: x = scale(fraction(x), exponent(x)). *) -VAR c: CHAR; BEGIN IF x=ZERO THEN RETURN ZERO ELSE - (* Set top 7 bits of exponent to 0111111 *) - S.GET(S.ADR(x)+3, c); - c := CHR(((ORD(c) DIV 128) * 128) + 63); (* Set X0111111 (X unchanged) *) - S.PUT(S.ADR(x)+3, c); - (* Set bottom bit of exponent to 0 *) - S.GET(S.ADR(x)+2, c); - c := CHR(ORD(c) MOD 128); (* Set 0XXXXXXX (X unchanged) *) - S.PUT(S.ADR(x)+2, c); + Reals.SetExpo(x, 126); (* biased exponent 126 = 2^(-1), so x*2 gives [1.0, 2.0) *) RETURN x * 2.0; END -(* - CONST eZero={(hiBit+2)..29}; -BEGIN - IF x=ZERO THEN RETURN ZERO - ELSE RETURN S.VAL(REAL,(S.VAL(SET,x)*nMask)+eZero)*2.0 (* set the mantissa's exponent to zero *) - END -*) END fraction; PROCEDURE IsInfinity * (real: REAL) : BOOLEAN; - VAR c0, c1, c2, c3: CHAR; BEGIN - S.GET(S.ADR(real)+0, c3); - S.GET(S.ADR(real)+1, c2); - S.GET(S.ADR(real)+2, c1); - S.GET(S.ADR(real)+3, c0); - RETURN (ORD(c0) MOD 128 = 127) & (ORD(c1) = 128) & (ORD(c2) = 0) & (ORD(c3) = 0) + RETURN (Reals.Expo(real) = 255) & (S.VAL(SET, real) * {0..22} = {}) END IsInfinity; PROCEDURE IsNaN * (real: REAL) : BOOLEAN; - VAR c0, c1, c2, c3: CHAR; BEGIN - S.GET(S.ADR(real)+0, c3); - S.GET(S.ADR(real)+1, c2); - S.GET(S.ADR(real)+2, c1); - S.GET(S.ADR(real)+3, c0); - RETURN (ORD(c0) MOD 128 = 127) - & (ORD(c1) DIV 128 = 1) - & ((ORD(c1) MOD 128 # 0) OR (ORD(c2) # 0) OR (ORD(c3) # 0)) + RETURN (Reals.Expo(real) = 255) & (S.VAL(SET, real) * {0..22} # {}) END IsNaN; PROCEDURE sign*(x: REAL): REAL; diff --git a/src/library/ulm/ulmTypes.Mod b/src/library/ulm/ulmTypes.Mod index 318fcd9d..2c62e589 100644 --- a/src/library/ulm/ulmTypes.Mod +++ b/src/library/ulm/ulmTypes.Mod @@ -68,7 +68,6 @@ MODULE ulmTypes; CONST bigEndian* = 0; (* SPARC, M68K etc *) littleEndian* = 1; (* Intel 80x86, VAX etc *) - byteorder* = littleEndian; (* machine-dependent constant *) TYPE ByteOrder* = SYS.INT8; (* bigEndian or littleEndian *) @@ -79,10 +78,20 @@ MODULE ulmTypes; TYPE SetInt* = SYS.INT32; (* Types.Int32 type that corresponds to Types.Set *) VAR + byteorder*: ByteOrder; (* detected at module initialisation *) msb*: SYS.SET32; msbIsMax*, msbIs0*: SYS.INT8; msbindex*, lsbindex*, nofbits*: SYS.INT32; + PROCEDURE DetectByteOrder; + VAR test: SYS.INT32; c: CHAR; + BEGIN + test := 1; SYS.GET(SYS.ADR(test), c); + IF c = 1X THEN byteorder := littleEndian + ELSE byteorder := bigEndian + END + END DetectByteOrder; + PROCEDURE ToInt8*(int: Int32) : Int8; BEGIN RETURN SHORT(SHORT(int)) @@ -109,6 +118,7 @@ MODULE ulmTypes; END ToReal64; BEGIN + DetectByteOrder; msb := SYS.VAL(SYS.SET32, MIN(SetInt)); (* most significant bit, converted to a Types.Set *) diff --git a/src/runtime/Files.Mod b/src/runtime/Files.Mod index 64236a7d..9ebee283 100644 --- a/src/runtime/Files.Mod +++ b/src/runtime/Files.Mod @@ -656,7 +656,11 @@ Especially Length would become fairly complex. WHILE b < 0 DO INC(q, ASH(b+128, s)); INC(s, 7); Read(R, b) END; INC(q, ASH(b MOD 64 - b DIV 64 * 64, s)); Assert(LEN(x) <= 8); - SYSTEM.MOVE(SYSTEM.ADR(q), SYSTEM.ADR(x), LEN(x)) (* Assumes little endian representation of q and x. *) + IF Platform.LittleEndian THEN + SYSTEM.MOVE(SYSTEM.ADR(q), SYSTEM.ADR(x), LEN(x)) + ELSE + SYSTEM.MOVE(SYSTEM.ADR(q) + SIZE(HUGEINT) - SHORT(LEN(x)), SYSTEM.ADR(x), LEN(x)) + END END ReadNum; PROCEDURE WriteBool* (VAR R: Rider; x: BOOLEAN); @@ -678,13 +682,11 @@ Especially Length would become fairly complex. PROCEDURE WriteSet* (VAR R: Rider; x: SET); VAR b: ARRAY 4 OF CHAR; i: LONGINT; - y: SYSTEM.SET64; BEGIN IF SIZE(SET) = SIZE(INTEGER) THEN i := SYSTEM.VAL(INTEGER, x); ELSE - y := x; - i := SYSTEM.VAL(LONGINT, y); + i := SYSTEM.VAL(LONGINT, x); (* same byte width: endian-neutral reinterpret *) END; b[0] := CHR(i); b[1] := CHR(i DIV 100H); b[2] := CHR(i DIV 10000H); b[3] := CHR(i DIV 1000000H); diff --git a/src/runtime/In.Mod b/src/runtime/In.Mod index 76ceb1e8..4c3ef8c5 100644 --- a/src/runtime/In.Mod +++ b/src/runtime/In.Mod @@ -91,12 +91,24 @@ END HugeInt; PROCEDURE Int*(VAR i: INTEGER); VAR h: HUGEINT; -BEGIN HugeInt(h); i := SYSTEM.VAL(INTEGER, h) +BEGIN + HugeInt(h); + IF ~Platform.LittleEndian THEN + SYSTEM.GET(SYSTEM.ADR(h) + SIZE(HUGEINT) - SIZE(INTEGER), i) + ELSE + SYSTEM.GET(SYSTEM.ADR(h), i) + END END Int; PROCEDURE LongInt*(VAR i: LONGINT); VAR h: HUGEINT; -BEGIN HugeInt(h); i := SYSTEM.VAL(LONGINT, h) +BEGIN + HugeInt(h); + IF ~Platform.LittleEndian THEN + SYSTEM.GET(SYSTEM.ADR(h) + SIZE(HUGEINT) - SIZE(LONGINT), i) + ELSE + SYSTEM.GET(SYSTEM.ADR(h), i) + END END LongInt; PROCEDURE Line*(VAR line: ARRAY OF CHAR); diff --git a/src/runtime/Math.Mod b/src/runtime/Math.Mod index 0d1d61f5..89707f0f 100644 --- a/src/runtime/Math.Mod +++ b/src/runtime/Math.Mod @@ -1,6 +1,6 @@ MODULE Math; -IMPORT SYSTEM; +IMPORT SYSTEM, Platform; (* Math - Oakwood REAL Mathematics. Adapted from OOC LowReal.Mod and RealMath.Mod @@ -768,7 +768,14 @@ BEGIN END fcmp; PROCEDURE ToREAL(h: HUGEINT): REAL; -BEGIN RETURN SYSTEM.VAL(REAL, h) + VAR r: REAL; +BEGIN + IF ~Platform.LittleEndian THEN + SYSTEM.GET(SYSTEM.ADR(h) + SIZE(HUGEINT) - SIZE(REAL), r) + ELSE + SYSTEM.GET(SYSTEM.ADR(h), r) + END; + RETURN r END ToREAL; BEGIN diff --git a/src/runtime/MathL.Mod b/src/runtime/MathL.Mod index b1448dc0..4c1e57a7 100644 --- a/src/runtime/MathL.Mod +++ b/src/runtime/MathL.Mod @@ -78,7 +78,7 @@ MODULE MathL; the status flags for mode control. *) -IMPORT Math, SYSTEM; +IMPORT Math, Platform, SYSTEM; CONST pi* = 3.1415926535897932384626433832795028841972D0; @@ -146,12 +146,17 @@ PROCEDURE exponent*(x: LONGREAL): INTEGER; that lies between `expoMin' and `expoMax'. An exception shall occur and may be raised if `x' is equal to 0.0. *) - VAR i: SYSTEM.INT64; + VAR i: SYSTEM.INT64; r: INTEGER; BEGIN IF x = ZERO THEN RETURN 0 (* NOTE: x=0.0 should raise exception *) ELSE i := SYSTEM.LSH(SYSTEM.VAL(SYSTEM.INT64, x), -52) MOD 2048; - RETURN SYSTEM.VAL(INTEGER, i) - 1023 + IF ~Platform.LittleEndian THEN + SYSTEM.GET(SYSTEM.ADR(i) + SIZE(HUGEINT) - SIZE(INTEGER), r) + ELSE + SYSTEM.GET(SYSTEM.ADR(i), r) + END; + RETURN r - 1023 END END exponent; diff --git a/src/runtime/Modules.Mod b/src/runtime/Modules.Mod index cf398304..c0ce21cf 100644 --- a/src/runtime/Modules.Mod +++ b/src/runtime/Modules.Mod @@ -37,7 +37,7 @@ MODULE Modules; (* jt 6.1.96 *) as the C main program. *) BEGIN MainStackFrame := argvadr; - ArgCount := SYSTEM.VAL(INTEGER, argc); + ArgCount := SHORT(argc); SYSTEM.GET(argvadr, ArgVector); InitHeap; (* Initialse heap variables needed for compiler generated *__inits *) diff --git a/src/runtime/Reals.Mod b/src/runtime/Reals.Mod index f9e6617b..20053f8a 100644 --- a/src/runtime/Reals.Mod +++ b/src/runtime/Reals.Mod @@ -1,8 +1,19 @@ MODULE Reals; (* JT, 5.2.90 / RC 9.12.91 conversion between reals and strings for HP-700, MB 9.12.91, JT for Ofront, 16.3. 95*) (* DCWB 20160817 Made independent of INTEGER size *) + (* Endian-neutral: exponent byte offsets are set at module initialisation *) + + IMPORT SYSTEM, Platform; + + VAR + (* Byte offsets within a REAL/LONGREAL for the two exponent-carrying bytes. + expHi: contains sign(1) + exponent MSBs + expLo: contains exponent LSB(s) + fraction MSBs + Little-endian: REAL expHi=3 expLo=2 / LONGREAL expHi=7 expLo=6 + Big-endian: REAL expHi=0 expLo=1 / LONGREAL expHi=0 expLo=1 *) + realExpHi, realExpLo: INTEGER; + lrealExpHi, lrealExpLo: INTEGER; - IMPORT SYSTEM; PROCEDURE Ten*(e: INTEGER): REAL; VAR r, power: LONGREAL; @@ -29,47 +40,52 @@ MODULE Reals; END TenL; - (* Real number format (IEEE 754) + (* IEEE 754 exponent layout (MSB-first bit numbering): + REAL bit 31=sign, bits 30-23=exponent(8), bits 22-0=fraction(23) + LONGREAL bit 63=sign, bits 62-52=exponent(11), bits 51-0=fraction(52) - TYPE REAL - Single precision / binary32: - 1/sign, 8/exponent, 23/significand + expHi byte: sign(1) | exponent[MSBs] + expLo byte: exponent[LSBs] | fraction[MSBs] - TYPE LONGREAL - Double precision / binary64: - 1/sign, 11/exponent, 52/significand - - exponent: - stored as exponent value + 127. - - significand (fraction): - excludes leading (most significant) bit which is assumed to be 1. - *) + REAL: exponent = (ORD(expHi) * 2 + ORD(expLo) DIV 128) MOD 256 + LONGREAL: exponent = (ORD(expHi) * 16 + ORD(expLo) DIV 16 ) MOD 2048 *) PROCEDURE Expo*(x: REAL): INTEGER; - VAR i: INTEGER; + VAR hi, lo: CHAR; BEGIN - SYSTEM.GET(SYSTEM.ADR(x)+2, i); - RETURN (i DIV 128) MOD 256 + SYSTEM.GET(SYSTEM.ADR(x) + realExpHi, hi); + SYSTEM.GET(SYSTEM.ADR(x) + realExpLo, lo); + RETURN (ORD(hi) * 2 + ORD(lo) DIV 128) MOD 256 END Expo; PROCEDURE SetExpo*(VAR x: REAL; ex: INTEGER); - VAR c: CHAR; + VAR c: CHAR; BEGIN - (* Replace exponent bits within top byte of REAL *) - SYSTEM.GET(SYSTEM.ADR(x)+3, c); - SYSTEM.PUT(SYSTEM.ADR(x)+3, CHR(((ORD(c) DIV 128) * 128) + ((ex DIV 2) MOD 128))); - (* Replace exponent bits within 2nd byte of REAL *) - SYSTEM.GET(SYSTEM.ADR(x)+2, c); - SYSTEM.PUT(SYSTEM.ADR(x)+2, CHR((ORD(c) MOD 128) + ((ex MOD 2) * 128))) + SYSTEM.GET(SYSTEM.ADR(x) + realExpHi, c); + SYSTEM.PUT(SYSTEM.ADR(x) + realExpHi, CHR((ORD(c) DIV 128) * 128 + (ex DIV 2) MOD 128)); + SYSTEM.GET(SYSTEM.ADR(x) + realExpLo, c); + SYSTEM.PUT(SYSTEM.ADR(x) + realExpLo, CHR( ORD(c) MOD 128 + (ex MOD 2) * 128)) END SetExpo; PROCEDURE ExpoL*(x: LONGREAL): INTEGER; - VAR i: INTEGER; + VAR hi, lo: CHAR; BEGIN - SYSTEM.GET(SYSTEM.ADR(x)+6, i); - RETURN (i DIV 16) MOD 2048 + SYSTEM.GET(SYSTEM.ADR(x) + lrealExpHi, hi); + SYSTEM.GET(SYSTEM.ADR(x) + lrealExpLo, lo); + RETURN (ORD(hi) * 16 + ORD(lo) DIV 16) MOD 2048 END ExpoL; + PROCEDURE SetExpoL*(VAR x: LONGREAL; ex: INTEGER); + VAR c: CHAR; + BEGIN + SYSTEM.GET(SYSTEM.ADR(x) + lrealExpHi, c); + SYSTEM.PUT(SYSTEM.ADR(x) + lrealExpHi, CHR((ORD(c) DIV 128) * 128 + (ex DIV 16) MOD 128)); + SYSTEM.GET(SYSTEM.ADR(x) + lrealExpLo, c); + SYSTEM.PUT(SYSTEM.ADR(x) + lrealExpLo, CHR((ex MOD 16) * 16 + ORD(c) MOD 16)) + END SetExpoL; + + (* Convert LONGREAL: Write positive integer value of x into array d. The value is stored backwards, i.e. least significant digit first. n digits are written, with trailing zeros fill. @@ -112,14 +128,17 @@ MODULE Reals; END ToHex; PROCEDURE BytesToHex(VAR b, d: ARRAY OF SYSTEM.BYTE); - VAR i: INTEGER; l: LONGINT; by: CHAR; + VAR i, j, len: INTEGER; by: CHAR; BEGIN - i := 0; l := LEN(b); - WHILE i < l DO + len := SHORT(LEN(b)); + IF Platform.LittleEndian THEN i := 0 ELSE i := len - 1 END; + j := 0; + WHILE (i >= 0) & (i < len) DO by := SYSTEM.VAL(CHAR, b[i]); - d[i*2] := ToHex(ORD(by) DIV 16); - d[i*2+1] := ToHex(ORD(by) MOD 16); - INC(i) + d[j*2] := ToHex(ORD(by) DIV 16); + d[j*2+1] := ToHex(ORD(by) MOD 16); + INC(j); + IF Platform.LittleEndian THEN INC(i) ELSE DEC(i) END END END BytesToHex; @@ -133,4 +152,18 @@ MODULE Reals; BEGIN BytesToHex(x, d) END ConvertHL; + + PROCEDURE InitEndian; + BEGIN + IF Platform.LittleEndian THEN + realExpHi := 3; realExpLo := 2; + lrealExpHi := 7; lrealExpLo := 6 + ELSE + realExpHi := 0; realExpLo := 1; + lrealExpHi := 0; lrealExpLo := 1 + END + END InitEndian; + +BEGIN + InitEndian END Reals. diff --git a/src/test/confidence/out/outtest.mod b/src/test/confidence/out/outtest.mod index aa1997cb..45be1564 100644 --- a/src/test/confidence/out/outtest.mod +++ b/src/test/confidence/out/outtest.mod @@ -1,6 +1,6 @@ MODULE outtest; -IMPORT Out, SYSTEM; +IMPORT Out, Platform, SYSTEM; VAR r: REAL; @@ -13,13 +13,15 @@ PROCEDURE wi(i: HUGEINT); BEGIN Out.Int(i,1) END wi; PROCEDURE wl; BEGIN Out.Ln END wl; PROCEDURE wh(VAR h: ARRAY OF SYSTEM.BYTE); - VAR i: INTEGER; b: SYSTEM.INT8; + VAR i, len: INTEGER; b: SYSTEM.INT8; BEGIN - i := SHORT(LEN(h)); - WHILE i > 0 DO - DEC(i); b := SYSTEM.VAL(SYSTEM.INT8, h[i]); + len := SHORT(LEN(h)); + IF Platform.LittleEndian THEN i := len - 1 ELSE i := 0 END; + WHILE (i >= 0) & (i < len) DO + b := SYSTEM.VAL(SYSTEM.INT8, h[i]); IF b DIV 16 MOD 16 < 10 THEN wc(CHR(b DIV 16 MOD 16 + 48)) ELSE wc(CHR(b DIV 16 MOD 16 + 55)) END; IF b MOD 16 < 10 THEN wc(CHR(b MOD 16 + 48)) ELSE wc(CHR(b MOD 16 + 55)) END; + IF Platform.LittleEndian THEN DEC(i) ELSE INC(i) END END END wh; diff --git a/src/tools/make/configure.c b/src/tools/make/configure.c index 6089d1fc..ad999660 100644 --- a/src/tools/make/configure.c +++ b/src/tools/make/configure.c @@ -362,8 +362,7 @@ void testSystemDotH() { if (((sizeof(rec2)==65) == (sizeof(rec0)==1)) && ((sizeof(rec2)-64) != sizeof(rec0))) printf("error: unsupported record layout sizeof(rec0) = %lu sizeof(rec2) = %lu\n", (long)sizeof(rec0), (long)sizeof(rec2)); - x = 1; - assert(*(char*)&x == 1, "C compiler does not store multibyte numeric values in little-endian order."); + /* byte-order check removed: voc supports both little-endian and big-endian platforms */ } diff --git a/src/tools/make/oberon.mk b/src/tools/make/oberon.mk index d68cc09b..1090d5e6 100644 --- a/src/tools/make/oberon.mk +++ b/src/tools/make/oberon.mk @@ -133,8 +133,8 @@ translate: browsercmd: @printf '\nMaking symbol browser\n' - @cd $(BUILDDIR); "$(ROOTDIR)/$(OBECOMP)" -Ss -O$(MODEL) ../../src/runtime/Oberon.Mod - @cd $(BUILDDIR); "$(ROOTDIR)/$(OBECOMP)" -Sm -O$(MODEL) ../../src/tools/browser/BrowserCmd.Mod + @cd $(BUILDDIR); "$(ROOTDIR)/$(OBECOMP)" -Ss -A$(ADRSIZE)$(ALIGNMENT) -O$(MODEL) ../../src/runtime/Oberon.Mod + @cd $(BUILDDIR); "$(ROOTDIR)/$(OBECOMP)" -Sm -A$(ADRSIZE)$(ALIGNMENT) -O$(MODEL) ../../src/tools/browser/BrowserCmd.Mod @cd $(BUILDDIR); $(COMPILE) BrowserCmd.c Oberon.c -o showdef \ Platform.o Texts.o OPT.o Heap.o Out.o SYSTEM.o OPM.o OPS.o OPV.o \ Files.o Reals.o Modules.o VT100.o Configuration.o Strings.o \