Browse Source

Removed end-of-line whitespace in all modules

git-svn-id: https://svn-dept.inf.ethz.ch/svn/lecturers/a2/trunk@8731 8c9fc860-2736-0410-a75d-ab315db34111
negelef 6 years ago
parent
commit
38473b9849
100 changed files with 1628 additions and 1631 deletions
  1. 2 2
      source/ACPI.Timer.Mod
  2. 1 1
      source/AMD64.EFIMachine.Mod
  3. 16 16
      source/AMD64.FoxArrayBaseOptimized.Mod
  4. 16 16
      source/ARM.Builtins.Mod
  5. 1 1
      source/ARM.FPE64.Mod
  6. 10 10
      source/ARM.Machine.Mod
  7. 1 1
      source/ARM.MathL.Mod
  8. 1 1
      source/ARM.Network.Mod
  9. 7 7
      source/ARM.Objects.Mod
  10. 1 1
      source/ARM.Traps.Mod
  11. 14 14
      source/ARM.UsbEhci.Mod
  12. 31 31
      source/ARM.UsbHidDriver.Mod
  13. 1 1
      source/ARM.UsbMouse.Mod
  14. 29 29
      source/ARM.UsbVarTdAlloc.Mod
  15. 1 1
      source/ARM.Usbdi.Mod
  16. 49 49
      source/ASN1.Mod
  17. 1 1
      source/AcStreamVideoOut.Mod
  18. 17 17
      source/Activities.Mod
  19. 68 68
      source/AdaptiveHuffman.Mod
  20. 63 63
      source/BB.StdCoder.Mod
  21. 2 2
      source/BIOS.ACPI.Mod
  22. 4 4
      source/BIOS.AMD64.Machine.Mod
  23. 2 2
      source/BIOS.ATADisks.Mod
  24. 1 1
      source/BIOS.Clock.Mod
  25. 9 9
      source/BIOS.I386.Machine.Mod
  26. 3 3
      source/BIOS.I386.Traps.Mod
  27. 6 6
      source/BIOS.MemCache.Mod
  28. 8 8
      source/BIOS.Objects.Mod
  29. 10 10
      source/BIOS.PCI.Mod
  30. 24 24
      source/BIOS.WebNetworkTimeProtocol.Mod
  31. 2 2
      source/BSplineCurves.Mod
  32. 2 2
      source/BenchTCP.Mod
  33. 1 1
      source/BitSets.Mod
  34. 52 52
      source/BorrowsWheeler.Mod
  35. 5 5
      source/CPU.Mod
  36. 4 4
      source/CRC.Mod
  37. 18 18
      source/Checksum.Mod
  38. 4 4
      source/Clock.Mod
  39. 1 1
      source/Commands.Mod
  40. 19 19
      source/Compiler.Mod
  41. 1 1
      source/ComplexNumbers.Mod
  42. 6 6
      source/ComponentViewer.Mod
  43. 3 3
      source/Coop.ARM.Machine.Mod
  44. 1 1
      source/Coop.Kernel.Mod
  45. 3 3
      source/Coop.Machine.Mod
  46. 8 8
      source/Coop.Objects.Mod
  47. 1 1
      source/Coop.Windows.Display.Mod
  48. 19 19
      source/Coop.Windows.I386.Kernel32.Mod
  49. 20 20
      source/CryptoAES.Mod
  50. 0 1
      source/CryptoARC4.Mod
  51. 39 39
      source/CryptoBase64.Mod
  52. 17 17
      source/CryptoBigNumbers.Mod
  53. 17 17
      source/CryptoBlowfish.Mod
  54. 5 5
      source/CryptoCAST.Mod
  55. 12 12
      source/CryptoCSPRNG.Mod
  56. 1 1
      source/CryptoCiphers.Mod
  57. 67 67
      source/CryptoDES.Mod
  58. 26 26
      source/CryptoDES3.Mod
  59. 3 3
      source/CryptoDiffieHellman.Mod
  60. 40 40
      source/CryptoKeccakF1600.Mod
  61. 20 20
      source/CryptoKeccakSponge.Mod
  62. 8 8
      source/CryptoMD5.Mod
  63. 1 1
      source/CryptoPrimes.Mod
  64. 3 3
      source/CryptoRSA.Mod
  65. 11 11
      source/CryptoSHA1.Mod
  66. 23 23
      source/CryptoSHA256.Mod
  67. 8 8
      source/CryptoSHA3.Mod
  68. 43 43
      source/CryptoTestCiphers.Mod
  69. 1 1
      source/CryptoTestDH.Mod
  70. 17 17
      source/CryptoTestHashes.Mod
  71. 1 1
      source/CryptoTools.Mod
  72. 15 15
      source/CryptoTwofish.Mod
  73. 18 18
      source/CryptoUtils.Mod
  74. 1 1
      source/DTPData.Mod
  75. 61 61
      source/Darwin.Unix.Mod
  76. 0 1
      source/DataErrors.Mod
  77. 2 2
      source/Dates.Mod
  78. 14 14
      source/Debugging.Mod
  79. 6 6
      source/DiskCaches.Mod
  80. 16 16
      source/DiskFS.Mod
  81. 1 1
      source/Displays.Mod
  82. 51 51
      source/Drand48.Mod
  83. 15 15
      source/EFI.AMD64.Machine.Mod
  84. 18 18
      source/EFI.I386.Machine.Mod
  85. 3 3
      source/EFI.Mod
  86. 4 4
      source/EFIGraphicalConsole.Mod
  87. 2 2
      source/EFILib.Mod
  88. 0 1
      source/ExampleTextWriter.Mod
  89. 3 3
      source/Files.Mod
  90. 19 19
      source/FoxAMD64Assembler.Mod
  91. 127 127
      source/FoxAMD64InstructionSet.Mod
  92. 53 53
      source/FoxAMDBackend.Mod
  93. 12 12
      source/FoxARMAssembler.Mod
  94. 60 60
      source/FoxARMBackend.Mod
  95. 21 21
      source/FoxARMInstructionSet.Mod
  96. 2 2
      source/FoxActiveCells.Mod
  97. 148 148
      source/FoxArrayBase.Mod
  98. 1 1
      source/FoxAssembler.Mod
  99. 4 4
      source/FoxBackend.Mod
  100. 19 19
      source/FoxBasic.Mod

+ 2 - 2
source/ACPI.Timer.Mod

@@ -16,13 +16,13 @@ CODE
 END GetInstructionTimer;
 END GetInstructionTimer;
 
 
 PROCEDURE GetCounter- (): Counter;
 PROCEDURE GetCounter- (): Counter;
-BEGIN {UNCOOPERATIVE, UNCHECKED} 
+BEGIN {UNCOOPERATIVE, UNCHECKED}
 	IF counter = NIL THEN RETURN  SHORT(GetInstructionTimer() DIV (1024*1024));  (* return millions of instructions *) END;
 	IF counter = NIL THEN RETURN  SHORT(GetInstructionTimer() DIV (1024*1024));  (* return millions of instructions *) END;
 	ASSERT (counter # NIL); RETURN SHORT (counter.value);
 	ASSERT (counter # NIL); RETURN SHORT (counter.value);
 END GetCounter;
 END GetCounter;
 
 
 PROCEDURE GetFrequency- (): Counter;
 PROCEDURE GetFrequency- (): Counter;
-BEGIN {UNCOOPERATIVE, UNCHECKED} 
+BEGIN {UNCOOPERATIVE, UNCHECKED}
 	IF counter = NIL THEN RETURN 1024 (* giga instructions as a rough guess *) END;
 	IF counter = NIL THEN RETURN 1024 (* giga instructions as a rough guess *) END;
 	RETURN frequency;
 	RETURN frequency;
 END GetFrequency;
 END GetFrequency;

+ 1 - 1
source/AMD64.EFIMachine.Mod

@@ -18,7 +18,7 @@ CODE {SYSTEM.AMD64, SYSTEM.Privileged}
 	MOV RAX, [RBP+rax]; btAddr
 	MOV RAX, [RBP+rax]; btAddr
 	MOV RCX, [RBP+rcx];
 	MOV RCX, [RBP+rcx];
 	MOV RDX, [RBP+rdx];
 	MOV RDX, [RBP+rdx];
-	
+
 	MOV RBX, [RBP+adr]
 	MOV RBX, [RBP+adr]
 	CALL RBX
 	CALL RBX
 
 

+ 16 - 16
source/AMD64.FoxArrayBaseOptimized.Mod

@@ -1460,7 +1460,7 @@ VAR
 		JMP	singlepieces	;
 		JMP	singlepieces	;
 		endL:
 		endL:
 	END AddARARLoopSSE;
 	END AddARARLoopSSE;
-	
+
 (* *)
 (* *)
 	PROCEDURE SubAXAXLoopA( ladr, radr, dadr: ADDRESS; linc, rinc, dinc, len: SIZE );
 	PROCEDURE SubAXAXLoopA( ladr, radr, dadr: ADDRESS; linc, rinc, dinc, len: SIZE );
 	CODE {SYSTEM.AMD64, SYSTEM.FPU}
 	CODE {SYSTEM.AMD64, SYSTEM.FPU}
@@ -1798,7 +1798,7 @@ VAR
 		JMP	singlepieces	;
 		JMP	singlepieces	;
 		endL:
 		endL:
 	END SubARARLoopSSE;
 	END SubARARLoopSSE;
-	
+
 	(* *)
 	(* *)
 	PROCEDURE EMulAXAXLoopA( ladr, radr, dadr: ADDRESS; linc, rinc, dinc, len: SIZE );
 	PROCEDURE EMulAXAXLoopA( ladr, radr, dadr: ADDRESS; linc, rinc, dinc, len: SIZE );
 	CODE {SYSTEM.AMD64, SYSTEM.FPU}
 	CODE {SYSTEM.AMD64, SYSTEM.FPU}
@@ -6375,7 +6375,7 @@ VAR
 		END;
 		END;
 	END MatMulR;
 	END MatMulR;
 
 
-	PROCEDURE MatMulX( matrixA, matrixB, matrixC: ADDRESS; 
+	PROCEDURE MatMulX( matrixA, matrixB, matrixC: ADDRESS;
 		IncA, StrideA, IncB, StrideB, IncC, StrideC, RowsA, ColsA, RowsB, ColsB: SIZE ): BOOLEAN;
 		IncA, StrideA, IncB, StrideB, IncC, StrideC, RowsA, ColsA, RowsB, ColsB: SIZE ): BOOLEAN;
 	VAR M, N, K: SIZE;
 	VAR M, N, K: SIZE;
 	BEGIN
 	BEGIN
@@ -6502,7 +6502,7 @@ VAR
 		END;
 		END;
 	END MatMulIncX;
 	END MatMulIncX;
 
 
-	PROCEDURE MatMulARARBlocked( matrixA, matrixB, matrixC: ADDRESS; 
+	PROCEDURE MatMulARARBlocked( matrixA, matrixB, matrixC: ADDRESS;
 		IncA, StrideA, IncB, StrideB, IncC, StrideC, RowsA, ColsA, RowsB, ColsB: SIZE;
 		IncA, StrideA, IncB, StrideB, IncC, StrideC, RowsA, ColsA, RowsB, ColsB: SIZE;
 															 add: BOOLEAN ): BOOLEAN;
 															 add: BOOLEAN ): BOOLEAN;
 	VAR M, N, K, L2M, L2N, L2K: SIZE;
 	VAR M, N, K, L2M, L2N, L2K: SIZE;
@@ -6616,7 +6616,7 @@ VAR
 															 ColsB, TRUE )
 															 ColsB, TRUE )
 	END MatMulIncRTransposed;
 	END MatMulIncRTransposed;
 
 
-	PROCEDURE MatMulXSSEStride( matrixA, matrixB, matrixC: ADDRESS; 
+	PROCEDURE MatMulXSSEStride( matrixA, matrixB, matrixC: ADDRESS;
 		IncA, StrideA, IncB, StrideB, IncC, StrideC, RowsA, ColsA, RowsB, ColsB: SIZE ): BOOLEAN;
 		IncA, StrideA, IncB, StrideB, IncC, StrideC, RowsA, ColsA, RowsB, ColsB: SIZE ): BOOLEAN;
 	BEGIN
 	BEGIN
 		RETURN MatMulAXAXSSEStride( matrixA, matrixB, matrixC,
 		RETURN MatMulAXAXSSEStride( matrixA, matrixB, matrixC,
@@ -7054,7 +7054,7 @@ VAR
 
 
 		MOVLPS [RCX], XMM0
 		MOVLPS [RCX], XMM0
 	END MatVecMulR2x2;
 	END MatVecMulR2x2;
-	
+
 	(* PH *)
 	(* PH *)
 	(* to do: use MOVAPS when Felix fixes issues with alignment *)
 	(* to do: use MOVAPS when Felix fixes issues with alignment *)
 	PROCEDURE MatVecMulR4x4(dadr, ladr, radr: ADDRESS);
 	PROCEDURE MatVecMulR4x4(dadr, ladr, radr: ADDRESS);
@@ -7068,15 +7068,15 @@ VAR
 		MOVUPS XMM2, [RAX+16] ; XMM2 := [a10,a11,a12,a13]
 		MOVUPS XMM2, [RAX+16] ; XMM2 := [a10,a11,a12,a13]
 		MOVUPS XMM3, [RAX+32] ; XMM3 := [a20,a21,a22,a23]
 		MOVUPS XMM3, [RAX+32] ; XMM3 := [a20,a21,a22,a23]
 		MOVUPS XMM4, [RAX+48] ; XMM4 := [a30,a31,a32,a33]
 		MOVUPS XMM4, [RAX+48] ; XMM4 := [a30,a31,a32,a33]
-		MULPS XMM1, XMM0 
-		MULPS XMM2, XMM0 
-		HADDPS XMM1, XMM2	; adjacent pairs are horizontally  added  
-		
-		MULPS XMM3, XMM0 
-		MULPS XMM4, XMM0 
-		HADDPS XMM3, XMM4	; adjacent pairs are horizontally  added  
-		
-		HADDPS XMM1, XMM3	; adjacent pairs are horizontally  added 
+		MULPS XMM1, XMM0
+		MULPS XMM2, XMM0
+		HADDPS XMM1, XMM2	; adjacent pairs are horizontally  added
+
+		MULPS XMM3, XMM0
+		MULPS XMM4, XMM0
+		HADDPS XMM3, XMM4	; adjacent pairs are horizontally  added
+
+		HADDPS XMM1, XMM3	; adjacent pairs are horizontally  added
 		MOVUPS [RCX], XMM1
 		MOVUPS [RCX], XMM1
 	END MatVecMulR4x4;
 	END MatVecMulR4x4;
 
 
@@ -7179,7 +7179,7 @@ VAR
 			ArrayBase.matVecMulR4x4 := MatVecMulR4x4;
 			ArrayBase.matVecMulR4x4 := MatVecMulR4x4;
 		END;
 		END;
 	END InstallSSE3;
 	END InstallSSE3;
-	
+
 	PROCEDURE Install*;
 	PROCEDURE Install*;
 	BEGIN
 	BEGIN
 		KernelLog.String( "ArrayBaseOptimized: installing runtime library optimizations:" );
 		KernelLog.String( "ArrayBaseOptimized: installing runtime library optimizations:" );

+ 16 - 16
source/ARM.Builtins.Mod

@@ -16,7 +16,7 @@ TYPE
 	DoubleWord = RECORD
 	DoubleWord = RECORD
 		low*: UNSIGNED32; high*: SIGNED32;
 		low*: UNSIGNED32; high*: SIGNED32;
 	END;
 	END;
-		
+
 	PROCEDURE DivS8*(left, right: SHORTINT): SHORTINT;
 	PROCEDURE DivS8*(left, right: SHORTINT): SHORTINT;
 	VAR result, dummy: LONGINT;
 	VAR result, dummy: LONGINT;
 	BEGIN {UNCOOPERATIVE, UNCHECKED} DivModS32(left, right, result, dummy); RETURN SHORTINT(result)
 	BEGIN {UNCOOPERATIVE, UNCHECKED} DivModS32(left, right, result, dummy); RETURN SHORTINT(result)
@@ -105,7 +105,7 @@ TYPE
 	PROCEDURE RorS64*(source: HUGEINT; amount: ULONGINT): HUGEINT;
 	PROCEDURE RorS64*(source: HUGEINT; amount: ULONGINT): HUGEINT;
 	BEGIN {UNCOOPERATIVE, UNCHECKED} RETURN RolS64(source, 64 - (amount MOD 64))
 	BEGIN {UNCOOPERATIVE, UNCHECKED} RETURN RolS64(source, 64 - (amount MOD 64))
 	END RorS64;
 	END RorS64;
-	
+
 	PROCEDURE RorU64*(source: HUGEINT; amount: ULONGINT): HUGEINT;
 	PROCEDURE RorU64*(source: HUGEINT; amount: ULONGINT): HUGEINT;
 	BEGIN {UNCOOPERATIVE, UNCHECKED} RETURN RolS64(source, 64 - (amount MOD 64))
 	BEGIN {UNCOOPERATIVE, UNCHECKED} RETURN RolS64(source, 64 - (amount MOD 64))
 	END RorU64;
 	END RorU64;
@@ -143,7 +143,7 @@ TYPE
 		CMP R0, R1
 		CMP R0, R1
 		BEQ Equal
 		BEQ Equal
 		BLS Exit ; nothing to do than setting quotient to 0 and remainder to dividend (R0)
 		BLS Exit ; nothing to do than setting quotient to 0 and remainder to dividend (R0)
-	
+
 		CLZ R3, R0 ; R3 := clz(dividend)
 		CLZ R3, R0 ; R3 := clz(dividend)
 		CLZ R4, R1 ; R4 := clz(divisor)
 		CLZ R4, R1 ; R4 := clz(divisor)
 
 
@@ -159,13 +159,13 @@ TYPE
 		BPL Loop
 		BPL Loop
 
 
 		; R0 holds the remainder
 		; R0 holds the remainder
-		
+
 		B Exit
 		B Exit
-		
+
 	Equal:
 	Equal:
 		MOV R2, #1
 		MOV R2, #1
 		MOV R0, #0
 		MOV R0, #0
-		
+
 	Exit:
 	Exit:
 		LDR R1, [FP,#quotient] ; R1 := address of quotient
 		LDR R1, [FP,#quotient] ; R1 := address of quotient
 		LDR R3, [FP,#remainder] ; R3 := address of remainder
 		LDR R3, [FP,#remainder] ; R3 := address of remainder
@@ -309,7 +309,7 @@ TYPE
 		END ;
 		END ;
 		RETURN x
 		RETURN x
 	END AddF32;
 	END AddF32;
-	
+
 	(* only called when no FPU64 is available *)
 	(* only called when no FPU64 is available *)
 	PROCEDURE AddF64*(x,y: FLOAT64): FLOAT64;
 	PROCEDURE AddF64*(x,y: FLOAT64): FLOAT64;
 	VAR z: FLOAT64;
 	VAR z: FLOAT64;
@@ -390,7 +390,7 @@ TYPE
 	(* stub in order to make the runtime itself compile, cf next procedure. This module needs to be compiled with FPU support on *)
 	(* stub in order to make the runtime itself compile, cf next procedure. This module needs to be compiled with FPU support on *)
 	PROCEDURE ConvF64U32*(x: UNSIGNED32): FLOAT64;
 	PROCEDURE ConvF64U32*(x: UNSIGNED32): FLOAT64;
 	BEGIN {UNCOOPERATIVE, UNCHECKED}
 	BEGIN {UNCOOPERATIVE, UNCHECKED}
-		HALT(100); 
+		HALT(100);
 	END ConvF64U32;
 	END ConvF64U32;
 
 
 	(* if an FPU64 is available, the result must be made available via FPU register *)
 	(* if an FPU64 is available, the result must be made available via FPU register *)
@@ -419,13 +419,13 @@ TYPE
 	BEGIN {UNCOOPERATIVE, UNCHECKED}
 	BEGIN {UNCOOPERATIVE, UNCHECKED}
 		RETURN ConvF32S32(LONGINT(x))
 		RETURN ConvF32S32(LONGINT(x))
 	END ConvF32S16;
 	END ConvF32S16;
-	
+
 	(* only called when no FPU32 is available *)
 	(* only called when no FPU32 is available *)
 	PROCEDURE ConvF32S8*(x: SHORTINT): FLOAT32;
 	PROCEDURE ConvF32S8*(x: SHORTINT): FLOAT32;
 	BEGIN {UNCOOPERATIVE, UNCHECKED}
 	BEGIN {UNCOOPERATIVE, UNCHECKED}
 		RETURN ConvF32S16(INTEGER(x))
 		RETURN ConvF32S16(INTEGER(x))
 	END ConvF32S8;
 	END ConvF32S8;
-	
+
 	(* only called when no FPU64 is available *)
 	(* only called when no FPU64 is available *)
 	PROCEDURE ConvF64S8*(x: SHORTINT): FLOAT64;
 	PROCEDURE ConvF64S8*(x: SHORTINT): FLOAT64;
 	BEGIN {UNCOOPERATIVE, UNCHECKED}
 	BEGIN {UNCOOPERATIVE, UNCHECKED}
@@ -449,9 +449,9 @@ TYPE
 			x := (x MOD C + C) * 20H;
 			x := (x MOD C + C) * 20H;
 			y := (y MOD C + C) * 20H;
 			y := (y MOD C + C) * 20H;
 			xe := xe + ye - B; (* exponent with bias *)
 			xe := xe + ye - B; (* exponent with bias *)
-			
+
 			SYSTEM.MULD(ye, x, y); (* note that this implicitly changes zh *)
 			SYSTEM.MULD(ye, x, y); (* note that this implicitly changes zh *)
-			
+
 			IF zh >= 4*C THEN
 			IF zh >= 4*C THEN
 				x := (zh+2) DIV 4;
 				x := (zh+2) DIV 4;
 				INC(xe);
 				INC(xe);
@@ -468,7 +468,7 @@ TYPE
 		END ;
 		END ;
 		RETURN x
 		RETURN x
 	END MulF32;
 	END MulF32;
-	
+
 	(* only called when no FPU32 is available *)
 	(* only called when no FPU32 is available *)
 	PROCEDURE DivF32*(x, y: FLOAT32): FLOAT32;
 	PROCEDURE DivF32*(x, y: FLOAT32): FLOAT32;
 	VAR xe, ye, q, s: LONGINT;
 	VAR xe, ye, q, s: LONGINT;
@@ -524,7 +524,7 @@ TYPE
 		END ;
 		END ;
 		RETURN x
 		RETURN x
 	END ConvS32F32;
 	END ConvS32F32;
-	
+
 	(** converts an integer into a float, ignores the non-integer part
 	(** converts an integer into a float, ignores the non-integer part
 	- corresponds to REAL(int)
 	- corresponds to REAL(int)
 	- note that no rounding occurs
 	- note that no rounding occurs
@@ -559,9 +559,9 @@ TYPE
 	(* stub in order to make the runtime itself compile, cf next procedure. This module needs to be compiled with FPU support on *)
 	(* stub in order to make the runtime itself compile, cf next procedure. This module needs to be compiled with FPU support on *)
 	PROCEDURE ConvF32U32*(x: UNSIGNED32): FLOAT32;
 	PROCEDURE ConvF32U32*(x: UNSIGNED32): FLOAT32;
 	BEGIN {UNCOOPERATIVE, UNCHECKED}
 	BEGIN {UNCOOPERATIVE, UNCHECKED}
-		HALT(100); 
+		HALT(100);
 	END ConvF32U32;
 	END ConvF32U32;
-	
+
 	(* if an FPU32 is available, the result must be made available via FPU register *)
 	(* if an FPU32 is available, the result must be made available via FPU register *)
 	PROCEDURE ConvF32S64F*(x: DoubleWord): REAL;
 	PROCEDURE ConvF32S64F*(x: DoubleWord): REAL;
 	VAR l,h:REAL;
 	VAR l,h:REAL;

+ 1 - 1
source/ARM.FPE64.Mod

@@ -9,7 +9,7 @@ MODULE FPE64;
 		Float64* = RECORD
 		Float64* = RECORD
 			low*, high*: LONGINT
 			low*, high*: LONGINT
 		END;
 		END;
-		
+
 		Float32* = LONGINT;
 		Float32* = LONGINT;
 
 
 	PROCEDURE Addd(VAR x1, x0: LONGINT; y1, y0: LONGINT);
 	PROCEDURE Addd(VAR x1, x0: LONGINT; y1, y0: LONGINT);

+ 10 - 10
source/ARM.Machine.Mod

@@ -14,7 +14,7 @@ CONST
 
 
 	(* Interrupts Dummy Test *)
 	(* Interrupts Dummy Test *)
 	DummyTest = FALSE;
 	DummyTest = FALSE;
-	
+
 	(* Lock levels *)
 	(* Lock levels *)
 	TraceOutput* = 0;
 	TraceOutput* = 0;
 	Memory* = 1;
 	Memory* = 1;
@@ -211,7 +211,7 @@ TYPE
 	CacheRefs = POINTER {UNSAFE,UNTRACED} TO ARRAY MaxCacheRefSize OF SHORTINT;
 	CacheRefs = POINTER {UNSAFE,UNTRACED} TO ARRAY MaxCacheRefSize OF SHORTINT;
 VAR
 VAR
 	version -: ARRAY 64 OF CHAR;
 	version -: ARRAY 64 OF CHAR;
-	
+
 	sp, fp: ADDRESS;
 	sp, fp: ADDRESS;
 
 
 	(** Interrupt Mask *)
 	(** Interrupt Mask *)
@@ -502,7 +502,7 @@ VAR
 		ISB
 		ISB
 		MOV R0, #0x40000000;
 		MOV R0, #0x40000000;
 		VMSR FPEXC, R0;
 		VMSR FPEXC, R0;
-		
+
 		VMRS R0, FPSCR
 		VMRS R0, FPSCR
 		BIC R0, R0, #0x0c00000 ; round to nearest as the default
 		BIC R0, R0, #0x0c00000 ; round to nearest as the default
 		; remark: if we put round to minus infinity as the default, we can spare quite some instructions in emission of ENTIER
 		; remark: if we put round to minus infinity as the default, we can spare quite some instructions in emission of ENTIER
@@ -1378,7 +1378,7 @@ VAR
 		ADD R0, R0, #8
 		ADD R0, R0, #8
 		VST1 D15, R0
 		VST1 D15, R0
 		ADD R0, R0, #8
 		ADD R0, R0, #8
-		
+
 		VSTR D16, R0, #0
 		VSTR D16, R0, #0
 		ADD R0, R0, #8
 		ADD R0, R0, #8
 		VSTR D17, R0, #0
 		VSTR D17, R0, #0
@@ -2287,7 +2287,7 @@ VAR
 	BEGIN	(* {interrupts off} *)
 	BEGIN	(* {interrupts off} *)
 		timer(ID(), state);
 		timer(ID(), state);
 		SYSTEM.PUT32(Platform.PrivateTimerInterruptStatusRegister, 1);
 		SYSTEM.PUT32(Platform.PrivateTimerInterruptStatusRegister, 1);
-		
+
 		(* Shutdown if requested *)
 		(* Shutdown if requested *)
 		IF ~(ID() IN allProcessors) THEN ShutdownSecondary END;
 		IF ~(ID() IN allProcessors) THEN ShutdownSecondary END;
 		IF enableWatchdog THEN PrivateWatchdog.Feed(Second) END;
 		IF enableWatchdog THEN PrivateWatchdog.Feed(Second) END;
@@ -2531,7 +2531,7 @@ VAR
 		CMP	R2, #0
 		CMP	R2, #0
 		BNE	loop
 		BNE	loop
 	END AtomicInc;
 	END AtomicInc;
-	
+
 	(* Atomic INC(x) *)
 	(* Atomic INC(x) *)
 	PROCEDURE -AtomicDec*(VAR x: LONGINT);
 	PROCEDURE -AtomicDec*(VAR x: LONGINT);
 	CODE
 	CODE
@@ -3076,7 +3076,7 @@ VAR
 			END
 			END
 		ELSE
 		ELSE
 			Acquire(TraceOutput);
 			Acquire(TraceOutput);
-			Trace.StringLn("Address not in stack");Trace.Address(virtAdr); 
+			Trace.StringLn("Address not in stack");Trace.Address(virtAdr);
 			Release(TraceOutput);
 			Release(TraceOutput);
 			ok := FALSE
 			ok := FALSE
 		END;
 		END;
@@ -3118,7 +3118,7 @@ VAR
 		s.adr := s.high - InitStackSize;	(* at the top of the virtual area *)
 		s.adr := s.high - InitStackSize;	(* at the top of the virtual area *)
 		initSP := s.high;
 		initSP := s.high;
 		b := AllocatePage(s.adr, FullAccess, flags); (* allocate one physical page first *)
 		b := AllocatePage(s.adr, FullAccess, flags); (* allocate one physical page first *)
-		
+
 		ASSERT(b);
 		ASSERT(b);
 		FlushDCacheRange(sysSecondLvlPtStart, sysSecondLvlPtStop - sysSecondLvlPtStart);
 		FlushDCacheRange(sysSecondLvlPtStart, sysSecondLvlPtStop - sysSecondLvlPtStart);
 		Release(Memory)
 		Release(Memory)
@@ -3595,10 +3595,10 @@ VAR
 		InitLocks;
 		InitLocks;
 		InitGlobalTimer
 		InitGlobalTimer
 	END Init;
 	END Init;
-	
+
 	PROCEDURE {INITIAL} Initial;
 	PROCEDURE {INITIAL} Initial;
 	BEGIN
 	BEGIN
 		Init;
 		Init;
 	END Initial;
 	END Initial;
-	
+
 END Machine.
 END Machine.

+ 1 - 1
source/ARM.MathL.Mod

@@ -18,7 +18,7 @@ VAR
 	y: Flt; h: HUGEINT;
 	y: Flt; h: HUGEINT;
 BEGIN
 BEGIN
 	y := SYSTEM.VAL(Flt, x);
 	y := SYSTEM.VAL(Flt, x);
-	h := y[0] + LSH(SYSTEM.VAL(HUGEINT, SYSTEM.VAL(SET, y[1])*{0..19}), 32); 
+	h := y[0] + LSH(SYSTEM.VAL(HUGEINT, SYSTEM.VAL(SET, y[1])*{0..19}), 32);
 	RETURN h;
 	RETURN h;
 END Mantissa;
 END Mantissa;
 
 

+ 1 - 1
source/ARM.Network.Mod

@@ -262,7 +262,7 @@ TYPE
 			ELSE
 			ELSE
 				KernelLog.String("Registered NON ARP receiver"); KernelLog.Ln
 				KernelLog.String("Registered NON ARP receiver"); KernelLog.Ln
 			END;
 			END;
-			
+
 			(* exists the type already? *)
 			(* exists the type already? *)
 			typeItem := typeList;
 			typeItem := typeList;
 			WHILE (typeItem # NIL) & (typeItem^.type # type) DO
 			WHILE (typeItem # NIL) & (typeItem^.type # type) DO

+ 7 - 7
source/ARM.Objects.Mod

@@ -43,7 +43,7 @@ CONST
 
 
 	AddressSize = SIZEOF(ADDRESS);
 	AddressSize = SIZEOF(ADDRESS);
 	ReturnStackDisplacement = 2 * AddressSize;
 	ReturnStackDisplacement = 2 * AddressSize;
-	
+
 TYPE
 TYPE
 	CpuCyclesArray* = ARRAY Machine.MaxCPU OF HUGEINT;
 	CpuCyclesArray* = ARRAY Machine.MaxCPU OF HUGEINT;
 
 
@@ -128,7 +128,7 @@ TYPE
 							Trace.String("[Objects.FindRoots sp=0]")
 							Trace.String("[Objects.FindRoots sp=0]")
 						END
 						END
 					END;
 					END;
-					
+
 					IF TraceProcessHook # NIL THEN
 					IF TraceProcessHook # NIL THEN
 						bp := state.BP; pc := state.PC; sp := state.SP;
 						bp := state.BP; pc := state.PC; sp := state.SP;
 						TraceProcessHook(SELF,pc,bp,sp,stack.high);
 						TraceProcessHook(SELF,pc,bp,sp,stack.high);
@@ -180,7 +180,7 @@ TYPE
 			END
 			END
 
 
 		END FindRoots;
 		END FindRoots;
-		
+
 		(*!TODO: adapt the code according to the new Modules/Reflection *)
 		(*!TODO: adapt the code according to the new Modules/Reflection *)
 		PROCEDURE FindPointers(bp, pc : ADDRESS; VAR diff0, diff1: SIZE);
 		PROCEDURE FindPointers(bp, pc : ADDRESS; VAR diff0, diff1: SIZE);
 		(*VAR data: Modules.ProcTableEntry; startIndex, i: LONGINT; ptr : ADDRESS; success: BOOLEAN;
 		(*VAR data: Modules.ProcTableEntry; startIndex, i: LONGINT; ptr : ADDRESS; success: BOOLEAN;
@@ -835,16 +835,16 @@ BEGIN
 			processingIRQ[state.INT-MinIRQ] := TRUE;
 			processingIRQ[state.INT-MinIRQ] := TRUE;
 		END;
 		END;
 	END;
 	END;
-	
+
 	(* if the reenabling of interrupts cannot be circumvented, then it is REQUIRED to acknowledge interrupts
 	(* if the reenabling of interrupts cannot be circumvented, then it is REQUIRED to acknowledge interrupts
 		BEFORE reenabling. Otherwise spurious IRQs cannot be identified as such.
 		BEFORE reenabling. Otherwise spurious IRQs cannot be identified as such.
 		Please note that this particular problem with spurious IRQs cannot observed on many machines but IF it is observed
 		Please note that this particular problem with spurious IRQs cannot observed on many machines but IF it is observed
 		then the machine will behave unexpected. Very hard to debug and trace!
 		then the machine will behave unexpected. Very hard to debug and trace!
 
 
-		Machine.Ack(state.INT); 
+		Machine.Ack(state.INT);
 		Machine.Sti ();	(* avoid Processors.StopAll deadlock when waiting for locks below (remove this) *)
 		Machine.Sti ();	(* avoid Processors.StopAll deadlock when waiting for locks below (remove this) *)
 	*)
 	*)
-	
+
 	Machine.Acquire(Machine.Objects);
 	Machine.Acquire(Machine.Objects);
 	(*IF state.INT = 53 THEN Trace.String("|") END;*)
 	(*IF state.INT = 53 THEN Trace.String("|") END;*)
 	t := interrupt[state.INT-MinIRQ].process;
 	t := interrupt[state.INT-MinIRQ].process;
@@ -1153,7 +1153,7 @@ BEGIN
 END TerminateThis;
 END TerminateThis;
 
 
 (* called by WMProcessInfo to obtain the current state of a running process *)
 (* called by WMProcessInfo to obtain the current state of a running process *)
-PROCEDURE UpdateProcessState*( p: Process );	
+PROCEDURE UpdateProcessState*( p: Process );
 BEGIN
 BEGIN
 	(*  update p.stat.{PC,BP,SP}  *)
 	(*  update p.stat.{PC,BP,SP}  *)
 END UpdateProcessState;
 END UpdateProcessState;

+ 1 - 1
source/ARM.Traps.Mod

@@ -96,7 +96,7 @@ CONST
 	ExceptionRaisedDesc = "exception";
 	ExceptionRaisedDesc = "exception";
 	ProcessResurrectedDesc = "process resurrected";
 	ProcessResurrectedDesc = "process resurrected";
 	RecursiveExclusiveDesc = "recursive entrance in EXCLUSIVE section";
 	RecursiveExclusiveDesc = "recursive entrance in EXCLUSIVE section";
-	AwaitOutsideExclusiveDesc = "AWAIT statement outside EXCLUSIVE section";	
+	AwaitOutsideExclusiveDesc = "AWAIT statement outside EXCLUSIVE section";
 
 
 TYPE
 TYPE
 	Variable* = RECORD	(** variable descriptor *)
 	Variable* = RECORD	(** variable descriptor *)

+ 14 - 14
source/ARM.UsbEhci.Mod

@@ -569,7 +569,7 @@ TYPE
 			*)
 			*)
 			ASSERT(pipe.descriptors[0] # 0);
 			ASSERT(pipe.descriptors[0] # 0);
 			qh := pipe.descriptors[0];
 			qh := pipe.descriptors[0];
-			
+
 			(* Queue Head Horizontal Link Pointer is not set here *)
 			(* Queue Head Horizontal Link Pointer is not set here *)
 			(* Queue Head Endpoint Capabilities 1 *)
 			(* Queue Head Endpoint Capabilities 1 *)
 			nakRL := 3;
 			nakRL := 3;
@@ -1159,8 +1159,8 @@ TYPE
 			(*Machine.FlushDCacheRange(ADDRESSOF(buffer[0]), bufferLen);*)
 			(*Machine.FlushDCacheRange(ADDRESSOF(buffer[0]), bufferLen);*)
 			(* pipe.tdBase = pipe.descriptors[0] + 32 in UsbHcdi *)
 			(* pipe.tdBase = pipe.descriptors[0] + 32 in UsbHcdi *)
 (*			pipe.firstTD := pipe.tdBase;
 (*			pipe.firstTD := pipe.tdBase;
-			ASSERT(pipe.firstTD = pipe.descriptors[0] + alignQh); 
-*)			
+			ASSERT(pipe.firstTD = pipe.descriptors[0] + alignQh);
+*)
 			pipe.firstTD := pipe.tdBase - 32 + alignQh;
 			pipe.firstTD := pipe.tdBase - 32 + alignQh;
 			AssertAlignment(pipe.firstTD, alignQtd);
 			AssertAlignment(pipe.firstTD, alignQtd);
 			ASSERT(SYSTEM.VAL(SET, pipe.firstTD) * {0..4} = {}); (* qTDs must be 32byte aligned *)
 			ASSERT(SYSTEM.VAL(SET, pipe.firstTD) * {0..4} = {}); (* qTDs must be 32byte aligned *)
@@ -1273,10 +1273,10 @@ TYPE
 			Machine.FlushDCacheRange(ADDRESSOF(buffer[offset]), bufferLen);
 			Machine.FlushDCacheRange(ADDRESSOF(buffer[offset]), bufferLen);
 			SYSTEM.PUT32(pipe.descriptors[0] + QhCurrentQtdPointer, 0);
 			SYSTEM.PUT32(pipe.descriptors[0] + QhCurrentQtdPointer, 0);
 (*			pipe.firstTD := pipe.tdBase;
 (*			pipe.firstTD := pipe.tdBase;
-			ASSERT(pipe.firstTD = pipe.descriptors[0] + alignQh); 
+			ASSERT(pipe.firstTD = pipe.descriptors[0] + alignQh);
 *)
 *)
 			pipe.firstTD :=  pipe.tdBase - 32 + alignQh;
 			pipe.firstTD :=  pipe.tdBase - 32 + alignQh;
-			
+
 			AssertAlignment(pipe.firstTD, alignQtd);
 			AssertAlignment(pipe.firstTD, alignQtd);
 			ASSERT(pipe.firstTD MOD alignQtd = 0);
 			ASSERT(pipe.firstTD MOD alignQtd = 0);
 			ASSERT(SYSTEM.VAL(SET, pipe.firstTD) * {0..4} = {}); (* qTDs must be 32byte aligned *)
 			ASSERT(SYSTEM.VAL(SET, pipe.firstTD) * {0..4} = {}); (* qTDs must be 32byte aligned *)
@@ -1440,7 +1440,7 @@ TYPE
 				SYSTEM.PUT32(qtd + QtdExtBufferPtr4, 0);*)
 				SYSTEM.PUT32(qtd + QtdExtBufferPtr4, 0);*)
 			END;
 			END;
 			(*Machine.FlushDCacheRange(curr, sizeQtd);*)
 			(*Machine.FlushDCacheRange(curr, sizeQtd);*)
-	
+
 			(* Setup phase always starts with dataToggle = FALSE, so now it must be TRUE *)
 			(* Setup phase always starts with dataToggle = FALSE, so now it must be TRUE *)
 			pipe.dataToggle := TRUE;
 			pipe.dataToggle := TRUE;
 
 
@@ -1949,7 +1949,7 @@ TYPE
 				(* The HC hasn't yet executed the transaction *)
 				(* The HC hasn't yet executed the transaction *)
 				RETURN
 				RETURN
 			END;*)
 			END;*)
-			(*! 
+			(*!
 				Disabling scheduling here leads to problems: some of the transfers does not get finished!
 				Disabling scheduling here leads to problems: some of the transfers does not get finished!
 			*)
 			*)
 			(*REPEAT UNTIL (SYSTEM.VAL(SET, qh.token) * TdActive = {}) OR (SYSTEM.GET32(iobase + HcAsyncListAddr) # qh);*)
 			(*REPEAT UNTIL (SYSTEM.VAL(SET, qh.token) * TdActive = {}) OR (SYSTEM.GET32(iobase + HcAsyncListAddr) # qh);*)
@@ -2509,16 +2509,16 @@ TYPE
 	  	 *)
 	  	 *)
 		PROCEDURE Start * ():BOOLEAN;
 		PROCEDURE Start * ():BOOLEAN;
 		VAR dword : SET;
 		VAR dword : SET;
-		TYPE 
+		TYPE
 			IRQPoller = OBJECT (* support polling i/o IRQ -- for testing *)
 			IRQPoller = OBJECT (* support polling i/o IRQ -- for testing *)
 				VAR handler: PROCEDURE {DELEGATE}; timer: Kernel.Timer;
 				VAR handler: PROCEDURE {DELEGATE}; timer: Kernel.Timer;
-				
+
 				PROCEDURE & Init* (h: PROCEDURE {DELEGATE});
 				PROCEDURE & Init* (h: PROCEDURE {DELEGATE});
 				BEGIN
 				BEGIN
 					handler := h;
 					handler := h;
-					NEW(timer); 
+					NEW(timer);
 				END Init;
 				END Init;
-				
+
 			BEGIN{ACTIVE}
 			BEGIN{ACTIVE}
 				LOOP
 				LOOP
 					handler();
 					handler();
@@ -2529,7 +2529,7 @@ TYPE
 		BEGIN
 		BEGIN
 			IF Debug.Trace & Debug.traceInit THEN KernelLog.String("UsbEhci: Starting host controller... "); KernelLog.Ln; END;
 			IF Debug.Trace & Debug.traceInit THEN KernelLog.String("UsbEhci: Starting host controller... "); KernelLog.Ln; END;
 			(* Enable Interrupts *)
 			(* Enable Interrupts *)
-			
+
 			IF Polling THEN
 			IF Polling THEN
 				NEW(is, InterruptHandler)
 				NEW(is, InterruptHandler)
 			ELSE
 			ELSE
@@ -2538,7 +2538,7 @@ TYPE
 
 
 			(* Clear interrupts *)
 			(* Clear interrupts *)
 			SYSTEM.PUT32(iobase + HcUsbSts, 0);
 			SYSTEM.PUT32(iobase + HcUsbSts, 0);
-			
+
 			(* Enable all interrupts except the frame list rollover interrupt *)
 			(* Enable all interrupts except the frame list rollover interrupt *)
 			dword := SYSTEM.VAL(SET, SYSTEM.GET32(iobase + HcUsbIntr));
 			dword := SYSTEM.VAL(SET, SYSTEM.GET32(iobase + HcUsbIntr));
 			interruptsEnabled := dword + {0..5}  - StsFrameListRollover;
 			interruptsEnabled := dword + {0..5}  - StsFrameListRollover;
@@ -2829,7 +2829,7 @@ BEGIN
 		next := sgList[idx].adr + size
 		next := sgList[idx].adr + size
 	END;
 	END;
 	RETURN next
 	RETURN next
-END AdvancePhysBuf;	
+END AdvancePhysBuf;
 
 
 PROCEDURE Indent(spaces : LONGINT);
 PROCEDURE Indent(spaces : LONGINT);
 VAR i : LONGINT;
 VAR i : LONGINT;

+ 31 - 31
source/ARM.UsbHidDriver.Mod

@@ -47,8 +47,8 @@ CONST
 	MouseSpeed = 50;
 	MouseSpeed = 50;
 	MouseWheelSpeed = 3;
 	MouseWheelSpeed = 3;
 	MouseAcceleration = 0;
 	MouseAcceleration = 0;
-	
-	
+
+
 
 
 TYPE
 TYPE
 
 
@@ -74,7 +74,7 @@ TYPE
 		prevx, prevy: LONGINT;
 		prevx, prevy: LONGINT;
 		prevkeys: SET;
 		prevkeys: SET;
 		prevTip: BOOLEAN;
 		prevTip: BOOLEAN;
-		tipTime: LONGINT; 
+		tipTime: LONGINT;
 	END;
 	END;
 
 
 	(*Handling keyboard devices*)
 	(*Handling keyboard devices*)
@@ -428,7 +428,7 @@ TYPE
 		consumerState			: ConsumerState;
 		consumerState			: ConsumerState;
 		joystickState			: JoystickState;
 		joystickState			: JoystickState;
 		useReportIDMechanism	: BOOLEAN;
 		useReportIDMechanism	: BOOLEAN;
-		
+
 		recentStatus: Usbdi.Status;
 		recentStatus: Usbdi.Status;
 
 
 		(*
 		(*
@@ -533,7 +533,7 @@ TYPE
 			RETURN TRUE;
 			RETURN TRUE;
 		END Connect;
 		END Connect;
 
 
-		
+
 
 
 		(*called when detaching a usb hid device*)
 		(*called when detaching a usb hid device*)
 		PROCEDURE Disconnect;
 		PROCEDURE Disconnect;
@@ -680,22 +680,22 @@ TYPE
 		BEGIN
 		BEGIN
 			RETURN touchscreenState # NIL
 			RETURN touchscreenState # NIL
 		END IsTouchscreen;
 		END IsTouchscreen;
-		
+
 		PROCEDURE GetPipeStatus*(): Usbdi.Status;
 		PROCEDURE GetPipeStatus*(): Usbdi.Status;
 		VAR len: LONGINT;
 		VAR len: LONGINT;
 		BEGIN
 		BEGIN
-			IF pipe # NIL THEN RETURN pipe.GetStatus(len) 
+			IF pipe # NIL THEN RETURN pipe.GetStatus(len)
 			ELSE RETURN Usbdi.Error
 			ELSE RETURN Usbdi.Error
 			END;
 			END;
 		END GetPipeStatus;
 		END GetPipeStatus;
-		
-		
+
+
 		PROCEDURE GetRecentStatus*(): Usbdi.Status;
 		PROCEDURE GetRecentStatus*(): Usbdi.Status;
 		BEGIN
 		BEGIN
 			RETURN recentStatus;
 			RETURN recentStatus;
 		END GetRecentStatus;
 		END GetRecentStatus;
-		
-		
+
+
 		(**
 		(**
 		 * Is called by handleHidEvent when mouse device is found
 		 * Is called by handleHidEvent when mouse device is found
 		 *)
 		 *)
@@ -743,38 +743,38 @@ TYPE
 		PROCEDURE HandleTouchscreenDriver;
 		PROCEDURE HandleTouchscreenDriver;
 		VAR
 		VAR
 			mm : 			Inputs.AbsMouseMsg;
 			mm : 			Inputs.AbsMouseMsg;
-			x,y: LONGINT; 
+			x,y: LONGINT;
 			displayWidth, displayHeight: LONGINT;
 			displayWidth, displayHeight: LONGINT;
 		BEGIN
 		BEGIN
-			getDisplayDimensions(displayWidth, displayHeight); 
+			getDisplayDimensions(displayWidth, displayHeight);
 			x := (touchscreenState.x.usageValue-touchscreenState.minX) * displayWidth DIV (touchscreenState.maxX-touchscreenState.minX +1);
 			x := (touchscreenState.x.usageValue-touchscreenState.minX) * displayWidth DIV (touchscreenState.maxX-touchscreenState.minX +1);
 			y := (touchscreenState.y.usageValue-touchscreenState.minY) * displayHeight DIV  (touchscreenState.maxY -touchscreenState.minY + 1);
 			y := (touchscreenState.y.usageValue-touchscreenState.minY) * displayHeight DIV  (touchscreenState.maxY -touchscreenState.minY + 1);
-			
+
 			(*
 			(*
 			TRACE(touchscreenState.inRange.usageValue);
 			TRACE(touchscreenState.inRange.usageValue);
-			IF touchscreenState.confidence # NIL THEN 
+			IF touchscreenState.confidence # NIL THEN
 				TRACE(touchscreenState.confidence.usageValue);
 				TRACE(touchscreenState.confidence.usageValue);
 			END;
 			END;
 			*)
 			*)
-			
-			IF (touchscreenState.tipSwitch.usageValue#0) THEN 
+
+			IF (touchscreenState.tipSwitch.usageValue#0) THEN
 				IF (touchConfidenceDelay#0) & ~touchscreenState.prevTip THEN
 				IF (touchConfidenceDelay#0) & ~touchscreenState.prevTip THEN
 					touchscreenState.tipTime := Kernel.GetTicks();
 					touchscreenState.tipTime := Kernel.GetTicks();
 					touchscreenState.prevTip := TRUE
 					touchscreenState.prevTip := TRUE
 				ELSIF (touchConfidenceDelay =0) OR (Kernel.GetTicks()-touchscreenState.tipTime > touchConfidenceDelay) THEN
 				ELSIF (touchConfidenceDelay =0) OR (Kernel.GetTicks()-touchscreenState.tipTime > touchConfidenceDelay) THEN
-					mm.keys := mm.keys + {0}; 
+					mm.keys := mm.keys + {0};
 				END
 				END
 			ELSE
 			ELSE
 				touchscreenState.prevTip := FALSE;
 				touchscreenState.prevTip := FALSE;
 			END;
 			END;
-			
-			
+
+
 			mm.x := x; mm.y := y;
 			mm.x := x; mm.y := y;
 
 
 			IF ~(0 IN mm.keys) THEN (* up event  *)
 			IF ~(0 IN mm.keys) THEN (* up event  *)
 				touchscreenState.prev := FALSE;
 				touchscreenState.prev := FALSE;
-				(* 
-					There are touchscreen devices that report a (0,0) coordinate with up-events. 
+				(*
+					There are touchscreen devices that report a (0,0) coordinate with up-events.
 					This does not work well together with an external mouse.
 					This does not work well together with an external mouse.
 					We keep the coordinate for the time being -- with the side effect that there may be a pointer-over status after a touchscreen click
 					We keep the coordinate for the time being -- with the side effect that there may be a pointer-over status after a touchscreen click
 				*)
 				*)
@@ -1222,13 +1222,13 @@ TYPE
 				touchscreenState.maxY := temp.logicalMaximum;
 				touchscreenState.maxY := temp.logicalMaximum;
 				touchscreenState.tipSwitch := reportManager.GetUsage(0DH, 042H, mouseCollection,temp);
 				touchscreenState.tipSwitch := reportManager.GetUsage(0DH, 042H, mouseCollection,temp);
 				touchscreenState.inRange := reportManager.GetUsage(0DH, 032H, mouseCollection,temp);
 				touchscreenState.inRange := reportManager.GetUsage(0DH, 032H, mouseCollection,temp);
-				touchscreenState.confidence := reportManager.GetUsage(0DH, 047H, mouseCollection, temp); 
+				touchscreenState.confidence := reportManager.GetUsage(0DH, 047H, mouseCollection, temp);
 				KernelLog.String("Touchscreen device registered with ");
 				KernelLog.String("Touchscreen device registered with ");
-				KernelLog.String("minX = "); KernelLog.Int(touchscreenState.minX,1); 
-				KernelLog.String(", maxX = "); KernelLog.Int(touchscreenState.maxX,1); 
-				KernelLog.String(", minY = "); KernelLog.Int(touchscreenState.minY,1); 
-				KernelLog.String(", maxY = "); KernelLog.Int(touchscreenState.maxY,1); 
-				IF touchscreenState.confidence # NIL THEN KernelLog.String(", confidence"); END; 
+				KernelLog.String("minX = "); KernelLog.Int(touchscreenState.minX,1);
+				KernelLog.String(", maxX = "); KernelLog.Int(touchscreenState.maxX,1);
+				KernelLog.String(", minY = "); KernelLog.Int(touchscreenState.minY,1);
+				KernelLog.String(", maxY = "); KernelLog.Int(touchscreenState.maxY,1);
+				IF touchscreenState.confidence # NIL THEN KernelLog.String(", confidence"); END;
 				KernelLog.Ln;
 				KernelLog.Ln;
 				RETURN TRUE;
 				RETURN TRUE;
 			ELSE
 			ELSE
@@ -1570,7 +1570,7 @@ END Cleanup;
 PROCEDURE Install*;
 PROCEDURE Install*;
 END Install;
 END Install;
 
 
-TYPE 
+TYPE
 	DimensionGetter= PROCEDURE {DELEGATE} (VAR w,h: LONGINT);
 	DimensionGetter= PROCEDURE {DELEGATE} (VAR w,h: LONGINT);
 VAR
 VAR
 	getDisplayDimensions: DimensionGetter;
 	getDisplayDimensions: DimensionGetter;
@@ -1585,7 +1585,7 @@ PROCEDURE InstallDisplayDimensions*(poller: DimensionGetter); (* for touchscreen
 BEGIN
 BEGIN
 	IF poller # NIL THEN
 	IF poller # NIL THEN
 		getDisplayDimensions := poller;
 		getDisplayDimensions := poller;
-	ELSE 
+	ELSE
 		getDisplayDimensions := DefaultDisplayDimensions;
 		getDisplayDimensions := DefaultDisplayDimensions;
 	END;
 	END;
 END InstallDisplayDimensions;
 END InstallDisplayDimensions;
@@ -1599,7 +1599,7 @@ BEGIN
 	IF s[0] # 0X THEN
 	IF s[0] # 0X THEN
 		p := 0;  touchConfidenceDelay := Machine.StrToInt(p, s)
 		p := 0;  touchConfidenceDelay := Machine.StrToInt(p, s)
 	ELSE
 	ELSE
-		touchConfidenceDelay := 0; 
+		touchConfidenceDelay := 0;
 	END;
 	END;
 	Usbdi.drivers.Add(Probe, Name, Description, 10);
 	Usbdi.drivers.Add(Probe, Name, Description, 10);
 END Setup;
 END Setup;

+ 1 - 1
source/ARM.UsbMouse.Mod

@@ -140,4 +140,4 @@ BEGIN
 	Usbdi.drivers.Add(Probe, Name, Description, 10)
 	Usbdi.drivers.Add(Probe, Name, Description, 10)
 END UsbMouse.
 END UsbMouse.
 
 
-UsbMouse.Install ~  System.Free UsbMouse ~ 
+UsbMouse.Install ~  System.Free UsbMouse ~

+ 29 - 29
source/ARM.UsbVarTdAlloc.Mod

@@ -36,7 +36,7 @@ TYPE
 		BEGIN
 		BEGIN
 			INCL(used[block DIV SetSize], block MOD SetSize);
 			INCL(used[block DIV SetSize], block MOD SetSize);
 		END SetUsed;
 		END SetUsed;
-		
+
 		(* faster version of SetUsed for blocks
 		(* faster version of SetUsed for blocks
 		PROCEDURE SetUsedR(from, to: LONGINT);
 		PROCEDURE SetUsedR(from, to: LONGINT);
 		VAR startSet, stopSet, startBit, stopBit: LONGINT;
 		VAR startSet, stopSet, startBit, stopBit: LONGINT;
@@ -51,7 +51,7 @@ TYPE
 				INC(startSet);
 				INC(startSet);
 				WHILE startSet < stopSet DO
 				WHILE startSet < stopSet DO
 					used[startSet] := {MIN(SET)..MAX(SET)};
 					used[startSet] := {MIN(SET)..MAX(SET)};
-					INC(startSet); 
+					INC(startSet);
 				END;
 				END;
 				used[stopSet] := used[stopSet] + {MIN(SET) .. stopBit};
 				used[stopSet] := used[stopSet] + {MIN(SET) .. stopBit};
 			ELSE
 			ELSE
@@ -59,7 +59,7 @@ TYPE
 			END;
 			END;
 		END SetUsedR;
 		END SetUsedR;
 		*)
 		*)
-				
+
 		PROCEDURE SetFree(block: LONGINT);
 		PROCEDURE SetFree(block: LONGINT);
 		BEGIN
 		BEGIN
 			EXCL(used[block DIV SetSize], block MOD SetSize);
 			EXCL(used[block DIV SetSize], block MOD SetSize);
@@ -79,7 +79,7 @@ TYPE
 				INC(startSet);
 				INC(startSet);
 				WHILE startSet < stopSet DO
 				WHILE startSet < stopSet DO
 					used[startSet] := {};
 					used[startSet] := {};
-					INC(startSet); 
+					INC(startSet);
 				END;
 				END;
 				used[stopSet] := used[stopSet] - {MIN(SET) .. stopBit};
 				used[stopSet] := used[stopSet] - {MIN(SET) .. stopBit};
 			ELSE
 			ELSE
@@ -87,16 +87,16 @@ TYPE
 			END;
 			END;
 		END SetFreeR;
 		END SetFreeR;
 		*)
 		*)
-		
+
 
 
 	END TdBuffer;
 	END TdBuffer;
 
 
 	(**
 	(**
 		Allocator.
 		Allocator.
-		
+
 		The allocator is created with a page size and a block size. It can then allocate memory blocks with a granularity of the block size.
 		The allocator is created with a page size and a block size. It can then allocate memory blocks with a granularity of the block size.
 		Each allocated block is guaranteed not to cross a page boundary.
 		Each allocated block is guaranteed not to cross a page boundary.
-		
+
 		Allocated blocks must be freed manually.
 		Allocated blocks must be freed manually.
 	*)
 	*)
 	CONST SetSize = SIZEOF(SET) * 8;
 	CONST SetSize = SIZEOF(SET) * 8;
@@ -121,7 +121,7 @@ TYPE
 			buf: TdBuffer;
 			buf: TdBuffer;
 			start, pos, count: LONGINT;
 			start, pos, count: LONGINT;
 			adr: ADDRESS;
 			adr: ADDRESS;
-			
+
 			(** Allocate a new TD buffer and mark as used the last 32-byte block before a 4kB page boundary. *)
 			(** Allocate a new TD buffer and mark as used the last 32-byte block before a 4kB page boundary. *)
 			PROCEDURE AllocateBuffer;
 			PROCEDURE AllocateBuffer;
 			VAR
 			VAR
@@ -147,17 +147,17 @@ TYPE
 				LOOP
 				LOOP
 					IF count >= AllocSize DIV blockSize THEN EXIT END;
 					IF count >= AllocSize DIV blockSize THEN EXIT END;
 					IF (ADDRESSOF(buf.buffer[buf.ofs + count * blockSize]) MOD pageSize) = pageSize - blockSize THEN
 					IF (ADDRESSOF(buf.buffer[buf.ofs + count * blockSize]) MOD pageSize) = pageSize - blockSize THEN
-						buf.SetUsed(count); 
+						buf.SetUsed(count);
 					END;
 					END;
 					INC(count)
 					INC(count)
 				END;
 				END;
 			END AllocateBuffer;
 			END AllocateBuffer;
 
 
-			
+
 		BEGIN {EXCLUSIVE}
 		BEGIN {EXCLUSIVE}
 			ASSERT(size MOD blockSize = 0);
 			ASSERT(size MOD blockSize = 0);
 			size := size DIV blockSize;
 			size := size DIV blockSize;
-			
+
 			buf := tdBuffers;
 			buf := tdBuffers;
 			LOOP
 			LOOP
 				IF buf = NIL THEN
 				IF buf = NIL THEN
@@ -167,35 +167,35 @@ TYPE
 				END;
 				END;
 				count := 0;
 				count := 0;
 				pos := 0;
 				pos := 0;
-				start := pos;  
+				start := pos;
 				WHILE (count < size) & (pos < bitmaskSize) DO
 				WHILE (count < size) & (pos < bitmaskSize) DO
 					IF buf.Used(pos) THEN
 					IF buf.Used(pos) THEN
-						count := 0; 
+						count := 0;
 						start := pos + 1;
 						start := pos + 1;
 					ELSE
 					ELSE
 						INC(count);
 						INC(count);
 					END;
 					END;
-					INC(pos); 
-				END; 
+					INC(pos);
+				END;
 
 
 				IF count = size THEN EXIT END;
 				IF count = size THEN EXIT END;
 				buf := buf.next
 				buf := buf.next
 			END;
 			END;
-			
+
 			ASSERT(buf # NIL);
 			ASSERT(buf # NIL);
 
 
 			adr := ADDRESSOF(buf.buffer[buf.ofs + start*blockSize]);
 			adr := ADDRESSOF(buf.buffer[buf.ofs + start*blockSize]);
-			
+
 			(* faster version:
 			(* faster version:
 			buf.SetUsedR(start, start+count-1);
 			buf.SetUsedR(start, start+count-1);
 			*)
 			*)
 			WHILE(count > 0) DO
 			WHILE(count > 0) DO
-				ASSERT(~buf.Used(start)); 
-				buf.SetUsed(start); 
-				INC(start); DEC(count); 
+				ASSERT(~buf.Used(start));
+				buf.SetUsed(start);
+				INC(start); DEC(count);
 			END;
 			END;
 			Machine.Fill32(adr, size * blockSize, 0);
 			Machine.Fill32(adr, size * blockSize, 0);
-			RETURN adr; 
+			RETURN adr;
 		END Allocate;
 		END Allocate;
 
 
 		(** Marks a TD as free, so that its memory can be used again *)
 		(** Marks a TD as free, so that its memory can be used again *)
@@ -206,7 +206,7 @@ TYPE
 			slot: LONGINT;
 			slot: LONGINT;
 		BEGIN {EXCLUSIVE}
 		BEGIN {EXCLUSIVE}
 			ASSERT(size MOD blockSize = 0);
 			ASSERT(size MOD blockSize = 0);
-			size := size DIV blockSize; 
+			size := size DIV blockSize;
 
 
 			buf := tdBuffers;
 			buf := tdBuffers;
 			LOOP
 			LOOP
@@ -221,10 +221,10 @@ TYPE
 			(* faster version:
 			(* faster version:
 			buf.SetFreeR(slot, slot+size-1);
 			buf.SetFreeR(slot, slot+size-1);
 			*)
 			*)
-			WHILE (size > 0) DO 
+			WHILE (size > 0) DO
 				ASSERT(buf.Used(slot));
 				ASSERT(buf.Used(slot));
 				buf.SetFree(slot);
 				buf.SetFree(slot);
-				INC(slot); DEC(size); 
+				INC(slot); DEC(size);
 			END;
 			END;
 		END Free;
 		END Free;
 	END Allocator;
 	END Allocator;
@@ -265,12 +265,12 @@ VAR allocator: UsbVarTdAlloc.Allocator; adr: POINTER TO ARRAY OF ADDRESS;
 gen: Random.Generator; i,j, k: LONGINT; size: POINTER TO ARRAY OF SIZE;
 gen: Random.Generator; i,j, k: LONGINT; size: POINTER TO ARRAY OF SIZE;
 BEGIN
 BEGIN
 	NEW(allocator, 4096, 32);
 	NEW(allocator, 4096, 32);
-	NEW(gen); 
+	NEW(gen);
 	NEW(adr, 1024); NEW(size, 1024);
 	NEW(adr, 1024); NEW(size, 1024);
 	FOR j := 0 TO 100 DO
 	FOR j := 0 TO 100 DO
 		FOR i := 0 TO LEN(adr)-1  DO
 		FOR i := 0 TO LEN(adr)-1  DO
 			size[i] := 32+gen.Dice(120)*32;
 			size[i] := 32+gen.Dice(120)*32;
-			adr[i] := allocator.Allocate(size[i]); 
+			adr[i] := allocator.Allocate(size[i]);
 			ASSERT(adr[i] MOD 32 = 0);
 			ASSERT(adr[i] MOD 32 = 0);
 			ASSERT(adr[i] DIV 4096 = (adr[i] + size[i]) DIV 4096);
 			ASSERT(adr[i] DIV 4096 = (adr[i] + size[i]) DIV 4096);
 			FOR k := 0 TO i-1 DO
 			FOR k := 0 TO i-1 DO
@@ -278,14 +278,14 @@ BEGIN
 			END;
 			END;
 		END;
 		END;
 		FOR i := 0 TO LEN(adr)-1 DO
 		FOR i := 0 TO LEN(adr)-1 DO
-			allocator.Free(adr[i], size[i]); 
+			allocator.Free(adr[i], size[i]);
 		END;
 		END;
-		TRACE(j); 
+		TRACE(j);
 	END;
 	END;
 	TRACE("done");
 	TRACE("done");
 END Test;
 END Test;
 
 
-	
+
 
 
 END TestUsbVarTdAlloc.
 END TestUsbVarTdAlloc.
 
 

+ 1 - 1
source/ARM.Usbdi.Mod

@@ -214,7 +214,7 @@ TYPE
 		maxPacketSize* : LONGINT;
 		maxPacketSize* : LONGINT;
 
 
 		mode* : LONGINT;
 		mode* : LONGINT;
-		
+
 		(** Transfer 'bufferLen' bytes from/to the specified buffer, starting at 'offset' *)
 		(** Transfer 'bufferLen' bytes from/to the specified buffer, starting at 'offset' *)
 
 
 		PROCEDURE Transfer*(bufferLen, offset : LONGINT; VAR buffer : Buffer) : Status;
 		PROCEDURE Transfer*(bufferLen, offset : LONGINT; VAR buffer : Buffer) : Status;

+ 49 - 49
source/ASN1.Mod

@@ -21,46 +21,46 @@ ASN1Context*=2;
 ASN1Private*=3;
 ASN1Private*=3;
 
 
 (*
 (*
-BER_TAG_UNKNOWN 0 
-BER_TAG_BOOLEAN 1 
-BER_TAG_INTEGER 2 
-BER_TAG_BIT_STRING 3 
-BER_TAG_OCTET_STRING 4 
-BER_TAG_NULL 5 
-BER_TAG_OID 6 
-BER_TAG_OBJECT_DESCRIPTOR 7 
-BER_TAG_EXTERNAL 8 
-BER_TAG_REAL 9 
+BER_TAG_UNKNOWN 0
+BER_TAG_BOOLEAN 1
+BER_TAG_INTEGER 2
+BER_TAG_BIT_STRING 3
+BER_TAG_OCTET_STRING 4
+BER_TAG_NULL 5
+BER_TAG_OID 6
+BER_TAG_OBJECT_DESCRIPTOR 7
+BER_TAG_EXTERNAL 8
+BER_TAG_REAL 9
 BER_TAG_ENUMERATED 10
 BER_TAG_ENUMERATED 10
-  12 to 15 are reserved for future versions of the recommendation 
+  12 to 15 are reserved for future versions of the recommendation
 BER_TAG_PKIX_UTF8_STRING 12
 BER_TAG_PKIX_UTF8_STRING 12
-BER_TAG_SEQUENCE 16 
+BER_TAG_SEQUENCE 16
 BER_TAG_SET 17
 BER_TAG_SET 17
-BER_TAG_NUMERIC_STRING 18 
-BER_TAG_PRINTABLE_STRING 19 
-BER_TAG_T61_STRING 20 
-BER_TAG_TELETEX_STRING BER_TAG_T61_STRING 
-BER_TAG_VIDEOTEX_STRING 21 
+BER_TAG_NUMERIC_STRING 18
+BER_TAG_PRINTABLE_STRING 19
+BER_TAG_T61_STRING 20
+BER_TAG_TELETEX_STRING BER_TAG_T61_STRING
+BER_TAG_VIDEOTEX_STRING 21
 BER_TAG_IA5_STRING 22
 BER_TAG_IA5_STRING 22
-BER_TAG_UTC_TIME 23 
+BER_TAG_UTC_TIME 23
 BER_TAG_GENERALIZED_TIME 24
 BER_TAG_GENERALIZED_TIME 24
-BER_TAG_GRAPHIC_STRING 25 
-BER_TAG_ISO646_STRING 26 
-BER_TAG_GENERAL_STRING 27 
+BER_TAG_GRAPHIC_STRING 25
+BER_TAG_ISO646_STRING 26
+BER_TAG_GENERAL_STRING 27
 BER_TAG_VISIBLE_STRING BER_TAG_ISO646_STRING
 BER_TAG_VISIBLE_STRING BER_TAG_ISO646_STRING
- 28 - are reserved for future versions of the recommendation 
-BER_TAG_PKIX_UNIVERSAL_STRING 28 
-BER_TAG_PKIX_BMP_STRING 30 
+ 28 - are reserved for future versions of the recommendation
+BER_TAG_PKIX_UNIVERSAL_STRING 28
+BER_TAG_PKIX_BMP_STRING 30
 *)
 *)
 
 
 Boolean* =1H;
 Boolean* =1H;
 Integer* =2H;
 Integer* =2H;
 BitString* =3H;
 BitString* =3H;
 (*
 (*
-BIT STRING: BER encoding. Primitive or constructed. 
-In a primitive encoding, the first contents octet gives the number of bits by which the length of the bit string 
-is less than the next multiple of eight (this is called the "number of unused bits"). 
-The second and following contents octets give the value of the bit string, converted to an octet string. 
+BIT STRING: BER encoding. Primitive or constructed.
+In a primitive encoding, the first contents octet gives the number of bits by which the length of the bit string
+is less than the next multiple of eight (this is called the "number of unused bits").
+The second and following contents octets give the value of the bit string, converted to an octet string.
 The conversion process is as follows:
 The conversion process is as follows:
      1.   The bit string is padded after the last bit with zero to seven bits of any value to make the length
      1.   The bit string is padded after the last bit with zero to seven bits of any value to make the length
           of the bit string a multiple of eight. If the  length of the bit string is a multiple of eight
           of the bit string a multiple of eight. If the  length of the bit string is a multiple of eight
@@ -120,20 +120,20 @@ TYPE Triplet* = OBJECT (* todo: 1 Byte tags are sufficient for certificates, but
 				unusedbits*:LONGINT;
 				unusedbits*:LONGINT;
 				constructed*:BOOLEAN;
 				constructed*:BOOLEAN;
 				definite*: BOOLEAN;
 				definite*: BOOLEAN;
-				
+
 				bvalue*:BOOLEAN;
 				bvalue*:BOOLEAN;
 				ivalue*:LONGINT;
 				ivalue*:LONGINT;
 				svalue*:POINTER TO ARRAY OF CHAR;
 				svalue*:POINTER TO ARRAY OF CHAR;
-				
+
 				child*, curchild:Triplet;
 				child*, curchild:Triplet;
 				next*:Triplet;
 				next*:Triplet;
 				level*:LONGINT; (*pretty print*)
 				level*:LONGINT; (*pretty print*)
-				
+
 			PROCEDURE AppendChild*(t:Triplet);
 			PROCEDURE AppendChild*(t:Triplet);
 			BEGIN
 			BEGIN
 				IF child=NIL THEN child:=t; curchild:=t ELSE curchild.next:=t; curchild:=t; END;
 				IF child=NIL THEN child:=t; curchild:=t ELSE curchild.next:=t; curchild:=t; END;
 			END AppendChild;
 			END AppendChild;
-			
+
 			PROCEDURE Print*(w: Streams.Writer);
 			PROCEDURE Print*(w: Streams.Writer);
 			VAR i:LONGINT;
 			VAR i:LONGINT;
 			BEGIN
 			BEGIN
@@ -141,7 +141,7 @@ TYPE Triplet* = OBJECT (* todo: 1 Byte tags are sufficient for certificates, but
 				FOR i:=0 TO level-1 DO w.String("- "); END;
 				FOR i:=0 TO level-1 DO w.String("- "); END;
 				w.Hex(tag,4); w.String("H[");
 				w.Hex(tag,4); w.String("H[");
 				w.Int(length,0); w.String("]");
 				w.Int(length,0); w.String("]");
-				CASE tag OF 
+				CASE tag OF
 				| Boolean: IF bvalue THEN w.String("true") ELSE w.String("false") END;
 				| Boolean: IF bvalue THEN w.String("true") ELSE w.String("false") END;
 				| Integer: IF length<=4 THEN w.Int(ivalue,0);ELSE PrintHexString(w,svalue^) END;
 				| Integer: IF length<=4 THEN w.Int(ivalue,0);ELSE PrintHexString(w,svalue^) END;
 				| Oid: PrintNumericString(w, svalue^); w.String("  "); PrintHexString(w, svalue^);
 				| Oid: PrintNumericString(w, svalue^); w.String("  "); PrintHexString(w, svalue^);
@@ -149,22 +149,22 @@ TYPE Triplet* = OBJECT (* todo: 1 Byte tags are sufficient for certificates, but
 				| UTCTime: PrintString(w,svalue^);
 				| UTCTime: PrintString(w,svalue^);
 				| BitString: w.Char("("); w.Int(unusedbits,0); w.Char(")"); IF svalue#NIL THEN PrintHexString(w, svalue^) END;
 				| BitString: w.Char("("); w.Int(unusedbits,0); w.Char(")"); IF svalue#NIL THEN PrintHexString(w, svalue^) END;
 				| Sequence, Set:
 				| Sequence, Set:
-				ELSE 
+				ELSE
 					IF svalue#NIL THEN PrintHexString(w,svalue^);END;
 					IF svalue#NIL THEN PrintHexString(w,svalue^);END;
 				END;
 				END;
 				w.Ln;
 				w.Ln;
 			END Print;
 			END Print;
 		END Triplet;
 		END Triplet;
-		
+
 VAR log*: Streams.Writer;
 VAR log*: Streams.Writer;
-		
+
 PROCEDURE PrintHexString*(w:Streams.Writer; CONST s: ARRAY OF CHAR);
 PROCEDURE PrintHexString*(w:Streams.Writer; CONST s: ARRAY OF CHAR);
 CONST hex="0123456789ABCDEF";
 CONST hex="0123456789ABCDEF";
 VAR i:LONGINT; c:CHAR;
 VAR i:LONGINT; c:CHAR;
 BEGIN
 BEGIN
 	FOR i:=0 TO LEN(s)-1 DO
 	FOR i:=0 TO LEN(s)-1 DO
 		c:=s[i];
 		c:=s[i];
-		w.Char(hex[ORD(c) DIV 16]); 
+		w.Char(hex[ORD(c) DIV 16]);
 		w.Char(hex[ORD(c) MOD 16]);
 		w.Char(hex[ORD(c) MOD 16]);
 		w.Char(" ");
 		w.Char(" ");
 	END;
 	END;
@@ -210,7 +210,7 @@ BEGIN
 	IF ORD(c)<128 THEN t.length:=ORD(c); t.definite:=TRUE;
 	IF ORD(c)<128 THEN t.length:=ORD(c); t.definite:=TRUE;
 	ELSIF ORD(c)=128 THEN t.definite:=FALSE;
 	ELSIF ORD(c)=128 THEN t.definite:=FALSE;
 	(* to do: class=0, length=0 is used to encode end of bit stream of undefined length, see ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc*)
 	(* to do: class=0, length=0 is used to encode end of bit stream of undefined length, see ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc*)
-	ELSE 
+	ELSE
 		lengthbytes:= ORD(c) MOD 128; t.definite:=TRUE;
 		lengthbytes:= ORD(c) MOD 128; t.definite:=TRUE;
 		FOR i:=0 TO lengthbytes-1 DO (* read all length bytes here ...*)
 		FOR i:=0 TO lengthbytes-1 DO (* read all length bytes here ...*)
 			t.length:=256*t.length;
 			t.length:=256*t.length;
@@ -220,30 +220,30 @@ BEGIN
 	END;
 	END;
 	CASE t.tag OF
 	CASE t.tag OF
 	| Boolean: reader.Char(c);INC(len); t.bvalue:=c#0X;
 	| Boolean: reader.Char(c);INC(len); t.bvalue:=c#0X;
-	| Integer: 
-		IF t.length<=4 THEN 
-			 NEW(t.svalue,t.length); 
-			 FOR i:=0 TO t.length-1 DO 
+	| Integer:
+		IF t.length<=4 THEN
+			 NEW(t.svalue,t.length);
+			 FOR i:=0 TO t.length-1 DO
 					t.ivalue:=256*t.ivalue;
 					t.ivalue:=256*t.ivalue;
 					reader.Char(c); INC(len);
 					reader.Char(c); INC(len);
 					t.svalue[i]:=c;
 					t.svalue[i]:=c;
 					t.ivalue:=t.ivalue+ORD(c);
 					t.ivalue:=t.ivalue+ORD(c);
 			END;
 			END;
 		ELSE
 		ELSE
-			NEW(t.svalue,t.length); 
+			NEW(t.svalue,t.length);
 			reader.Bytes(t.svalue^,0,t.length,len0); len:=len+len0;
 			reader.Bytes(t.svalue^,0,t.length,len0); len:=len+len0;
 		END;
 		END;
-	| BitString: 
+	| BitString:
 		reader.Char(c); t.unusedbits:=ORD(c); INC(len);
 		reader.Char(c); t.unusedbits:=ORD(c); INC(len);
 		IF FALSE & (ORD(reader.Peek())=30H) (*rsa bit string 1024b*) THEN (*unreliable hack. to do: pass info about recursive bitstring to child*)
 		IF FALSE & (ORD(reader.Peek())=30H) (*rsa bit string 1024b*) THEN (*unreliable hack. to do: pass info about recursive bitstring to child*)
 			IF Trace & (log#NIL) THEN log.String("(BitSRec  "); log.Int(len,0); log.String(")");t.Print(log);  END;
 			IF Trace & (log#NIL) THEN log.String("(BitSRec  "); log.Int(len,0); log.String(")");t.Print(log);  END;
 			t.child:=Decode(reader,level+1, len0);  len:=len+len0;
 			t.child:=Decode(reader,level+1, len0);  len:=len+len0;
 		ELSE
 		ELSE
-			NEW(t.svalue,t.length-1); 
+			NEW(t.svalue,t.length-1);
 			IF t.length>0 THEN reader.Bytes(t.svalue^,0,t.length-1,len0); len:=len+len0; END;
 			IF t.length>0 THEN reader.Bytes(t.svalue^,0,t.length-1,len0); len:=len+len0; END;
 		END;
 		END;
 	| String:
 	| String:
-		NEW(t.svalue,t.length); 
+		NEW(t.svalue,t.length);
 		reader.Bytes(t.svalue^,0,t.length,len0);len:=len+len0;
 		reader.Bytes(t.svalue^,0,t.length,len0);len:=len+len0;
 	| Set:
 	| Set:
 		IF Trace & (log#NIL) THEN log.String("(Set  "); log.Int(len,0); log.String("+)"); t.Print(log); END; (*bytes not including body*)
 		IF Trace & (log#NIL) THEN log.String("(Set  "); log.Int(len,0); log.String("+)"); t.Print(log); END; (*bytes not including body*)
@@ -256,13 +256,13 @@ BEGIN
 			t.AppendChild(t1);
 			t.AppendChild(t1);
 		END;
 		END;
 	ELSE
 	ELSE
-		NEW(t.svalue,t.length); 
+		NEW(t.svalue,t.length);
 		IF t.length>0 THEN reader.Bytes(t.svalue^,0,t.length,len0); len:=len+len0; END;
 		IF t.length>0 THEN reader.Bytes(t.svalue^,0,t.length,len0); len:=len+len0; END;
 	END;
 	END;
 	IF Trace & (log#NIL) THEN
 	IF Trace & (log#NIL) THEN
 		CASE t.tag OF
 		CASE t.tag OF
 		| Integer: log.String("(Integer  "); log.Int(len,4); log.Char(")"); t.Print(log);(*bytes including header*)
 		| Integer: log.String("(Integer  "); log.Int(len,4); log.Char(")"); t.Print(log);(*bytes including header*)
-		| BitString: 
+		| BitString:
 			IF t.constructed THEN log.String("(constrBitString "); ELSE log.String("(BitString "); END;
 			IF t.constructed THEN log.String("(constrBitString "); ELSE log.String("(BitString "); END;
 			log.Int(len,4); log.Char(")"); t.Print(log); (*bytes including header*)
 			log.Int(len,4); log.Char(")"); t.Print(log); (*bytes including header*)
 		| String: log.String("(String   ");log.Int(len,4); log.Char(")"); t.Print(log);(*bytes including header*)
 		| String: log.String("(String   ");log.Int(len,4); log.Char(")"); t.Print(log);(*bytes including header*)
@@ -270,7 +270,7 @@ BEGIN
 		| Oid: log.String("(OID");log.Int(len,4); log.Char(")"); t.Print(log);(*bytes including header*)
 		| Oid: log.String("(OID");log.Int(len,4); log.Char(")"); t.Print(log);(*bytes including header*)
 		| PrintableString: log.String("(Printable");log.Int(len,4); log.Char(")"); t.Print(log);(*bytes including header*)
 		| PrintableString: log.String("(Printable");log.Int(len,4); log.Char(")"); t.Print(log);(*bytes including header*)
 		| UTCTime: log.String("(UTCTime");log.Int(len,4); log.Char(")"); t.Print(log);(*bytes including header*)
 		| UTCTime: log.String("(UTCTime");log.Int(len,4); log.Char(")"); t.Print(log);(*bytes including header*)
-		| Set: 
+		| Set:
 		| Sequence:
 		| Sequence:
 		ELSE log.String("(t.tag="); log.Hex(t.tag,4);log.Int(len,4); log.Char(")"); t.Print(log); (*bytes including header*)
 		ELSE log.String("(t.tag="); log.Hex(t.tag,4);log.Int(len,4); log.Char(")"); t.Print(log); (*bytes including header*)
 		END;
 		END;

+ 1 - 1
source/AcStreamVideoOut.Mod

@@ -21,7 +21,7 @@ type
 	Controller* = record
 	Controller* = record
 		cfg-: port out; (** configuration port *)
 		cfg-: port out; (** configuration port *)
 		enabled-: boolean; (** TRUE if the PWM output is enabled *)
 		enabled-: boolean; (** TRUE if the PWM output is enabled *)
-		
+
 		pixelClock-: real; (** pixel clock in Hz *)
 		pixelClock-: real; (** pixel clock in Hz *)
 
 
 		horizActiveSize-: longint;
 		horizActiveSize-: longint;

+ 17 - 17
source/Activities.Mod

@@ -428,11 +428,11 @@ BEGIN {UNCOOPERATIVE, UNCHECKED}
 END EnqueueWaiting;
 END EnqueueWaiting;
 
 
 PROCEDURE  ReturnToStackSegment*;
 PROCEDURE  ReturnToStackSegment*;
-VAR 
+VAR
 	stackFrame {UNTRACED}: BaseTypes.StackFrame;
 	stackFrame {UNTRACED}: BaseTypes.StackFrame;
-	currentActivity {UNTRACED}: Activity; 
+	currentActivity {UNTRACED}: Activity;
 	newStack {UNTRACED}: Stack;
 	newStack {UNTRACED}: Stack;
-	stackRecord {UNTRACED}: StackRecord; 
+	stackRecord {UNTRACED}: StackRecord;
 BEGIN{UNCOOPERATIVE, UNCHECKED}
 BEGIN{UNCOOPERATIVE, UNCHECKED}
 	(* old stack pointer and base pointer have been pushed again, we have to revert this *)
 	(* old stack pointer and base pointer have been pushed again, we have to revert this *)
 	stackFrame := SYSTEM.GetFramePointer();
 	stackFrame := SYSTEM.GetFramePointer();
@@ -460,24 +460,24 @@ END ReturnToStackSegment0;
 
 
 (** Expands the stack memory of the current activity to include the specified stack address and returns the new stack pointer to be set after the call. *)
 (** Expands the stack memory of the current activity to include the specified stack address and returns the new stack pointer to be set after the call. *)
 PROCEDURE ExpandStack- (address: ADDRESS; parSize: SIZE): ADDRESS;
 PROCEDURE ExpandStack- (address: ADDRESS; parSize: SIZE): ADDRESS;
-VAR 
-	currentActivity {UNTRACED}: Activity; 
+VAR
+	currentActivity {UNTRACED}: Activity;
 	varSize, minSize, newSize: SIZE;  sp: ADDRESS;
 	varSize, minSize, newSize: SIZE;  sp: ADDRESS;
-	newStack {UNTRACED}: POINTER {DISPOSABLE} TO ARRAY OF CHAR; 
+	newStack {UNTRACED}: POINTER {DISPOSABLE} TO ARRAY OF CHAR;
 	stackFrame {UNTRACED}, previousFrame {UNTRACED}, newFrame {UNTRACED}: BaseTypes.StackFrame;
 	stackFrame {UNTRACED}, previousFrame {UNTRACED}, newFrame {UNTRACED}: BaseTypes.StackFrame;
 	stackRecord{UNTRACED}, newStackRecord{UNTRACED}: StackRecord;
 	stackRecord{UNTRACED}, newStackRecord{UNTRACED}: StackRecord;
 BEGIN {UNCOOPERATIVE, UNCHECKED}
 BEGIN {UNCOOPERATIVE, UNCHECKED}
 	(* check for valid argument *)
 	(* check for valid argument *)
 	currentActivity := SYSTEM.GetActivity ()(Activity);
 	currentActivity := SYSTEM.GetActivity ()(Activity);
-	
+
 	stackFrame := SYSTEM.GetFramePointer ();
 	stackFrame := SYSTEM.GetFramePointer ();
 	previousFrame := stackFrame.previous;
 	previousFrame := stackFrame.previous;
 	varSize := stackFrame.previous - address;
 	varSize := stackFrame.previous - address;
-	
+
 	(*
 	(*
 	TRACE(SYSTEM.GetFramePointer(), address, varSize, parSize, size, stackFrame.caller);
 	TRACE(SYSTEM.GetFramePointer(), address, varSize, parSize, size, stackFrame.caller);
 	*)
 	*)
-	ASSERT(varSize >= 0); 
+	ASSERT(varSize >= 0);
 	ASSERT(parSize >= 0);
 	ASSERT(parSize >= 0);
 
 
 	newSize := LEN (currentActivity.stack); (* current stack size *)
 	newSize := LEN (currentActivity.stack); (* current stack size *)
@@ -486,20 +486,20 @@ BEGIN {UNCOOPERATIVE, UNCHECKED}
 	ASSERT (newSize <= MaximumStackSize);
 	ASSERT (newSize <= MaximumStackSize);
 	stackRecord := ADDRESS OF currentActivity.stack[0];
 	stackRecord := ADDRESS OF currentActivity.stack[0];
 	newStack := stackRecord.next;
 	newStack := stackRecord.next;
-	IF (newStack = NIL) OR (LEN(newStack) < newSize) THEN 
-		NEW (newStack, newSize); 
+	IF (newStack = NIL) OR (LEN(newStack) < newSize) THEN
+		NEW (newStack, newSize);
 		ASSERT (newStack # NIL);
 		ASSERT (newStack # NIL);
 		newStackRecord := ADDRESS OF newStack[0];
 		newStackRecord := ADDRESS OF newStack[0];
 		newStackRecord.prev := currentActivity.stack;
 		newStackRecord.prev := currentActivity.stack;
 		newStackRecord.next := NIL;
 		newStackRecord.next := NIL;
 		stackRecord.next := newStack;
 		stackRecord.next := newStack;
-	ELSE 
+	ELSE
 		newStackRecord := ADDRESS OF newStack[0];
 		newStackRecord := ADDRESS OF newStack[0];
 		ASSERT(newStackRecord.prev = currentActivity.stack);
 		ASSERT(newStackRecord.prev = currentActivity.stack);
 		ASSERT(stackRecord.next = newStack);
 		ASSERT(stackRecord.next = newStack);
 	END;
 	END;
-	newSize := LEN(newStack); 
-	newFrame := ADDRESS OF newStack[0] + newSize- parSize -  3*SIZE OF ADDRESS; 
+	newSize := LEN(newStack);
+	newFrame := ADDRESS OF newStack[0] + newSize- parSize -  3*SIZE OF ADDRESS;
 	newFrame.previous := stackFrame.previous;
 	newFrame.previous := stackFrame.previous;
 	newFrame.descriptor := previousFrame.descriptor;
 	newFrame.descriptor := previousFrame.descriptor;
 	newFrame.caller := ReturnToStackSegment0;
 	newFrame.caller := ReturnToStackSegment0;
@@ -507,12 +507,12 @@ BEGIN {UNCOOPERATIVE, UNCHECKED}
 
 
 	stackFrame.previous := newFrame;
 	stackFrame.previous := newFrame;
 	SYSTEM.MOVE(ADDRESS OF previousFrame.caller + SIZE OF ADDRESS, ADDRESS OF newFrame.caller + SIZE OF ADDRESS, parSize); (* copy parameters *)
 	SYSTEM.MOVE(ADDRESS OF previousFrame.caller + SIZE OF ADDRESS, ADDRESS OF newFrame.caller + SIZE OF ADDRESS, parSize); (* copy parameters *)
-		
-	sp := ADDRESSOF(newFrame.descriptor) - varSize; 
+
+	sp := ADDRESSOF(newFrame.descriptor) - varSize;
 	DISPOSE (currentActivity.stack); currentActivity.stack := newStack;
 	DISPOSE (currentActivity.stack); currentActivity.stack := newStack;
 	currentActivity.stackLimit := ADDRESS OF newStack[SafeStackSize + 3 * SIZE OF ADDRESS];
 	currentActivity.stackLimit := ADDRESS OF newStack[SafeStackSize + 3 * SIZE OF ADDRESS];
 
 
-	RETURN sp; 
+	RETURN sp;
 END ExpandStack;
 END ExpandStack;
 
 
 (** Returns whether the specified address corresponds to a local variable that resides on the stack of the current activity calling this procedure. *)
 (** Returns whether the specified address corresponds to a local variable that resides on the stack of the current activity calling this procedure. *)

+ 68 - 68
source/AdaptiveHuffman.Mod

@@ -8,25 +8,25 @@ CONST
 	AlphabetSize = 256;		(* byte *)
 	AlphabetSize = 256;		(* byte *)
 	BlockSize* = 8*1024;
 	BlockSize* = 8*1024;
 	ScaleLimit = 4*1024;
 	ScaleLimit = 4*1024;
-	
+
 	Encode = 0;  Decode = 1;
 	Encode = 0;  Decode = 1;
 
 
-TYPE	
+TYPE
 	BitReader = OBJECT
 	BitReader = OBJECT
 		VAR
 		VAR
 			in: Streams.Reader;
 			in: Streams.Reader;
 			curByte, curBit: LONGINT;
 			curByte, curBit: LONGINT;
-			
+
 			PROCEDURE &New( r: Streams.Reader );
 			PROCEDURE &New( r: Streams.Reader );
 			BEGIN
 			BEGIN
 				in := r;  curBit := -1;  curByte := 0
 				in := r;  curBit := -1;  curByte := 0
 			END New;
 			END New;
-			
+
 			PROCEDURE Initialize;
 			PROCEDURE Initialize;
 			BEGIN
 			BEGIN
 				curBit := -1;  curByte := 0
 				curBit := -1;  curByte := 0
 			END Initialize;
 			END Initialize;
-			
+
 			PROCEDURE Bit( ): LONGINT;
 			PROCEDURE Bit( ): LONGINT;
 			VAR
 			VAR
 				bit: LONGINT;  ch: CHAR;
 				bit: LONGINT;  ch: CHAR;
@@ -38,21 +38,21 @@ TYPE
 				DEC( curBit );
 				DEC( curBit );
 				RETURN bit
 				RETURN bit
 			END Bit;
 			END Bit;
-	
+
 	END BitReader;
 	END BitReader;
-	
+
 
 
 TYPE
 TYPE
 	BitWriter = OBJECT
 	BitWriter = OBJECT
 		VAR
 		VAR
 			out: Streams.Writer;
 			out: Streams.Writer;
 			curByte, curBit: LONGINT;
 			curByte, curBit: LONGINT;
-			
+
 			PROCEDURE &New( w: Streams.Writer );
 			PROCEDURE &New( w: Streams.Writer );
 			BEGIN
 			BEGIN
 				out := w;  curBit := 0;  curByte := 0
 				out := w;  curBit := 0;  curByte := 0
 			END New;
 			END New;
-			
+
 			PROCEDURE Bit( bit: LONGINT );
 			PROCEDURE Bit( bit: LONGINT );
 			BEGIN
 			BEGIN
 				curByte := 2*curByte + bit;
 				curByte := 2*curByte + bit;
@@ -61,20 +61,20 @@ TYPE
 					out.Char( CHR( curByte ) );  curByte := 0;  curBit := 0
 					out.Char( CHR( curByte ) );  curByte := 0;  curBit := 0
 				END
 				END
 			END Bit;
 			END Bit;
-		
+
 			PROCEDURE Finish;	(* flush last few bits *)
 			PROCEDURE Finish;	(* flush last few bits *)
 			BEGIN
 			BEGIN
 				WHILE curBit # 0 DO  Bit( 0 )  END;
 				WHILE curBit # 0 DO  Bit( 0 )  END;
 				out.Update
 				out.Update
 			END Finish;
 			END Finish;
-				
+
 	END BitWriter;
 	END BitWriter;
-	
-	
+
+
 
 
 
 
 TYPE
 TYPE
-	HuffmanCoder = OBJECT		
+	HuffmanCoder = OBJECT
 		TYPE
 		TYPE
 			Index = INTEGER;		(* 16-bit integer to keep the table small *)
 			Index = INTEGER;		(* 16-bit integer to keep the table small *)
 			Pattern = INTEGER;
 			Pattern = INTEGER;
@@ -88,50 +88,50 @@ TYPE
 			mode: SHORTINT;	(* Encode, Decode *)
 			mode: SHORTINT;	(* Encode, Decode *)
 			in: BitReader;		(* input from archive *)
 			in: BitReader;		(* input from archive *)
 			out: BitWriter;	(* output to archive *)
 			out: BitWriter;	(* output to archive *)
-			
+
 			esc: Index;		(* the current escape node	*)
 			esc: Index;		(* the current escape node	*)
 			root: Index;         (* the root of the tree	*)
 			root: Index;         (* the root of the tree	*)
 			map: ARRAY AlphabetSize OF Index;			(* mapping of patterns to nodes	*)
 			map: ARRAY AlphabetSize OF Index;			(* mapping of patterns to nodes	*)
 			table: ARRAY 2*AlphabetSize + 2 OF Node;	(* the Huffman tree	*)
 			table: ARRAY 2*AlphabetSize + 2 OF Node;	(* the Huffman tree	*)
-		
-		
-		
+
+
+
 		PROCEDURE &New( m: SHORTINT;  input: Streams.Reader;  output: Streams.Writer );
 		PROCEDURE &New( m: SHORTINT;  input: Streams.Reader;  output: Streams.Writer );
 		BEGIN
 		BEGIN
 			ASSERT( m IN {Encode, Decode} );
 			ASSERT( m IN {Encode, Decode} );
 			mode := m;
 			mode := m;
 			IF mode = Encode THEN  NEW( out, output )  ELSE  NEW( in, input )  END;
 			IF mode = Encode THEN  NEW( out, output )  ELSE  NEW( in, input )  END;
 		END New;
 		END New;
-		
+
 		PROCEDURE Initialize;
 		PROCEDURE Initialize;
 		VAR  i: Index;
 		VAR  i: Index;
 		BEGIN
 		BEGIN
-			root := 2*AlphabetSize + 2 - 1; 
+			root := 2*AlphabetSize + 2 - 1;
 			FOR i := 0 TO root DO
 			FOR i := 0 TO root DO
 				table[i].up := 0;  table[i].down := 0;  table[i].pattern := 0;  table[i].weight := 0
 				table[i].up := 0;  table[i].down := 0;  table[i].pattern := 0;  table[i].weight := 0
 			END;
 			END;
 			FOR i := 0 TO AlphabetSize - 1 DO  map[i]  := 0  END;
 			FOR i := 0 TO AlphabetSize - 1 DO  map[i]  := 0  END;
 			esc := root;
 			esc := root;
 			IF mode = Decode THEN  in.Initialize  END
 			IF mode = Decode THEN  in.Initialize  END
-		END Initialize;		
-		
-		PROCEDURE Finish;	
+		END Initialize;
+
+		PROCEDURE Finish;
 		BEGIN
 		BEGIN
 			ASSERT( mode = Encode );
 			ASSERT( mode = Encode );
 			out.Finish  (* flush last few bits *)
 			out.Finish  (* flush last few bits *)
-		END Finish;	
+		END Finish;
+
 
 
-		
 		PROCEDURE GetPattern(  ): Pattern;
 		PROCEDURE GetPattern(  ): Pattern;
 		VAR  i: INTEGER;  patt: Pattern;
 		VAR  i: INTEGER;  patt: Pattern;
 		BEGIN
 		BEGIN
-			patt := 0; 
+			patt := 0;
 			FOR i := 0 TO 7 DO
 			FOR i := 0 TO 7 DO
 				IF in.Bit() = 1 THEN  patt := patt + INTEGER(ASH( 1, i ))  END;
 				IF in.Bit() = 1 THEN  patt := patt + INTEGER(ASH( 1, i ))  END;
 			END;
 			END;
 			RETURN patt
 			RETURN patt
 		END GetPattern;
 		END GetPattern;
-		
+
 		PROCEDURE PutPattern( patt: Pattern );
 		PROCEDURE PutPattern( patt: Pattern );
 		VAR i: LONGINT;
 		VAR i: LONGINT;
 		BEGIN
 		BEGIN
@@ -140,27 +140,27 @@ TYPE
 			END
 			END
 		END PutPattern;
 		END PutPattern;
 
 
-		
+
 		(* split escape node to incorporate a new pattern *)
 		(* split escape node to incorporate a new pattern *)
 		PROCEDURE AddPattern( patt: Pattern ): Index;
 		PROCEDURE AddPattern( patt: Pattern ): Index;
 		VAR  pair, node: Index;
 		VAR  pair, node: Index;
 		BEGIN
 		BEGIN
 			ASSERT( esc > 1 );
 			ASSERT( esc > 1 );
 			pair := esc;  node := esc - 1;  esc := esc - 2 ;
 			pair := esc;  node := esc - 1;  esc := esc - 2 ;
-			
-			table[pair].down := node;  table[pair].weight := 1;  
-			
+
+			table[pair].down := node;  table[pair].weight := 1;
+
 			table[node].up := pair;
 			table[node].up := pair;
-			table[node].down := 0;  table[node].weight := 0;  table[node].pattern := patt; 
-			
+			table[node].down := 0;  table[node].weight := 0;  table[node].pattern := patt;
+
 			table[esc].up := pair;
 			table[esc].up := pair;
-			table[esc].down := 0;  table[esc].weight := 0;  
-			
+			table[esc].down := 0;  table[esc].weight := 0;
+
 			map[patt] := node;
 			map[patt] := node;
-			
+
 			RETURN node;
 			RETURN node;
-		END AddPattern;		
-		
+		END AddPattern;
+
 
 
 		(* swap leaf to group leader position, return pattern's new node *)
 		(* swap leaf to group leader position, return pattern's new node *)
 		PROCEDURE GroupLeader( node: Index ): Index;
 		PROCEDURE GroupLeader( node: Index ): Index;
@@ -171,7 +171,7 @@ TYPE
 		BEGIN
 		BEGIN
 			weight := table[node].weight;  leader := node;
 			weight := table[node].weight;  leader := node;
 			WHILE (leader < root) & (weight = table[leader + 1].weight) DO  INC( leader )  END;
 			WHILE (leader < root) & (weight = table[leader + 1].weight) DO  INC( leader )  END;
-			IF leader # node THEN  
+			IF leader # node THEN
 				(* swap the leaf nodes *)
 				(* swap the leaf nodes *)
 				patt := table[node].pattern;
 				patt := table[node].pattern;
 				prev := table[leader].pattern;
 				prev := table[leader].pattern;
@@ -181,8 +181,8 @@ TYPE
 				map[prev] := node;
 				map[prev] := node;
 			END;
 			END;
 			RETURN leader
 			RETURN leader
-		END GroupLeader;		
-				
+		END GroupLeader;
+
 
 
 		(*	slide internal node up over all leaves of equal weight
 		(*	slide internal node up over all leaves of equal weight
 			or exchange leaf with next smaller weight internal node.
 			or exchange leaf with next smaller weight internal node.
@@ -209,7 +209,7 @@ TYPE
 				map[swap.pattern] := next;
 				map[swap.pattern] := next;
 			END;
 			END;
 			RETURN next;
 			RETURN next;
-		END SlideNode;		
+		END SlideNode;
 
 
 
 
 		(* increment pattern weight and re balance the tree. *)
 		(* increment pattern weight and re balance the tree. *)
@@ -237,20 +237,20 @@ TYPE
 				INC( table[node].weight, 2 );  up := table[node].up
 				INC( table[node].weight, 2 );  up := table[node].up
 			END;
 			END;
 		END IncrementWeight;
 		END IncrementWeight;
-		
-			
+
+
 		(*  scale all weights and rebalance the tree,
 		(*  scale all weights and rebalance the tree,
 		    zero weight nodes are removed from the tree	*)
 		    zero weight nodes are removed from the tree	*)
 		PROCEDURE Scale;
 		PROCEDURE Scale;
 		VAR  node, prev: Index;  weight: INTEGER;
 		VAR  node, prev: Index;  weight: INTEGER;
-		
+
 			PROCEDURE Weight( idx: Index ): INTEGER;
 			PROCEDURE Weight( idx: Index ): INTEGER;
 			VAR w: INTEGER;
 			VAR w: INTEGER;
 			BEGIN
 			BEGIN
 				w := table[idx].weight;
 				w := table[idx].weight;
 				IF ODD( w ) THEN  RETURN w - 1  ELSE  RETURN w  END
 				IF ODD( w ) THEN  RETURN w - 1  ELSE  RETURN w  END
 			END Weight;
 			END Weight;
-			
+
 		BEGIN
 		BEGIN
 			node := esc + 1;
 			node := esc + 1;
 			(* work up the tree from the escape node scaling weights *)
 			(* work up the tree from the escape node scaling weights *)
@@ -276,23 +276,23 @@ TYPE
 			(* prepare a new escape node *)
 			(* prepare a new escape node *)
 			table[esc].down := 0;  table[esc].weight := 0;
 			table[esc].down := 0;  table[esc].weight := 0;
 		END Scale;
 		END Scale;
-		
-		
-		
-	
+
+
+
+
 		PROCEDURE EncodeByte( ch: CHAR );
 		PROCEDURE EncodeByte( ch: CHAR );
 		VAR
 		VAR
-			code, bits: LONGINT;  
+			code, bits: LONGINT;
 			cur, node: Index;  patt: Pattern;
 			cur, node: Index;  patt: Pattern;
 		BEGIN
 		BEGIN
-			patt := ORD( ch );  node := map[patt];  
-			
+			patt := ORD( ch );  node := map[patt];
+
 			(* accumulate the code bits by working up from the node to the root	*)
 			(* accumulate the code bits by working up from the node to the root	*)
 			cur := node;  code := 0;  bits := 0;
 			cur := node;  code := 0;  bits := 0;
 			IF cur = 0 THEN  cur := esc  END;
 			IF cur = 0 THEN  cur := esc  END;
 			WHILE table[cur].up # 0 DO
 			WHILE table[cur].up # 0 DO
 				IF ODD( cur ) THEN  code := code*2 + 1  ELSE  code := code*2  END;
 				IF ODD( cur ) THEN  code := code*2 + 1  ELSE  code := code*2  END;
-				INC( bits );  cur := table[cur].up	
+				INC( bits );  cur := table[cur].up
 			END;
 			END;
 			(* send the code *)
 			(* send the code *)
 			WHILE bits > 0 DO
 			WHILE bits > 0 DO
@@ -309,7 +309,7 @@ TYPE
 
 
 		PROCEDURE ExtractByte( ): CHAR;
 		PROCEDURE ExtractByte( ): CHAR;
 		VAR
 		VAR
-			node, down: Index; 
+			node, down: Index;
 			patt: Pattern;
 			patt: Pattern;
 		BEGIN
 		BEGIN
 			(* work down the tree from the root until reaching either a leaf or the escape node *)
 			(* work down the tree from the root until reaching either a leaf or the escape node *)
@@ -327,7 +327,7 @@ TYPE
 			IncrementWeight( node );
 			IncrementWeight( node );
 			RETURN CHR( patt );
 			RETURN CHR( patt );
 		END ExtractByte;
 		END ExtractByte;
-		
+
 	END HuffmanCoder;
 	END HuffmanCoder;
 
 
 
 
@@ -336,16 +336,16 @@ TYPE
 	Encoder* =OBJECT
 	Encoder* =OBJECT
 		VAR
 		VAR
 			huff: HuffmanCoder;
 			huff: HuffmanCoder;
-			
+
 			PROCEDURE & New*( archive: Streams.Writer );
 			PROCEDURE & New*( archive: Streams.Writer );
 			BEGIN
 			BEGIN
 				NEW( huff, Encode, NIL, archive );
 				NEW( huff, Encode, NIL, archive );
 			END New;
 			END New;
-			
+
 			PROCEDURE CompressBlock*( CONST source: ARRAY OF CHAR; len: LONGINT );
 			PROCEDURE CompressBlock*( CONST source: ARRAY OF CHAR; len: LONGINT );
 			VAR  i: LONGINT;
 			VAR  i: LONGINT;
 			BEGIN
 			BEGIN
-				huff.Initialize;	
+				huff.Initialize;
 				i := 0;
 				i := 0;
 				WHILE i < len DO
 				WHILE i < len DO
 					huff.EncodeByte( source[i] );  INC( i );
 					huff.EncodeByte( source[i] );  INC( i );
@@ -355,23 +355,23 @@ TYPE
 			END CompressBlock;
 			END CompressBlock;
 
 
 	END Encoder;
 	END Encoder;
-	
-	
-	
+
+
+
 TYPE
 TYPE
 	Decoder* =OBJECT
 	Decoder* =OBJECT
 		VAR
 		VAR
 			huff: HuffmanCoder;
 			huff: HuffmanCoder;
-			
+
 			PROCEDURE & New*( archive: Streams.Reader );
 			PROCEDURE & New*( archive: Streams.Reader );
 			BEGIN
 			BEGIN
 				NEW( huff, Decode, archive, NIL );
 				NEW( huff, Decode, archive, NIL );
 			END New;
 			END New;
-			
+
 			PROCEDURE ExtractBlock*( VAR buf: ARRAY OF CHAR; len: LONGINT );
 			PROCEDURE ExtractBlock*( VAR buf: ARRAY OF CHAR; len: LONGINT );
-			VAR  i: LONGINT; 
+			VAR  i: LONGINT;
 			BEGIN
 			BEGIN
-				huff.Initialize;  
+				huff.Initialize;
 				i := 0;
 				i := 0;
 				WHILE i < len DO
 				WHILE i < len DO
 					buf[i] := huff.ExtractByte( );  INC( i );
 					buf[i] := huff.ExtractByte( );  INC( i );
@@ -380,8 +380,8 @@ TYPE
 			END ExtractBlock;
 			END ExtractBlock;
 
 
 	END Decoder;
 	END Decoder;
-	
-	
+
+
 END AdaptiveHuffman.
 END AdaptiveHuffman.
 
 
 
 

+ 63 - 63
source/BB.StdCoder.Mod

@@ -3,7 +3,7 @@ MODULE StdCoder; (** AUTHOR "GF"; PURPOSE "Extract sources from BlackBox standar
 IMPORT Streams, Commands, Files, Strings, Log := KernelLog;
 IMPORT Streams, Commands, Files, Strings, Log := KernelLog;
 
 
 CONST
 CONST
-	Tag = "StdCoder.Decode";	
+	Tag = "StdCoder.Decode";
 	Ok = Streams.Ok;
 	Ok = Streams.Ok;
 	OldVersion = 0; ThisVersion = 1;
 	OldVersion = 0; ThisVersion = 1;
 	View = 1; File = 2; List = 3;
 	View = 1; File = 2; List = 3;
@@ -11,15 +11,15 @@ CONST
 
 
 TYPE
 TYPE
 	FileType = ARRAY 16 OF CHAR;
 	FileType = ARRAY 16 OF CHAR;
-	
+
 	FileList = POINTER TO RECORD
 	FileList = POINTER TO RECORD
 		next: FileList;
 		next: FileList;
 		oberonSource: BOOLEAN;
 		oberonSource: BOOLEAN;
 		oberonDoku: BOOLEAN;
 		oberonDoku: BOOLEAN;
 		name: Files.FileName
 		name: Files.FileName
 	END;
 	END;
-	
-	
+
+
 VAR
 VAR
 	code: ARRAY 64 OF CHAR;
 	code: ARRAY 64 OF CHAR;
 	revCode: ARRAY 256 OF SHORTINT;
 	revCode: ARRAY 256 OF SHORTINT;
@@ -29,18 +29,18 @@ VAR
 	BEGIN
 	BEGIN
 		Log.String( "### StdCoder.Decode: " );
 		Log.String( "### StdCoder.Decode: " );
 		CASE n OF
 		CASE n OF
-		|  1: Log.String("bad characters or EOT" ); 
-		|  2: Log.String("checksum error" ); 
-		|  3: Log.String("incompatible version" ); 
-		|  4: Log.String("filing error" ); 
-		|  5: Log.String("directory ^0 not found" ); 
-		|  6: Log.String("file ^0 not found" ); 
-		|  7: Log.String("illegal path" ); 
-		|  8: Log.String("bad tag" ); 
-		|  9: Log.String("disk write protected" ); 
-		| 10: Log.String("io error" ); 
+		|  1: Log.String("bad characters or EOT" );
+		|  2: Log.String("checksum error" );
+		|  3: Log.String("incompatible version" );
+		|  4: Log.String("filing error" );
+		|  5: Log.String("directory ^0 not found" );
+		|  6: Log.String("file ^0 not found" );
+		|  7: Log.String("illegal path" );
+		|  8: Log.String("bad tag" );
+		|  9: Log.String("disk write protected" );
+		| 10: Log.String("io error" );
 		END;
 		END;
-		Log.Ln	
+		Log.Ln
 	END ShowError;
 	END ShowError;
 
 
 
 
@@ -54,8 +54,8 @@ VAR
 		IF res # 0 THEN  x := 0  END;
 		IF res # 0 THEN  x := 0  END;
 		RETURN x
 		RETURN x
 	END read;
 	END read;
-	
-	
+
+
 	PROCEDURE peeknext( r: Streams.Reader ): CHAR;
 	PROCEDURE peeknext( r: Streams.Reader ): CHAR;
 	VAR ch: CHAR;
 	VAR ch: CHAR;
 	BEGIN
 	BEGIN
@@ -63,9 +63,9 @@ VAR
 	END peeknext;
 	END peeknext;
 
 
 
 
-	PROCEDURE ReadHeader(		r: Streams.Reader; 
+	PROCEDURE ReadHeader(		r: Streams.Reader;
 									VAR res: WORD;  VAR name: ARRAY OF CHAR;  VAR type: LONGINT );
 									VAR res: WORD;  VAR name: ARRAY OF CHAR;  VAR type: LONGINT );
-	VAR 
+	VAR
 		x, bits, i: LONGINT; ch: CHAR; tag: ARRAY 16 OF CHAR;
 		x, bits, i: LONGINT; ch: CHAR; tag: ARRAY 16 OF CHAR;
 	BEGIN
 	BEGIN
 		tag := Tag; i := 0;  res := 0;
 		tag := Tag; i := 0;  res := 0;
@@ -78,11 +78,11 @@ VAR
 		IF res = 0 THEN
 		IF res = 0 THEN
 			i := 0;  bits := 0;  x := 0;
 			i := 0;  bits := 0;  x := 0;
 			REPEAT
 			REPEAT
-				WHILE (res = 0) & (bits < 8) DO 
-					INC( x, ASH( read( r, res ), bits ) ); INC( bits, 6 ) 
+				WHILE (res = 0) & (bits < 8) DO
+					INC( x, ASH( read( r, res ), bits ) ); INC( bits, 6 )
 				END;
 				END;
 				IF res = 0 THEN
 				IF res = 0 THEN
-					ch := CHR(x MOD 256);  x := x DIV 256;  DEC( bits, 8 ); 
+					ch := CHR(x MOD 256);  x := x DIV 256;  DEC( bits, 8 );
 					name[i] := ch; INC(i);
 					name[i] := ch; INC(i);
 				END
 				END
 			UNTIL (res # 0) OR (ch = 0X);
 			UNTIL (res # 0) OR (ch = 0X);
@@ -93,24 +93,24 @@ VAR
 				END
 				END
 			END
 			END
 		ELSE  res := 8
 		ELSE  res := 8
-		END 
+		END
 	END ReadHeader;
 	END ReadHeader;
-	
-	
+
+
 	PROCEDURE SkipFileType(r: Streams.Reader; VAR res: WORD ): BOOLEAN;
 	PROCEDURE SkipFileType(r: Streams.Reader; VAR res: WORD ): BOOLEAN;
-	VAR x, bits, i: LONGINT; ch: CHAR;  ftype: FileType; 
+	VAR x, bits, i: LONGINT; ch: CHAR;  ftype: FileType;
 	BEGIN
 	BEGIN
 		res := 0;  i := 0; bits := 0;  x := 0;
 		res := 0;  i := 0; bits := 0;  x := 0;
 		REPEAT
 		REPEAT
 			WHILE (res = 0) & (bits < 8) DO  INC( x, ASH( read( r, res ), bits ) ); INC( bits, 6 )  END;
 			WHILE (res = 0) & (bits < 8) DO  INC( x, ASH( read( r, res ), bits ) ); INC( bits, 6 )  END;
-			IF res = 0 THEN  
-				ch := CHR( x MOD 256 );  x := x DIV 256;  DEC( bits, 8 );  ftype[i] := ch;  INC( i )  
+			IF res = 0 THEN
+				ch := CHR( x MOD 256 );  x := x DIV 256;  DEC( bits, 8 );  ftype[i] := ch;  INC( i )
 			END
 			END
 		UNTIL (res # 0) OR (ch = 0X);
 		UNTIL (res # 0) OR (ch = 0X);
 		RETURN res = 0
 		RETURN res = 0
 	END SkipFileType;
 	END SkipFileType;
-	
-	
+
+
 	PROCEDURE ReadInteger( r: Streams.Reader; VAR res: WORD ): LONGINT;
 	PROCEDURE ReadInteger( r: Streams.Reader; VAR res: WORD ): LONGINT;
 	VAR bits, val: LONGINT;
 	VAR bits, val: LONGINT;
 	BEGIN
 	BEGIN
@@ -118,10 +118,10 @@ VAR
 		REPEAT  val := val + ASH( read( r, res ), bits ); INC( bits, 6 )  UNTIL (res # 0) OR (bits >= 32);
 		REPEAT  val := val + ASH( read( r, res ), bits ); INC( bits, 6 )  UNTIL (res # 0) OR (bits >= 32);
 		RETURN val
 		RETURN val
 	END ReadInteger;
 	END ReadInteger;
-	
-	
+
+
 	PROCEDURE ReadFile( r: Streams.Reader; VAR res: WORD ): Files.File;
 	PROCEDURE ReadFile( r: Streams.Reader; VAR res: WORD ): Files.File;
-	VAR 
+	VAR
 		hash, x, bits, i, len, sum, s: LONGINT; byte: SHORTINT;  f: Files.File;  w: Files.Writer;
 		hash, x, bits, i, len, sum, s: LONGINT; byte: SHORTINT;  f: Files.File;  w: Files.Writer;
 	BEGIN
 	BEGIN
 		f := Files.New( "" );  Files.OpenWriter( w, f, 0 );
 		f := Files.New( "" );  Files.OpenWriter( w, f, 0 );
@@ -137,11 +137,11 @@ VAR
 				byte := SHORTINT( i );  x := x DIV 256;  DEC( bits, 8 );
 				byte := SHORTINT( i );  x := x DIV 256;  DEC( bits, 8 );
 				table[hash] := byte
 				table[hash] := byte
 			ELSE  (* correct prediction *)
 			ELSE  (* correct prediction *)
-				byte := table[hash];  x := x DIV 2;  DEC( bits )	
+				byte := table[hash];  x := x DIV 2;  DEC( bits )
 			END;
 			END;
 			hash := (16 * hash + byte MOD 256) MOD N;
 			hash := (16 * hash + byte MOD 256) MOD N;
 			sum := (sum + byte MOD 256) MOD (16 * 1024);
 			sum := (sum + byte MOD 256) MOD (16 * 1024);
-			
+
 			w.Char( CHR( byte ) );  DEC( len );
 			w.Char( CHR( byte ) );  DEC( len );
 		END;
 		END;
 		IF res = 0 THEN
 		IF res = 0 THEN
@@ -151,11 +151,11 @@ VAR
 		w.Update;
 		w.Update;
 		RETURN f
 		RETURN f
 	END ReadFile;
 	END ReadFile;
-	
-	
+
+
 	PROCEDURE NewFile( CONST name: ARRAY OF CHAR ): Files.File;
 	PROCEDURE NewFile( CONST name: ARRAY OF CHAR ): Files.File;
 	VAR
 	VAR
-		f: Files.File;  res: WORD;  name2: Files.FileName; 
+		f: Files.File;  res: WORD;  name2: Files.FileName;
 	BEGIN
 	BEGIN
 		f := Files.Old( name );
 		f := Files.Old( name );
 		IF f # NIL THEN
 		IF f # NIL THEN
@@ -164,26 +164,26 @@ VAR
 		END;
 		END;
 		RETURN Files.New( name );
 		RETURN Files.New( name );
 	END NewFile;
 	END NewFile;
-	
-	
+
+
 	PROCEDURE CutSuffixODC( VAR n: Files.FileName );
 	PROCEDURE CutSuffixODC( VAR n: Files.FileName );
 	VAR i: LONGINT
 	VAR i: LONGINT
 	BEGIN
 	BEGIN
 		i := 0;  WHILE n[i] # 0X DO  INC(i)  END;
 		i := 0;  WHILE n[i] # 0X DO  INC(i)  END;
-		IF (i > 4) & (n[i -4] = ".") & (CAP(n[i-3]) = "O") & (CAP(n[i-2]) = "D") & (CAP(n[i-1]) = "C") THEN 
+		IF (i > 4) & (n[i -4] = ".") & (CAP(n[i-3]) = "O") & (CAP(n[i-2]) = "D") & (CAP(n[i-1]) = "C") THEN
 			n[i - 4] := 0X
 			n[i - 4] := 0X
 		END;
 		END;
 	END CutSuffixODC;
 	END CutSuffixODC;
-	
-	
+
+
 	PROCEDURE PositionReader( VAR r: Files.Reader; str: ARRAY OF CHAR );
 	PROCEDURE PositionReader( VAR r: Files.Reader; str: ARRAY OF CHAR );
-	VAR pos, i: LONGINT; c: CHAR; 
+	VAR pos, i: LONGINT; c: CHAR;
 	BEGIN
 	BEGIN
 		pos := 0;
 		pos := 0;
 		LOOP
 		LOOP
 			r.SetPos( pos );
 			r.SetPos( pos );
 			REPEAT r.Char( c ); INC( pos )  UNTIL (c = str[0]) OR (r.res # Ok);
 			REPEAT r.Char( c ); INC( pos )  UNTIL (c = str[0]) OR (r.res # Ok);
-			i := 1; 
+			i := 1;
 			LOOP
 			LOOP
 				IF r.res = Ok THEN  r.Char( c )  ELSE (*failed*) r.SetPos( 0 );  RETURN  END;
 				IF r.res = Ok THEN  r.Char( c )  ELSE (*failed*) r.SetPos( 0 );  RETURN  END;
 				IF c # str[i] THEN  (*try again*)  EXIT  END;
 				IF c # str[i] THEN  (*try again*)  EXIT  END;
@@ -192,26 +192,26 @@ VAR
 			END
 			END
 		END
 		END
 	END PositionReader;
 	END PositionReader;
-	
-	
+
+
 	PROCEDURE ExtractAscii( src: Files.File;  CONST startstring, destname: ARRAY OF CHAR );
 	PROCEDURE ExtractAscii( src: Files.File;  CONST startstring, destname: ARRAY OF CHAR );
 	CONST CR = 0DX; LF = 0AX;  HT = 09X;
 	CONST CR = 0DX; LF = 0AX;  HT = 09X;
 	VAR r: Files.Reader; w: Files.Writer; destfile: Files.File; ch: CHAR;
 	VAR r: Files.Reader; w: Files.Writer; destfile: Files.File; ch: CHAR;
 	BEGIN
 	BEGIN
-		Log.String( "extract: " ); Log.String( destname ); Log.Ln; 
+		Log.String( "extract: " ); Log.String( destname ); Log.Ln;
 		destfile := NewFile( destname );  Files.OpenWriter( w, destfile, 0 );
 		destfile := NewFile( destname );  Files.OpenWriter( w, destfile, 0 );
-		Files.OpenReader( r, src, 0 );  PositionReader( r, startstring );  
+		Files.OpenReader( r, src, 0 );  PositionReader( r, startstring );
 		r.Char( ch );
 		r.Char( ch );
 		REPEAT
 		REPEAT
 			IF (ch = CR) OR (ch = LF) THEN  w.Ln
 			IF (ch = CR) OR (ch = LF) THEN  w.Ln
-			ELSIF ((ch >= ' ') & (ch <= '~')) OR (ch = HT) THEN  w.Char( ch ) 
+			ELSIF ((ch >= ' ') & (ch <= '~')) OR (ch = HT) THEN  w.Char( ch )
 			END;
 			END;
 			r.Char( ch )
 			r.Char( ch )
 		UNTIL r.res # Ok;
 		UNTIL r.res # Ok;
 		w.Update;  Files.Register( destfile )
 		w.Update;  Files.Register( destfile )
 	END ExtractAscii;
 	END ExtractAscii;
-	
-	
+
+
 	PROCEDURE DecodeFile( r: Streams.Reader; CONST name: Files.FileName );
 	PROCEDURE DecodeFile( r: Streams.Reader; CONST name: Files.FileName );
 	VAR res: WORD; f: Files.File;
 	VAR res: WORD; f: Files.File;
 	BEGIN
 	BEGIN
@@ -223,10 +223,10 @@ VAR
 		ELSE  ShowError( res )
 		ELSE  ShowError( res )
 		END
 		END
 	END DecodeFile;
 	END DecodeFile;
-	
-	
+
+
 	PROCEDURE DecodeFileList ( r: Streams.Reader; VAR res: WORD );
 	PROCEDURE DecodeFileList ( r: Streams.Reader; VAR res: WORD );
-	VAR 
+	VAR
 		i: LONGINT; p, files: FileList; ch: CHAR;
 		i: LONGINT; p, files: FileList; ch: CHAR;
 		f: Files.File; fr: Files.Reader; path: Files.FileName;
 		f: Files.File; fr: Files.Reader; path: Files.FileName;
 		sa: Strings.StringArray; suffix: ARRAY 16 OF CHAR;
 		sa: Strings.StringArray; suffix: ARRAY 16 OF CHAR;
@@ -257,10 +257,10 @@ VAR
 					ELSE res := 1
 					ELSE res := 1
 					END
 					END
 				END;
 				END;
-				p := files; 
+				p := files;
 				WHILE (res = 0) & (p # NIL) DO
 				WHILE (res = 0) & (p # NIL) DO
 					IF SkipFileType( r, res ) THEN
 					IF SkipFileType( r, res ) THEN
-						f := ReadFile( r, res ); 
+						f := ReadFile( r, res );
 						IF res = 0 THEN
 						IF res = 0 THEN
 							IF p.oberonSource THEN  ExtractAscii( f, "MODULE", p.name )
 							IF p.oberonSource THEN  ExtractAscii( f, "MODULE", p.name )
 							ELSIF p.oberonDoku THEN  ExtractAscii( f, "DEFINITION", p.name )
 							ELSIF p.oberonDoku THEN  ExtractAscii( f, "DEFINITION", p.name )
@@ -273,12 +273,12 @@ VAR
 			END
 			END
 		END
 		END
 	END DecodeFileList;
 	END DecodeFileList;
-	
-	
+
+
 	PROCEDURE Decode* ( c: Commands.Context );
 	PROCEDURE Decode* ( c: Commands.Context );
 	VAR
 	VAR
 		name: Files.FileName;
 		name: Files.FileName;
-		res, type: LONGINT; 
+		res, type: LONGINT;
 		r: Streams.Reader;
 		r: Streams.Reader;
 	BEGIN
 	BEGIN
 		r := c.arg;
 		r := c.arg;
@@ -300,7 +300,7 @@ VAR
 	VAR i: SHORTINT;  j: LONGINT;
 	VAR i: SHORTINT;  j: LONGINT;
 	BEGIN
 	BEGIN
 		FOR j := 0 TO 255 DO  revCode[j] := -1  END;
 		FOR j := 0 TO 255 DO  revCode[j] := -1  END;
-		code[0] := ".";  revCode[ORD(".")] := 0; 
+		code[0] := ".";  revCode[ORD(".")] := 0;
 		code[1] := ",";  revCode[ORD(",")] := 1;
 		code[1] := ",";  revCode[ORD(",")] := 1;
 		i := 2;  j := ORD("0");
 		i := 2;  j := ORD("0");
 		WHILE j <= ORD("9") DO code[i] := CHR(j); revCode[j] := i; INC(i); INC(j) END;
 		WHILE j <= ORD("9") DO code[i] := CHR(j); revCode[j] := i; INC(i); INC(j) END;
@@ -309,8 +309,8 @@ VAR
 		j := ORD("a");
 		j := ORD("a");
 		WHILE j <= ORD("z") DO code[i] := CHR(j); revCode[j] := i; INC(i); INC(j) END;
 		WHILE j <= ORD("z") DO code[i] := CHR(j); revCode[j] := i; INC(i); INC(j) END;
 		ASSERT(i = 64, 60)
 		ASSERT(i = 64, 60)
-	END InitCodes;		
-		
+	END InitCodes;
+
 BEGIN
 BEGIN
 	InitCodes
 	InitCodes
 END StdCoder.
 END StdCoder.

+ 2 - 2
source/BIOS.ACPI.Mod

@@ -78,7 +78,7 @@ BEGIN {UNCOOPERATIVE, UNCHECKED}
 END GetTable;
 END GetTable;
 
 
 PROCEDURE Initialize-;
 PROCEDURE Initialize-;
-TYPE BiosEBDA = POINTER {UNSAFE} TO RECORD val: INTEGER END; 
+TYPE BiosEBDA = POINTER {UNSAFE} TO RECORD val: INTEGER END;
 VAR address := 0E0000H: ADDRESS; size := 020000H: SIZE; biosEBDA {UNTRACED}: BiosEBDA;
 VAR address := 0E0000H: ADDRESS; size := 020000H: SIZE; biosEBDA {UNTRACED}: BiosEBDA;
 
 
 BEGIN {UNCOOPERATIVE, UNCHECKED}
 BEGIN {UNCOOPERATIVE, UNCHECKED}
@@ -87,7 +87,7 @@ BEGIN {UNCOOPERATIVE, UNCHECKED}
 		IF (rdsp.signature = RDSPSignature) & (Checksum (address, 20) = 0) THEN RETURN END;
 		IF (rdsp.signature = RDSPSignature) & (Checksum (address, 20) = 0) THEN RETURN END;
 		INC (address, 16); DEC (size, 16);
 		INC (address, 16); DEC (size, 16);
 	END;
 	END;
-	
+
 	biosEBDA := 40EH;
 	biosEBDA := 40EH;
 	(* try Extended Bios Data Area EBDA *)
 	(* try Extended Bios Data Area EBDA *)
 	address := ADDRESS(biosEBDA.val) MOD 10000H * 16;
 	address := ADDRESS(biosEBDA.val) MOD 10000H * 16;

+ 4 - 4
source/BIOS.AMD64.Machine.Mod

@@ -573,9 +573,9 @@ CONST
 	SSE2Flag = 26;
 	SSE2Flag = 26;
 	SSE3Flag = 0; (*IN features2 from ECX*) (*PH 04/11*)
 	SSE3Flag = 0; (*IN features2 from ECX*) (*PH 04/11*)
 	SSSE3Flag =9;
 	SSSE3Flag =9;
-	SSE41Flag =19; 
+	SSE41Flag =19;
 	SSE42Flag =20;
 	SSE42Flag =20;
-	SSE5Flag = 11; 
+	SSE5Flag = 11;
 	AVXFlag = 28;
 	AVXFlag = 28;
 BEGIN
 BEGIN
 	SSE2Support := FALSE;
 	SSE2Support := FALSE;
@@ -2641,7 +2641,7 @@ entry:
 
 
 	LEA RBP, [RSP + 136]
 	LEA RBP, [RSP + 136]
 	MOV RBX, [RSP + 128]	; RBX = int number
 	MOV RBX, [RSP + 128]	; RBX = int number
-	
+
 	IMUL RBX, RBX, MaxNumHandlers
 	IMUL RBX, RBX, MaxNumHandlers
 	IMUL RBX, RBX, SizeOfHandlerRec
 	IMUL RBX, RBX, SizeOfHandlerRec
 	; todo: replace LEA by MOV when compiler supports this
 	; todo: replace LEA by MOV when compiler supports this
@@ -3834,7 +3834,7 @@ CODE{SYSTEM.AMD64}
 	REP MOVSB
 	REP MOVSB
 	POP RDI
 	POP RDI
 	POP RSI
 	POP RSI
-	POP RAX	
+	POP RAX
 
 
 
 
 
 

+ 2 - 2
source/BIOS.ATADisks.Mod

@@ -2253,7 +2253,7 @@ VAR idx, bus, dev, fkt: LONGINT;
 BEGIN
 BEGIN
 	idx := 0; Dot();
 	idx := 0; Dot();
 	WHILE PCI.FindPCIDevice(id, vendor, idx, bus, dev, fkt) = PCI.Done DO
 	WHILE PCI.FindPCIDevice(id, vendor, idx, bus, dev, fkt) = PCI.Done DO
-		Show("Found PCI device "); KernelLogHex(vendor, 4, 0); KernelLog.String(":"); KernelLogHex(id, 4, 0); KernelLog.Ln; 
+		Show("Found PCI device "); KernelLogHex(vendor, 4, 0); KernelLog.String(":"); KernelLogHex(id, 4, 0); KernelLog.Ln;
 		IdentifyController(bus, dev, fkt);
 		IdentifyController(bus, dev, fkt);
 		INC(idx);
 		INC(idx);
 	END;
 	END;
@@ -2265,7 +2265,7 @@ BEGIN
 	idx := 0; Dot();
 	idx := 0; Dot();
 	WHILE PCI.FindPCIClassCode(class, idx, bus, dev, fkt) = PCI.Done DO
 	WHILE PCI.FindPCIClassCode(class, idx, bus, dev, fkt) = PCI.Done DO
 		Show("Found PCI device on bus "); KernelLog.Int(bus, 0); KernelLog.String(", device "); KernelLog.Int(dev, 0);
 		Show("Found PCI device on bus "); KernelLog.Int(bus, 0); KernelLog.String(", device "); KernelLog.Int(dev, 0);
-		KernelLog.String(", function "); KernelLog.Int(fkt, 0); KernelLog.Ln; 
+		KernelLog.String(", function "); KernelLog.Int(fkt, 0); KernelLog.Ln;
 		IdentifyController(bus, dev, fkt);
 		IdentifyController(bus, dev, fkt);
 		INC(idx);
 		INC(idx);
 	END;
 	END;

+ 1 - 1
source/BIOS.Clock.Mod

@@ -101,7 +101,7 @@ TYPE
 				KernelLog.String("Clock: ClockMode = ");  KernelLog.Int(clockmode, 1);  KernelLog.Ln
 				KernelLog.String("Clock: ClockMode = ");  KernelLog.Int(clockmode, 1);  KernelLog.Ln
 			END
 			END
 		END InitClock;
 		END InitClock;
-		
+
 		PROCEDURE Terminate;
 		PROCEDURE Terminate;
 		BEGIN
 		BEGIN
 			IF clockmode # 1 THEN
 			IF clockmode # 1 THEN

+ 9 - 9
source/BIOS.I386.Machine.Mod

@@ -592,9 +592,9 @@ CONST
 	SSE2Flag = 26;
 	SSE2Flag = 26;
 	SSE3Flag = 0; (*IN features2 from ECX*) (*PH 04/11*)
 	SSE3Flag = 0; (*IN features2 from ECX*) (*PH 04/11*)
 	SSSE3Flag =9;
 	SSSE3Flag =9;
-	SSE41Flag =19; 
+	SSE41Flag =19;
 	SSE42Flag =20;
 	SSE42Flag =20;
-	SSE5Flag = 11; 
+	SSE5Flag = 11;
 	AVXFlag = 28;
 	AVXFlag = 28;
 BEGIN
 BEGIN
 	SSE2Support := FALSE;
 	SSE2Support := FALSE;
@@ -2085,7 +2085,7 @@ END InModuleHeap;
 (* returns if an address is a currently allocated heap address *)
 (* returns if an address is a currently allocated heap address *)
 PROCEDURE ValidHeapAddress*(p: ADDRESS): BOOLEAN;
 PROCEDURE ValidHeapAddress*(p: ADDRESS): BOOLEAN;
 BEGIN
 BEGIN
-	RETURN 
+	RETURN
 		(p >= memBlockHead.beginBlockAdr) & (p <= memBlockTail.endBlockAdr)
 		(p >= memBlockHead.beginBlockAdr) & (p <= memBlockTail.endBlockAdr)
 		OR InModuleHeap(p);
 		OR InModuleHeap(p);
 END ValidHeapAddress;
 END ValidHeapAddress;
@@ -3480,8 +3480,8 @@ VAR status: SHORTINT;
 	PROCEDURE Scroll;
 	PROCEDURE Scroll;
 	VAR adr: ADDRESS; off: SIZE; i,j: LONGINT;
 	VAR adr: ADDRESS; off: SIZE; i,j: LONGINT;
 	BEGIN
 	BEGIN
-		IF (traceDelay > 0) & (scrollLines MOD TraceHeight = 0) THEN 
-			FOR i := 0 TO traceDelay-1 DO 
+		IF (traceDelay > 0) & (scrollLines MOD TraceHeight = 0) THEN
+			FOR i := 0 TO traceDelay-1 DO
 				FOR j := 0 TO 1000000 DO END;
 				FOR j := 0 TO 1000000 DO END;
 			END;
 			END;
 		END;
 		END;
@@ -3525,7 +3525,7 @@ PROCEDURE TraceColor (c: SHORTINT);
 BEGIN traceColor := c;
 BEGIN traceColor := c;
 END TraceColor;
 END TraceColor;
 
 
-VAR traceDelay: LONGINT; 
+VAR traceDelay: LONGINT;
 (* Initialise tracing. *)
 (* Initialise tracing. *)
 PROCEDURE InitTrace;
 PROCEDURE InitTrace;
 CONST MaxPorts = 8;
 CONST MaxPorts = 8;
@@ -3544,8 +3544,8 @@ BEGIN
 		Portout8(3D5H, CHR((TraceWidth*TraceHeight) DIV 100H));
 		Portout8(3D5H, CHR((TraceWidth*TraceHeight) DIV 100H));
 		Portout8(3D4H, 0FX);
 		Portout8(3D4H, 0FX);
 		Portout8(3D5H, CHR((TraceWidth*TraceHeight) MOD 100H));
 		Portout8(3D5H, CHR((TraceWidth*TraceHeight) MOD 100H));
-		GetConfig("TraceDelay", s); 
-		p := 0; traceDelay := StrToInt(p, s); 
+		GetConfig("TraceDelay", s);
+		p := 0; traceDelay := StrToInt(p, s);
 
 
 	END;
 	END;
 	IF TraceV24 IN traceMode THEN
 	IF TraceV24 IN traceMode THEN
@@ -3594,7 +3594,7 @@ BEGIN (* no PAF --> no variables !! *)
 		MOV bootFlag, EAX
 		MOV bootFlag, EAX
 		MOV initRegs0,ESI
 		MOV initRegs0,ESI
 		MOV initRegs1, EDI
 		MOV initRegs1, EDI
-	END; 
+	END;
 	Init; (* call initializer as first action of the kernel *)
 	Init; (* call initializer as first action of the kernel *)
 END FirstAddress;
 END FirstAddress;
 
 

+ 3 - 3
source/BIOS.I386.Traps.Mod

@@ -90,17 +90,17 @@ VAR
 				w.String(", Locks: "); w.Set(exc.locks)
 				w.String(", Locks: "); w.Set(exc.locks)
 			END;
 			END;
 			w.Ln; w.String("System: "); w.String(Machine.version); w.String(" Kernel_CRC=");(* w.Hex(SystemVersion.BootCRC,8);*)
 			w.Ln; w.String("System: "); w.String(Machine.version); w.String(" Kernel_CRC=");(* w.Hex(SystemVersion.BootCRC,8);*)
-			IF long THEN 
+			IF long THEN
 				w.Char(0EX);	(* "fixed font" *)
 				w.Char(0EX);	(* "fixed font" *)
 				w.Ln;
 				w.Ln;
 				w.String("Processor:");
 				w.String("Processor:");
 				(* output values *)
 				(* output values *)
 				Val("CS", int.CS); Val("DS", exc.DS); Val("ES", exc.ES); Val("SS", exc.SS); Val("CR0", exc.CR[0]);
 				Val("CS", int.CS); Val("DS", exc.DS); Val("ES", exc.ES); Val("SS", exc.SS); Val("CR0", exc.CR[0]);
-				Val("FPU", SYSTEM.VAL(LONGINT, exc.FPU[1] * {0..15} + LSH(exc.FPU[2], 16))); 
+				Val("FPU", SYSTEM.VAL(LONGINT, exc.FPU[1] * {0..15} + LSH(exc.FPU[2], 16)));
 				Val("PC", int.PC); Val("ESI", int.ESI); Val("EDI", int.EDI); Val("SP", exc.SP); Val("CR2", exc.CR[2]);
 				Val("PC", int.PC); Val("ESI", int.ESI); Val("EDI", int.EDI); Val("SP", exc.SP); Val("CR2", exc.CR[2]);
 				Val("PID", id);
 				Val("PID", id);
 				Val("EAX", int.EAX); Val("EBX", int.EBX); Val("ECX", int.ECX); Val("EDX", int.EDX); Val("CR3", exc.CR[3]);
 				Val("EAX", int.EAX); Val("EBX", int.EBX); Val("ECX", int.ECX); Val("EDX", int.EDX); Val("CR3", exc.CR[3]);
-				Val("LCK", SYSTEM.VAL(LONGINT, exc.locks)); 
+				Val("LCK", SYSTEM.VAL(LONGINT, exc.locks));
 				Val("BP", int.BP); Val("FS", exc.FS); Val("GS", exc.GS); Val("ERR", int.ERR); Val("CR4", exc.CR[4]);
 				Val("BP", int.BP); Val("FS", exc.FS); Val("GS", exc.GS); Val("ERR", int.ERR); Val("CR4", exc.CR[4]);
 				Val("TMR", Kernel.GetTicks()); w.Ln;
 				Val("TMR", Kernel.GetTicks()); w.Ln;
 				IF SYSTEM.VAL(CHAR, exc.DR[7]) # 0X THEN	(* some breakpoints enabled *)
 				IF SYSTEM.VAL(CHAR, exc.DR[7]) # 0X THEN	(* some breakpoints enabled *)

+ 6 - 6
source/BIOS.MemCache.Mod

@@ -32,7 +32,7 @@ CODE
 	RDMSR
 	RDMSR
 #ELSE
 #ELSE
 	unimplemented
 	unimplemented
-#END	
+#END
 END GetMTTRcapLow;
 END GetMTTRcapLow;
 
 
 (*
 (*
@@ -49,7 +49,7 @@ CODE
 	RDMSR
 	RDMSR
 #ELSE
 #ELSE
 	unimplemented
 	unimplemented
-#END	
+#END
 END GetMTTRdefTypeLow;
 END GetMTTRdefTypeLow;
 *)
 *)
 
 
@@ -70,7 +70,7 @@ CODE
 	RDMSR
 	RDMSR
 #ELSE
 #ELSE
 	unimplemented
 	unimplemented
-#END	
+#END
 END GetMTTRphysBaseLow;
 END GetMTTRphysBaseLow;
 
 
 (* Return the value of the specified MTTRphysMask register. *)
 (* Return the value of the specified MTTRphysMask register. *)
@@ -90,7 +90,7 @@ CODE
 	RDMSR
 	RDMSR
 #ELSE
 #ELSE
 	unimplemented
 	unimplemented
-#END	
+#END
 END GetMTTRphysMaskLow;
 END GetMTTRphysMaskLow;
 
 
 (* Set the specified MTTRphysBase register. *)
 (* Set the specified MTTRphysBase register. *)
@@ -113,7 +113,7 @@ CODE
 	WRMSR
 	WRMSR
 #ELSE
 #ELSE
 	unimplemented
 	unimplemented
-#END	
+#END
 END SetMTTRphysBase;
 END SetMTTRphysBase;
 
 
 (* Set the specified MTTRphysMask register. *)
 (* Set the specified MTTRphysMask register. *)
@@ -136,7 +136,7 @@ CODE
 	WRMSR
 	WRMSR
 #ELSE
 #ELSE
 	unimplemented
 	unimplemented
-#END	
+#END
 END SetMTTRphysMask;
 END SetMTTRphysMask;
 
 
 (** Set the cache properties of the specified physical memory area on the current processor. {physAdr, size MOD PS = 0}  Must be called from supervisor mode. *)
 (** Set the cache properties of the specified physical memory area on the current processor. {physAdr, size MOD PS = 0}  Must be called from supervisor mode. *)

+ 8 - 8
source/BIOS.Objects.Mod

@@ -690,7 +690,7 @@ PROCEDURE CurrentProcess*( ): Process;
 BEGIN
 BEGIN
 	RETURN SYSTEM.VAL(Process, Machine.GetProcessPtr());
 	RETURN SYSTEM.VAL(Process, Machine.GetProcessPtr());
 END CurrentProcess;
 END CurrentProcess;
-	
+
 PROCEDURE CurrentContext*(): ANY;
 PROCEDURE CurrentContext*(): ANY;
 VAR p: Process;
 VAR p: Process;
 BEGIN
 BEGIN
@@ -827,16 +827,16 @@ BEGIN
 			processingIRQ[state.INT-MinIRQ] := TRUE;
 			processingIRQ[state.INT-MinIRQ] := TRUE;
 		END;
 		END;
 	END;
 	END;
-	
+
 	(* if the reenabling of interrupts cannot be circumvented, then it is REQUIRED to acknowledge interrupts
 	(* if the reenabling of interrupts cannot be circumvented, then it is REQUIRED to acknowledge interrupts
 		BEFORE reenabling. Otherwise spurious IRQs cannot be identified as such.
 		BEFORE reenabling. Otherwise spurious IRQs cannot be identified as such.
 		Please note that this particular problem with spurious IRQs cannot observed on many machines but IF it is observed
 		Please note that this particular problem with spurious IRQs cannot observed on many machines but IF it is observed
 		then the machine will behave unexpected. Very hard to debug and trace!
 		then the machine will behave unexpected. Very hard to debug and trace!
 
 
-		Machine.Ack(state.INT); 
+		Machine.Ack(state.INT);
 		Machine.Sti ();	(* avoid Processors.StopAll deadlock when waiting for locks below (remove this) *)
 		Machine.Sti ();	(* avoid Processors.StopAll deadlock when waiting for locks below (remove this) *)
 	*)
 	*)
-	
+
 	Machine.Acquire(Machine.Objects);
 	Machine.Acquire(Machine.Objects);
 	t := interrupt[state.INT-MinIRQ].process;
 	t := interrupt[state.INT-MinIRQ].process;
 	IF StrongChecks THEN ASSERT(t.mode = AwaitingEvent) END;
 	IF StrongChecks THEN ASSERT(t.mode = AwaitingEvent) END;
@@ -1007,8 +1007,8 @@ PROCEDURE CancelTimeout*(t: Timer);
 BEGIN
 BEGIN
 	Machine.Acquire(Machine.Objects);
 	Machine.Acquire(Machine.Objects);
 	ASSERT(t # event);
 	ASSERT(t # event);
-	IF t.next # NIL THEN 
-		t.next.prev := t.prev; 
+	IF t.next # NIL THEN
+		t.next.prev := t.prev;
 		IF t.prev #NIL THEN t.prev.next := t.next END;
 		IF t.prev #NIL THEN t.prev.next := t.next END;
 	END;
 	END;
 	t.next := NIL; t.prev := NIL;
 	t.next := NIL; t.prev := NIL;
@@ -1161,7 +1161,7 @@ BEGIN
 END TerminateThis;
 END TerminateThis;
 
 
 (* called by WMProcessInfo to obtain the current state of a running process *)
 (* called by WMProcessInfo to obtain the current state of a running process *)
-PROCEDURE UpdateProcessState*( p: Process );	
+PROCEDURE UpdateProcessState*( p: Process );
 BEGIN
 BEGIN
 	(*  update p.stat.{PC,BP,SP}  *)
 	(*  update p.stat.{PC,BP,SP}  *)
 END UpdateProcessState;
 END UpdateProcessState;
@@ -1801,7 +1801,7 @@ END InitPrioRequest;
 VAR
 VAR
 	(* for compatibility and later extension *)
 	(* for compatibility and later extension *)
 	TraceProcessHook*: PROCEDURE (prcoess: Process; pc, bp: ADDRESS; stacklow, stackhigh: ADDRESS);
 	TraceProcessHook*: PROCEDURE (prcoess: Process; pc, bp: ADDRESS; stacklow, stackhigh: ADDRESS);
-	
+
 BEGIN
 BEGIN
 	TraceProcessHook := NIL;
 	TraceProcessHook := NIL;
 	IF Stats THEN InitStats; END;
 	IF Stats THEN InitStats; END;

+ 10 - 10
source/BIOS.PCI.Mod

@@ -91,11 +91,11 @@ MODULE PCI;	 (** author: fof -- PCI without using PCI bios (using PCI tables des
 						IF idx = index THEN
 						IF idx = index THEN
 							busNr := pci.bus; devNr := pci.device; fktNr := pci.function;
 							busNr := pci.bus; devNr := pci.device; fktNr := pci.function;
 							IF debug THEN
 							IF debug THEN
-								KernelLog.String("FindPCIDevice "); 
-								KernelLog.Int(devId,1); KernelLog.String(", "); 
-								KernelLog.Int(vendId,1); KernelLog.String(","); 
+								KernelLog.String("FindPCIDevice ");
+								KernelLog.Int(devId,1); KernelLog.String(", ");
+								KernelLog.Int(vendId,1); KernelLog.String(",");
 								KernelLog.Int(idx,1);
 								KernelLog.Int(idx,1);
-								KernelLog.String(" found."); KernelLog.Ln; 
+								KernelLog.String(" found."); KernelLog.Ln;
 							END;
 							END;
 							RETURN Done
 							RETURN Done
 						ELSE INC(index)
 						ELSE INC(index)
@@ -124,9 +124,9 @@ MODULE PCI;	 (** author: fof -- PCI without using PCI bios (using PCI tables des
 						IF idx = index THEN
 						IF idx = index THEN
 							busNr := pci.bus; devNr := pci.device; fktNr := pci.function;
 							busNr := pci.bus; devNr := pci.device; fktNr := pci.function;
 							IF debug THEN
 							IF debug THEN
-								KernelLog.String("FindPCIClassCode "); 
+								KernelLog.String("FindPCIClassCode ");
 								KernelLog.Int(classCode,1); KernelLog.String(","); KernelLog.Int(idx,1);
 								KernelLog.Int(classCode,1); KernelLog.String(","); KernelLog.Int(idx,1);
-								KernelLog.String(" found."); KernelLog.Ln; 
+								KernelLog.String(" found."); KernelLog.Ln;
 							END;
 							END;
 							RETURN Done
 							RETURN Done
 						ELSE INC(index)
 						ELSE INC(index)
@@ -465,7 +465,7 @@ MODULE PCI;	 (** author: fof -- PCI without using PCI bios (using PCI tables des
 		ELSE multifunction := TRUE
 		ELSE multifunction := TRUE
 		END;
 		END;
 		INC(pci.function);
 		INC(pci.function);
-		
+
 		IF ~multifunction OR (pci.function >= 8) THEN
 		IF ~multifunction OR (pci.function >= 8) THEN
 			pci.function := 0;
 			pci.function := 0;
 			INC(pci.device);
 			INC(pci.device);
@@ -613,7 +613,7 @@ MODULE PCI;	 (** author: fof -- PCI without using PCI bios (using PCI tables des
 						KernelLog.String(" class="); KernelLog.Int(class,1);
 						KernelLog.String(" class="); KernelLog.Int(class,1);
 						KernelLog.String(" subclass="); KernelLog.Int(subclass,1);
 						KernelLog.String(" subclass="); KernelLog.Int(subclass,1);
 						KernelLog.String(" api="); KernelLog.Int(api,1);
 						KernelLog.String(" api="); KernelLog.Int(api,1);
-						KernelLog.String(" classCode= "); KernelLog.Address(r8 DIV 100H MOD 1000000H); 
+						KernelLog.String(" classCode= "); KernelLog.Address(r8 DIV 100H MOD 1000000H);
 						KernelLog.String(" : ");
 						KernelLog.String(" : ");
 						DisplayDeviceClass(class, subclass);
 						DisplayDeviceClass(class, subclass);
 						KernelLog.Ln;
 						KernelLog.Ln;
@@ -642,10 +642,10 @@ BEGIN
 	Show;
 	Show;
 END PCI.
 END PCI.
 
 
-useful sources: 
+useful sources:
 
 
 http://tldp.org/LDP/tlk/dd/pci.html
 http://tldp.org/LDP/tlk/dd/pci.html
-http://my.execpc.com/~geezer/code/pci.c 
+http://my.execpc.com/~geezer/code/pci.c
 
 
 
 
 (**
 (**

+ 24 - 24
source/BIOS.WebNetworkTimeProtocol.Mod

@@ -1,17 +1,17 @@
 MODULE WebNetworkTimeProtocol; (** AUTHOR "Patrick Hunziker"; PURPOSE "SimpleNetworkTimeProtocol RFC4330 and NetworkTimeProtocol RFC5905 "; *)
 MODULE WebNetworkTimeProtocol; (** AUTHOR "Patrick Hunziker"; PURPOSE "SimpleNetworkTimeProtocol RFC4330 and NetworkTimeProtocol RFC5905 "; *)
 
 
 (**
 (**
-NTP operates over the User Datagram Protocol (UDP). An NTP server listens for client NTP packets on port 123. 
-The NTP server is stateless and responds to each received client NTP packet in a simple transactional manner 
+NTP operates over the User Datagram Protocol (UDP). An NTP server listens for client NTP packets on port 123.
+The NTP server is stateless and responds to each received client NTP packet in a simple transactional manner
 by adding fields to the received packet and passing the packet back to the original sender, without reference to preceding NTP transactions.
 by adding fields to the received packet and passing the packet back to the original sender, without reference to preceding NTP transactions.
 
 
-Upon receipt of a client NTP packet, the receiver time-stamps receipt of the packet as soon as possible within the packet assembly logic of the server. 
-The packet is then passed to the NTP server process. 
-This process interchanges the IP Header Address and Port fields in the packet, overwrites numerous fields in the NTP packet with local clock values, 
+Upon receipt of a client NTP packet, the receiver time-stamps receipt of the packet as soon as possible within the packet assembly logic of the server.
+The packet is then passed to the NTP server process.
+This process interchanges the IP Header Address and Port fields in the packet, overwrites numerous fields in the NTP packet with local clock values,
 time-stamps the egress of the packet, recalculates the checksum, and sends the packet back to the client.
 time-stamps the egress of the packet, recalculates the checksum, and sends the packet back to the client.
 
 
-Time is given as 64-bit time-stamp value. 
-This value is an unsigned 32-bit seconds value, and a 32-bit fractional part. 
+Time is given as 64-bit time-stamp value.
+This value is an unsigned 32-bit seconds value, and a 32-bit fractional part.
 The unit of time is in seconds, and the epoch is 1 January 1900, meaning that the NTP time will cycle in the year 2036 (two years before the 32-bit Unix time cycle event in 2038).
 The unit of time is in seconds, and the epoch is 1 January 1900, meaning that the NTP time will cycle in the year 2036 (two years before the 32-bit Unix time cycle event in 2038).
 
 
 for best NTP server pools for a given region see wikipedia: NTP-Pool
 for best NTP server pools for a given region see wikipedia: NTP-Pool
@@ -67,8 +67,8 @@ BEGIN
 		sw.Net32(LONGINT(packet.TransmitTimestamp DIV 100000000H));    sw.Net32(LONGINT(packet.TransmitTimestamp MOD 100000000H));
 		sw.Net32(LONGINT(packet.TransmitTimestamp DIV 100000000H));    sw.Net32(LONGINT(packet.TransmitTimestamp MOD 100000000H));
 		sw.Update;
 		sw.Update;
 		sw.GetRaw(buf, len);
 		sw.GetRaw(buf, len);
-		socket.Send( fip, fport, buf, 0, 48, res );  
-		
+		socket.Send( fip, fport, buf, 0, 48, res );
+
 		socket.Receive(buf,0,48, 1000, fip1, fport1, len, res);
 		socket.Receive(buf,0,48, 1000, fip1, fport1, len, res);
 		IF (res=UDP.Ok)&(len>=48) THEN (* receive the modified NTP record *)
 		IF (res=UDP.Ok)&(len>=48) THEN (* receive the modified NTP record *)
 			NEW(sr,1024);
 			NEW(sr,1024);
@@ -93,18 +93,18 @@ END Get;
 PROCEDURE SetSystemTime* (time: HUGEINT; timeZone, daylightSaving: LONGINT);
 PROCEDURE SetSystemTime* (time: HUGEINT; timeZone, daylightSaving: LONGINT);
 VAR dt: Dates.DateTime; frac:HUGEINT;
 VAR dt: Dates.DateTime; frac:HUGEINT;
 BEGIN {EXCLUSIVE}
 BEGIN {EXCLUSIVE}
-		frac:=time MOD 100000000H; 
-	time:=time DIV 100000000H MOD 100000000H; 
+		frac:=time MOD 100000000H;
+	time:=time DIV 100000000H MOD 100000000H;
 	dt:=Dates.ZeroDateNTP;
 	dt:=Dates.ZeroDateNTP;
 	Dates.AddSeconds(dt, LONGINT(time MOD (60*60*24)));
 	Dates.AddSeconds(dt, LONGINT(time MOD (60*60*24)));
 	Dates.AddMinutes(dt, timeZone+daylightSaving);
 	Dates.AddMinutes(dt, timeZone+daylightSaving);
 	time:=time DIV (60*60*24);
 	time:=time DIV (60*60*24);
 	Dates.AddDays(dt, LONGINT(time));
 	Dates.AddDays(dt, LONGINT(time));
-	
+
 	Machine.PutNVByte(0BH, 82X);	(* disable clock & interrupt *)
 	Machine.PutNVByte(0BH, 82X);	(* disable clock & interrupt *)
-	Machine.PutNVByte(0, CHR(dt.seconds0)); 
-	Machine.PutNVByte(2, CHR(dt.minutes)); 
-	Machine.PutNVByte(4, CHR(dt.hours)); 
+	Machine.PutNVByte(0, CHR(dt.seconds0));
+	Machine.PutNVByte(2, CHR(dt.minutes));
+	Machine.PutNVByte(4, CHR(dt.hours));
 	Machine.PutNVByte(7, CHR(dt.day));
 	Machine.PutNVByte(7, CHR(dt.day));
 	Machine.PutNVByte(8, CHR(dt.month));
 	Machine.PutNVByte(8, CHR(dt.month));
 	Machine.PutNVByte(9, CHR(dt.year));
 	Machine.PutNVByte(9, CHR(dt.year));
@@ -130,26 +130,26 @@ BEGIN
 	DNS.HostByName("0.ch.pool.ntp.org", fip, port);
 	DNS.HostByName("0.ch.pool.ntp.org", fip, port);
 	Get(fip, NTPPort, packet, res);
 	Get(fip, NTPPort, packet, res);
 	IF res=UDP.Ok THEN
 	IF res=UDP.Ok THEN
-		SetSystemTime(packet.TransmitTimestamp, 60, 60);  
-		context.out.String("Set system time to "); 
-		context.out.Int(packet.TransmitTimestamp  MOD 100000000H, 16); 
-		context.out.Int(packet.TransmitTimestamp  DIV 100000000H MOD 100000000H, 16); 
-		context.out.Ln; context.out.Update; 
+		SetSystemTime(packet.TransmitTimestamp, 60, 60);
+		context.out.String("Set system time to ");
+		context.out.Int(packet.TransmitTimestamp  MOD 100000000H, 16);
+		context.out.Int(packet.TransmitTimestamp  DIV 100000000H MOD 100000000H, 16);
+		context.out.Ln; context.out.Update;
 	END;
 	END;
 END SynchronizeSNTP;
 END SynchronizeSNTP;
 
 
 
 
 PROCEDURE GetSimpleTime*(context:Commands.Context);
 PROCEDURE GetSimpleTime*(context:Commands.Context);
 VAR ipstr: ARRAY 64 OF CHAR; port, res, i:LONGINT;machineTimer1,machineTimer2: HUGEINT; fip: IP.Adr; packet:Packet;
 VAR ipstr: ARRAY 64 OF CHAR; port, res, i:LONGINT;machineTimer1,machineTimer2: HUGEINT; fip: IP.Adr; packet:Packet;
-BEGIN 
-	
+BEGIN
+
 	IF ~context.arg.GetString(ipstr) THEN	Configuration.Get("NTP.Server0",ipstr,res); END;
 	IF ~context.arg.GetString(ipstr) THEN	Configuration.Get("NTP.Server0",ipstr,res); END;
 	(* note that DNS.HostByName might also deliver a default NTP server when an empty string and an NTP port number is given*)
 	(* note that DNS.HostByName might also deliver a default NTP server when an empty string and an NTP port number is given*)
 	DNS.HostByName(ipstr, fip, port);
 	DNS.HostByName(ipstr, fip, port);
-	
+
 	IF ~context.arg.GetInteger(port,FALSE) THEN port:=NTPPort END;
 	IF ~context.arg.GetInteger(port,FALSE) THEN port:=NTPPort END;
 	Get(fip, port, packet, res);
 	Get(fip, port, packet, res);
-	
+
 	context.out.String("checking server "); context.out.String(ipstr);context.out.Char(":"); context.out.Int(port,0);  context.out.Ln; context.out.Update;
 	context.out.String("checking server "); context.out.String(ipstr);context.out.Char(":"); context.out.Int(port,0);  context.out.Ln; context.out.Update;
 	context.out.String("SNTP result, transmit time [seconds.fraction]: "); context.out.Ln;
 	context.out.String("SNTP result, transmit time [seconds.fraction]: "); context.out.Ln;
 
 

+ 2 - 2
source/BSplineCurves.Mod

@@ -214,7 +214,7 @@ TYPE
 			closed - TRUE for closed curve
 			closed - TRUE for closed curve
 		*)
 		*)
 		PROCEDURE &Init*(degree: LONGINT; closed: BOOLEAN);
 		PROCEDURE &Init*(degree: LONGINT; closed: BOOLEAN);
-		BEGIN		
+		BEGIN
 			IF closed THEN boundary := Periodic; ELSE boundary := MirrorW; END;
 			IF closed THEN boundary := Periodic; ELSE boundary := MirrorW; END;
 
 
 			IF degree > 1 THEN
 			IF degree > 1 THEN
@@ -646,6 +646,6 @@ TYPE
 		ELSE
 		ELSE
 			RETURN 0;
 			RETURN 0;
 		END;
 		END;
-	END IPower;	
+	END IPower;
 
 
 END BSplineCurves.
 END BSplineCurves.

+ 2 - 2
source/BenchTCP.Mod

@@ -74,7 +74,7 @@ TYPE
 					KernelLog.Int(time MOD 60,6); time:=time DIV 60; KernelLog.String("min");
 					KernelLog.Int(time MOD 60,6); time:=time DIV 60; KernelLog.String("min");
 					KernelLog.Int(time MOD 24,6); time:=time DIV 24; KernelLog.String("hh");
 					KernelLog.Int(time MOD 24,6); time:=time DIV 24; KernelLog.String("hh");
 					KernelLog.Int(time,7);  KernelLog.String("days since 1.1.1900");
 					KernelLog.Int(time,7);  KernelLog.String("days since 1.1.1900");
-					KernelLog.Ln;   
+					KernelLog.Ln;
 				ELSE
 				ELSE
 					NEW(sender, c, buf, num);
 					NEW(sender, c, buf, num);
 					IF port = EchoPort THEN
 					IF port = EchoPort THEN
@@ -82,7 +82,7 @@ TYPE
 						WHILE (res = 0) & (num > 0) DO
 						WHILE (res = 0) & (num > 0) DO
 							num0 := LEN(buf^) DIV 1024;
 							num0 := LEN(buf^) DIV 1024;
 							IF num0 > num THEN num0 := num END;
 							IF num0 > num THEN num0 := num END;
-							
+
 							c.Receive(buf^, 0, num0*1024, num0*1024, len, res);
 							c.Receive(buf^, 0, num0*1024, num0*1024, len, res);
 							DEC(num, num0)
 							DEC(num, num0)
 						END
 						END

+ 1 - 1
source/BitSets.Mod

@@ -74,7 +74,7 @@ TYPE BitSet* = OBJECT
 			END;
 			END;
 		END;
 		END;
 	END SetBits;
 	END SetBits;
-	
+
 	PROCEDURE SetBytes*(startPos, bytes: SIZE; CONST values: ARRAY OF CHAR);
 	PROCEDURE SetBytes*(startPos, bytes: SIZE; CONST values: ARRAY OF CHAR);
 	VAR adr: ADDRESS;
 	VAR adr: ADDRESS;
 	BEGIN
 	BEGIN

+ 52 - 52
source/BorrowsWheeler.Mod

@@ -1,18 +1,18 @@
 MODULE BorrowsWheeler;  (** AUTHOR GF; PURPOSE  "Borrows Wheeler Transformation"; *)
 MODULE BorrowsWheeler;  (** AUTHOR GF; PURPOSE  "Borrows Wheeler Transformation"; *)
-	
+
 CONST
 CONST
 	BlockSize* = 8*1024;
 	BlockSize* = 8*1024;
-	
-TYPE 	
+
+TYPE
 	MTF = OBJECT (* move to front *)
 	MTF = OBJECT (* move to front *)
-		TYPE 
+		TYPE
 			Node = POINTER TO RECORD
 			Node = POINTER TO RECORD
 				byte: CHAR;  next: Node
 				byte: CHAR;  next: Node
 			END;
 			END;
 		VAR
 		VAR
 			alpha: Node;
 			alpha: Node;
-			
-			
+
+
 			PROCEDURE Initialize;
 			PROCEDURE Initialize;
 			VAR n: Node;  i: LONGINT;
 			VAR n: Node;  i: LONGINT;
 			BEGIN
 			BEGIN
@@ -31,33 +31,33 @@ TYPE
 					IF alpha.byte = ch THEN  k := 0
 					IF alpha.byte = ch THEN  k := 0
 					ELSE
 					ELSE
 						l := alpha;  m := alpha.next;  k := 1;
 						l := alpha;  m := alpha.next;  k := 1;
-						WHILE m.byte # ch DO  
-							INC( k );  l := m;  m := m.next  
+						WHILE m.byte # ch DO
+							INC( k );  l := m;  m := m.next
 						END;
 						END;
 						l.next := m.next;  m.next := alpha;  alpha := m
 						l.next := m.next;  m.next := alpha;  alpha := m
 					END;
 					END;
 					buf[i] := CHR( k )
 					buf[i] := CHR( k )
 				END
 				END
 			END Encode;
 			END Encode;
-			
+
 			PROCEDURE Decode( VAR buf: ARRAY OF CHAR; len: LONGINT );
 			PROCEDURE Decode( VAR buf: ARRAY OF CHAR; len: LONGINT );
 			VAR l, m: Node;  i, c: LONGINT;  ch: CHAR;
 			VAR l, m: Node;  i, c: LONGINT;  ch: CHAR;
 			BEGIN
 			BEGIN
 				Initialize;
 				Initialize;
 				FOR i := 0 TO len - 1 DO
 				FOR i := 0 TO len - 1 DO
 					ch := buf[i];
 					ch := buf[i];
-					IF ch # 0X THEN 
+					IF ch # 0X THEN
 						c := ORD( ch );  l := alpha;
 						c := ORD( ch );  l := alpha;
 						WHILE c > 1 DO  l := l.next;  DEC( c )  END;
 						WHILE c > 1 DO  l := l.next;  DEC( c )  END;
-						m := l.next;  l.next := m.next;  m.next := alpha;  
+						m := l.next;  l.next := m.next;  m.next := alpha;
 						alpha := m
 						alpha := m
 					END;
 					END;
 					buf[i] := alpha.byte;
 					buf[i] := alpha.byte;
 				END
 				END
 			END Decode;
 			END Decode;
-	
+
 	END MTF;
 	END MTF;
-	
+
 TYPE
 TYPE
 	Encoder* = OBJECT
 	Encoder* = OBJECT
 		TYPE
 		TYPE
@@ -66,40 +66,40 @@ TYPE
 			mtf: MTF;  length: LONGINT;
 			mtf: MTF;  length: LONGINT;
 			sbuf: ARRAY 2*BlockSize OF CHAR;
 			sbuf: ARRAY 2*BlockSize OF CHAR;
 			rotation: ARRAY BlockSize OF Index;
 			rotation: ARRAY BlockSize OF Index;
-			
+
 			PROCEDURE &New*;
 			PROCEDURE &New*;
 			BEGIN
 			BEGIN
 				NEW( mtf );
 				NEW( mtf );
 			END New;
 			END New;
-			
-	
+
+
 			PROCEDURE Less( a, b: Index ): BOOLEAN;
 			PROCEDURE Less( a, b: Index ): BOOLEAN;
-			VAR i1, i2: Index;  n, diff: LONGINT;  
+			VAR i1, i2: Index;  n, diff: LONGINT;
 			BEGIN
 			BEGIN
 				n := 0;  i1 := rotation[a];  i2 := rotation[b];
 				n := 0;  i1 := rotation[a];  i2 := rotation[b];
 				REPEAT
 				REPEAT
 					diff := ORD( sbuf[i1]) - ORD( sbuf[i2] );
 					diff := ORD( sbuf[i1]) - ORD( sbuf[i2] );
-					INC( i1 );  INC( i2 );  INC( n ); 
+					INC( i1 );  INC( i2 );  INC( n );
 				UNTIL (diff # 0) OR (n = length);
 				UNTIL (diff # 0) OR (n = length);
 				RETURN diff < 0
 				RETURN diff < 0
 			END Less;
 			END Less;
-			
+
 			PROCEDURE Swap( a, b: Index );
 			PROCEDURE Swap( a, b: Index );
 			VAR  tmp: Index;
 			VAR  tmp: Index;
 			BEGIN
 			BEGIN
 				tmp := rotation[a];  rotation[a] := rotation[b];  rotation[b] := tmp
 				tmp := rotation[a];  rotation[a] := rotation[b];  rotation[b] := tmp
 			END Swap;
 			END Swap;
-			
+
 			PROCEDURE InsertSort( lo, hi: Index );
 			PROCEDURE InsertSort( lo, hi: Index );
-			VAR x, i, l, h, m, ip, tmp: Index; 
+			VAR x, i, l, h, m, ip, tmp: Index;
 			BEGIN
 			BEGIN
-				x := lo + 1; 
+				x := lo + 1;
 				WHILE x <= hi DO
 				WHILE x <= hi DO
 					IF Less( x, x - 1 )  THEN
 					IF Less( x, x - 1 )  THEN
 						(* find insert position ip *)
 						(* find insert position ip *)
 						ip := x - 1;  l := lo;  h := ip - 1;
 						ip := x - 1;  l := lo;  h := ip - 1;
 						WHILE l <= h DO
 						WHILE l <= h DO
-							m := (l + h) DIV 2; 
+							m := (l + h) DIV 2;
 							IF Less( x, m ) THEN  ip := m;  h := m - 1  ELSE  l := m + 1  END
 							IF Less( x, m ) THEN  ip := m;  h := m - 1  ELSE  l := m + 1  END
 						END;
 						END;
 						(* insert rotation[x] at position ip*)
 						(* insert rotation[x] at position ip*)
@@ -110,21 +110,21 @@ TYPE
 					INC( x )
 					INC( x )
 				END
 				END
 			END InsertSort;
 			END InsertSort;
-			
+
 			PROCEDURE SortR( lo, hi: LONGINT );
 			PROCEDURE SortR( lo, hi: LONGINT );
 			VAR i, j, m, n: LONGINT;
 			VAR i, j, m, n: LONGINT;
 			BEGIN
 			BEGIN
 				IF lo < hi THEN
 				IF lo < hi THEN
 					n := hi - lo + 1;
 					n := hi - lo + 1;
-					IF n = 2 THEN 
+					IF n = 2 THEN
 						IF Less( hi, lo ) THEN  Swap( lo, hi )  END
 						IF Less( hi, lo ) THEN  Swap( lo, hi )  END
-					ELSIF n < 16 THEN  
+					ELSIF n < 16 THEN
 						InsertSort( lo, hi )  (* less expensive string compares! *)
 						InsertSort( lo, hi )  (* less expensive string compares! *)
 					ELSE
 					ELSE
 						(* QuickSort *)
 						(* QuickSort *)
 						i := lo;  j := hi;  m := (lo + hi) DIV 2;
 						i := lo;  j := hi;  m := (lo + hi) DIV 2;
 						REPEAT
 						REPEAT
-							WHILE Less( i, m ) DO  INC( i )  END;  
+							WHILE Less( i, m ) DO  INC( i )  END;
 							WHILE Less( m, j ) DO  DEC( j )  END;
 							WHILE Less( m, j ) DO  DEC( j )  END;
 							IF i <= j THEN
 							IF i <= j THEN
 								IF m = i THEN  m := j  ELSIF  m = j THEN  m := i  END;
 								IF m = i THEN  m := j  ELSIF  m = j THEN  m := i  END;
@@ -135,12 +135,12 @@ TYPE
 					END
 					END
 				END
 				END
 			END SortR;
 			END SortR;
-	
+
 			PROCEDURE EncodeBlock*( VAR buf: ARRAY OF CHAR; len: LONGINT ): LONGINT;
 			PROCEDURE EncodeBlock*( VAR buf: ARRAY OF CHAR; len: LONGINT ): LONGINT;
-			VAR  i, index: LONGINT;  
+			VAR  i, index: LONGINT;
 			BEGIN
 			BEGIN
 				ASSERT( len <= BlockSize );  length := len;
 				ASSERT( len <= BlockSize );  length := len;
-				FOR i := 0 TO length - 1 DO  sbuf[i] := buf[i];  sbuf[i+length] := buf[i]  END; 
+				FOR i := 0 TO length - 1 DO  sbuf[i] := buf[i];  sbuf[i+length] := buf[i]  END;
 				FOR i := 0 TO length - 1 DO  rotation[i] := INTEGER( i )  END;
 				FOR i := 0 TO length - 1 DO  rotation[i] := INTEGER( i )  END;
 				SortR( 0, length - 1 );
 				SortR( 0, length - 1 );
 				(* find index of the original row *)
 				(* find index of the original row *)
@@ -150,43 +150,43 @@ TYPE
 				mtf.Encode( buf, length );
 				mtf.Encode( buf, length );
 				RETURN index
 				RETURN index
 			END EncodeBlock;
 			END EncodeBlock;
-			
+
 	END Encoder;
 	END Encoder;
-			
-				
+
+
 TYPE
 TYPE
 	Decoder* = OBJECT
 	Decoder* = OBJECT
 		TYPE
 		TYPE
 			Index = LONGINT;
 			Index = LONGINT;
 		VAR
 		VAR
 			mtf: MTF;
 			mtf: MTF;
-			f, l: ARRAY BlockSize OF CHAR; 
+			f, l: ARRAY BlockSize OF CHAR;
 			lc, fc: ARRAY BlockSize OF INTEGER;
 			lc, fc: ARRAY BlockSize OF INTEGER;
-			
+
 			PROCEDURE &New*;
 			PROCEDURE &New*;
 			BEGIN
 			BEGIN
 				NEW( mtf );
 				NEW( mtf );
 			END New;
 			END New;
-			
-			
+
+
 			PROCEDURE -Swap( a, b: Index );
 			PROCEDURE -Swap( a, b: Index );
 			VAR  tmp: CHAR;
 			VAR  tmp: CHAR;
 			BEGIN
 			BEGIN
 				tmp := f[a];  f[a] := f[b];  f[b] := tmp
 				tmp := f[a];  f[a] := f[b];  f[b] := tmp
 			END Swap;
 			END Swap;
-			
-			
+
+
 			PROCEDURE SortF( lo, hi: Index );
 			PROCEDURE SortF( lo, hi: Index );
-			VAR i, j, m: Index;  
+			VAR i, j, m: Index;
 			BEGIN
 			BEGIN
 				IF lo < hi THEN
 				IF lo < hi THEN
-					IF (hi - lo) = 1 THEN 
+					IF (hi - lo) = 1 THEN
 						IF f[hi] < f[lo] THEN  Swap( lo, hi )  END;
 						IF f[hi] < f[lo] THEN  Swap( lo, hi )  END;
 					ELSE
 					ELSE
 						(* QuickSort *)
 						(* QuickSort *)
-						i := lo;  j := hi;  m := (lo + hi) DIV 2; 
+						i := lo;  j := hi;  m := (lo + hi) DIV 2;
 						REPEAT
 						REPEAT
-							WHILE f[i] < f[m] DO  INC( i )  END;  
+							WHILE f[i] < f[m] DO  INC( i )  END;
 							WHILE f[m] < f[j] DO  DEC( j )  END;
 							WHILE f[m] < f[j] DO  DEC( j )  END;
 							IF i <= j THEN
 							IF i <= j THEN
 								IF m = i THEN  m := j  ELSIF m = j THEN  m := i  END;
 								IF m = i THEN  m := j  ELSIF m = j THEN  m := i  END;
@@ -197,23 +197,23 @@ TYPE
 					END
 					END
 				END
 				END
 			END SortF;
 			END SortF;
-			
-			
+
+
 			PROCEDURE DecodeBlock*( VAR buf: ARRAY OF CHAR; len, index: LONGINT );
 			PROCEDURE DecodeBlock*( VAR buf: ARRAY OF CHAR; len, index: LONGINT );
-			VAR 
+			VAR
 				i, j, n: LONGINT;  ch: CHAR;
 				i, j, n: LONGINT;  ch: CHAR;
-				xn: ARRAY 256 OF INTEGER;  
+				xn: ARRAY 256 OF INTEGER;
 			BEGIN
 			BEGIN
 				ASSERT( len <= BlockSize );
 				ASSERT( len <= BlockSize );
 				mtf.Decode( buf, len );
 				mtf.Decode( buf, len );
 				FOR i := 0 TO 255 DO  xn[i] := 0  END;
 				FOR i := 0 TO 255 DO  xn[i] := 0  END;
-				FOR i := 0 TO len - 1 DO 
+				FOR i := 0 TO len - 1 DO
 					l[i] := buf[i];  f[i] := buf[i];
 					l[i] := buf[i];  f[i] := buf[i];
 					j := ORD( l[i] );  lc[i] := xn[j];  INC( xn[j] )
 					j := ORD( l[i] );  lc[i] := xn[j];  INC( xn[j] )
 				END;
 				END;
 				SortF( 0, len - 1 );
 				SortF( 0, len - 1 );
 				FOR i := 0 TO 255 DO  xn[i] := 0  END;
 				FOR i := 0 TO 255 DO  xn[i] := 0  END;
-				FOR i := 0 TO len - 1 DO 
+				FOR i := 0 TO len - 1 DO
 					j := ORD( f[i] );  fc[i] := xn[j];  INC( xn[j] )
 					j := ORD( f[i] );  fc[i] := xn[j];  INC( xn[j] )
 				END;
 				END;
 				FOR i := 0 TO len - 1 DO
 				FOR i := 0 TO len - 1 DO
@@ -221,8 +221,8 @@ TYPE
 					WHILE (l[index] # ch) OR (lc[index] # n) DO  INC( index )  END
 					WHILE (l[index] # ch) OR (lc[index] # n) DO  INC( index )  END
 				END;
 				END;
 			END DecodeBlock;
 			END DecodeBlock;
-			
+
 	END Decoder;
 	END Decoder;
-	
-	
+
+
 END BorrowsWheeler.
 END BorrowsWheeler.

+ 5 - 5
source/CPU.Mod

@@ -238,7 +238,7 @@ BEGIN {UNCOOPERATIVE, UNCHECKED}
 	SYSTEM.SetActivity (NIL);
 	SYSTEM.SetActivity (NIL);
 
 
 	IF handlers[index] # NIL THEN handlers[index] (index) ELSE HALT (1234) END;
 	IF handlers[index] # NIL THEN handlers[index] (index) ELSE HALT (1234) END;
-	
+
 	IF index >= IRQ8 THEN
 	IF index >= IRQ8 THEN
 		OutByte (PIC2CommandPort, PIC_EOI); OutByte (PIC1CommandPort, PIC_EOI);
 		OutByte (PIC2CommandPort, PIC_EOI); OutByte (PIC1CommandPort, PIC_EOI);
 	ELSIF index >= IRQ0 THEN
 	ELSIF index >= IRQ0 THEN
@@ -319,7 +319,7 @@ BEGIN {UNCOOPERATIVE, UNCHECKED}
 	(* mask all maskable interrupts *)
 	(* mask all maskable interrupts *)
 	OutChar (PIC1DataPort, 0FBX);
 	OutChar (PIC1DataPort, 0FBX);
 	OutChar (PIC2DataPort, 0FFX);
 	OutChar (PIC2DataPort, 0FFX);
-	
+
 	FOR i := 0 TO Interrupts - 1 DO
 	FOR i := 0 TO Interrupts - 1 DO
 		IF (i # 9) & (i # 15) & ((i < 20) OR (i > 29)) & (i # 31) THEN
 		IF (i # 9) & (i # 15) & ((i < 20) OR (i > 29)) & (i # 31) THEN
 			idt[i][0] := INTEGER (ADDRESS OF wrapper[i] MOD 10000H);
 			idt[i][0] := INTEGER (ADDRESS OF wrapper[i] MOD 10000H);
@@ -354,7 +354,7 @@ BEGIN {UNCOOPERATIVE, UNCHECKED}
 			idt[i][3] := 0;
 			idt[i][3] := 0;
 		END;
 		END;
 	END;
 	END;
-	
+
 	CODE
 	CODE
 		LEA	EAX, idt
 		LEA	EAX, idt
 		PUSH	EAX
 		PUSH	EAX
@@ -393,7 +393,7 @@ BEGIN {UNCOOPERATIVE, UNCHECKED}
 	(* mask all maskable interrupts *)
 	(* mask all maskable interrupts *)
 	OutChar (PIC1DataPort, 0FBX);
 	OutChar (PIC1DataPort, 0FBX);
 	OutChar (PIC2DataPort, 0FFX);
 	OutChar (PIC2DataPort, 0FFX);
-	
+
 	FOR i := 0 TO Interrupts - 1 DO
 	FOR i := 0 TO Interrupts - 1 DO
 		IF (i # 9) & (i # 15) & ((i < 20) OR (i > 29)) & (i # 31) THEN
 		IF (i # 9) & (i # 15) & ((i < 20) OR (i > 29)) & (i # 31) THEN
 			idt[i][0] := INTEGER (ADDRESS OF wrapper[i] MOD 10000H);
 			idt[i][0] := INTEGER (ADDRESS OF wrapper[i] MOD 10000H);
@@ -434,7 +434,7 @@ BEGIN {UNCOOPERATIVE, UNCHECKED}
 		idt[i][6] := 0;
 		idt[i][6] := 0;
 		idt[i][7] := 0;
 		idt[i][7] := 0;
 	END;
 	END;
-	
+
 	CODE
 	CODE
 		LEA	RAX, idt
 		LEA	RAX, idt
 		PUSH	RAX
 		PUSH	RAX

+ 4 - 4
source/CRC.Mod

@@ -104,7 +104,7 @@ TYPE CRC32*= OBJECT
 		BEGIN
 		BEGIN
 			crc := LONGINT(0FFFFFFFFH);
 			crc := LONGINT(0FFFFFFFFH);
 		END Init;
 		END Init;
-		
+
 		(* standard use: one character at a time *)
 		(* standard use: one character at a time *)
 		PROCEDURE Char*(c: CHAR);
 		PROCEDURE Char*(c: CHAR);
 		VAR idx: LONGINT;
 		VAR idx: LONGINT;
@@ -112,10 +112,10 @@ TYPE CRC32*= OBJECT
 			idx := SYSTEM.VAL(LONGINT, SYSTEM.VAL(SET, crc) / SYSTEM.VAL(SET, LONG(ORD(c)))) MOD 100H;
 			idx := SYSTEM.VAL(LONGINT, SYSTEM.VAL(SET, crc) / SYSTEM.VAL(SET, LONG(ORD(c)))) MOD 100H;
 			crc := SYSTEM.VAL(LONGINT, SYSTEM.VAL(SET, CRC32Table[idx])/SYSTEM.VAL(SET, LSH(crc, -8)));
 			crc := SYSTEM.VAL(LONGINT, SYSTEM.VAL(SET, CRC32Table[idx])/SYSTEM.VAL(SET, LSH(crc, -8)));
 		END Char;
 		END Char;
-		
+
 		(* nonstandard use - add a LONGINT; LSB *)
 		(* nonstandard use - add a LONGINT; LSB *)
 		PROCEDURE Add*(i: LONGINT);
 		PROCEDURE Add*(i: LONGINT);
-		VAR idx: LONGINT; 
+		VAR idx: LONGINT;
 		BEGIN
 		BEGIN
 			i:= SYSTEM.VAL(LONGINT, SYSTEM.VAL(SET, crc) / SYSTEM.VAL(SET, i));
 			i:= SYSTEM.VAL(LONGINT, SYSTEM.VAL(SET, crc) / SYSTEM.VAL(SET, i));
 			idx := i MOD 100H;
 			idx := i MOD 100H;
@@ -132,7 +132,7 @@ TYPE CRC32*= OBJECT
 		BEGIN
 		BEGIN
 			RETURN SYSTEM.VAL(LONGINT, SYSTEM.VAL(SET, crc)/{0..31})
 			RETURN SYSTEM.VAL(LONGINT, SYSTEM.VAL(SET, crc)/{0..31})
 		END Get;
 		END Get;
-	
+
 	END CRC32;
 	END CRC32;
 
 
 VAR
 VAR

+ 18 - 18
source/Checksum.Mod

@@ -2,7 +2,7 @@ MODULE Checksum;	(** AUTHOR "GF"; PURPOSE "compute md5, sha1 and sha3 checksums"
 
 
 IMPORT Commands, Files, Streams, Hashes := CryptoHashes;
 IMPORT Commands, Files, Streams, Hashes := CryptoHashes;
 
 
-VAR 
+VAR
 	hexdigits: ARRAY 17 OF CHAR;
 	hexdigits: ARRAY 17 OF CHAR;
 
 
 
 
@@ -10,7 +10,7 @@ VAR
 	BEGIN
 	BEGIN
 		Do( c, Hashes.NewHash( "CryptoMD5" ) )
 		Do( c, Hashes.NewHash( "CryptoMD5" ) )
 	END MD5;
 	END MD5;
-	
+
 	PROCEDURE SHA1*( c: Commands.Context );
 	PROCEDURE SHA1*( c: Commands.Context );
 	BEGIN
 	BEGIN
 		Do( c, Hashes.NewHash( "CryptoSHA1" ) )
 		Do( c, Hashes.NewHash( "CryptoSHA1" ) )
@@ -23,10 +23,10 @@ VAR
 	(*	h.SetNameAndSize( "", 32 )	*)	(* 256 bit, default *)
 	(*	h.SetNameAndSize( "", 32 )	*)	(* 256 bit, default *)
 		Do( c, h )
 		Do( c, h )
 	END SHA3;
 	END SHA3;
-	
-	
+
+
 	PROCEDURE Do( c: Commands.Context; h: Hashes.Hash );
 	PROCEDURE Do( c: Commands.Context; h: Hashes.Hash );
-	VAR 
+	VAR
 		f: Files.File;  r: Files.Reader;
 		f: Files.File;  r: Files.Reader;
 		fname: ARRAY 256 OF CHAR;
 		fname: ARRAY 256 OF CHAR;
 	BEGIN
 	BEGIN
@@ -34,19 +34,19 @@ VAR
 			Files.OpenReader( r, f, 0 );
 			Files.OpenReader( r, f, 0 );
 			ComputeHash( r, h, c.out );
 			ComputeHash( r, h, c.out );
 			f.GetName( fname );
 			f.GetName( fname );
-			c.out.String( '    ' );  c.out.String( fname );  c.out.Ln;		
-			c.out.Update		
+			c.out.String( '    ' );  c.out.String( fname );  c.out.Ln;
+			c.out.Update
 		END;
 		END;
 	END Do;
 	END Do;
 
 
 	PROCEDURE OpenNextFile( c: Commands.Context;  VAR f: Files.File ): BOOLEAN;
 	PROCEDURE OpenNextFile( c: Commands.Context;  VAR f: Files.File ): BOOLEAN;
-	VAR 
+	VAR
 		fname: ARRAY 64 OF CHAR;
 		fname: ARRAY 64 OF CHAR;
 	BEGIN
 	BEGIN
 		IF c.arg.GetString( fname ) THEN
 		IF c.arg.GetString( fname ) THEN
 			f := Files.Old( fname );
 			f := Files.Old( fname );
 			IF f = NIL THEN
 			IF f = NIL THEN
-				c.error.String( "File " );  c.error.String( fname );  c.error.String( " not fond" ); 
+				c.error.String( "File " );  c.error.String( fname );  c.error.String( " not fond" );
 				c.error.Ln; c.error.Update;
 				c.error.Ln; c.error.Update;
 				RETURN FALSE
 				RETURN FALSE
 			ELSE
 			ELSE
@@ -59,8 +59,8 @@ VAR
 
 
 
 
 	PROCEDURE ComputeHash( r: Files.Reader; h: Hashes.Hash; out: Streams.Writer );
 	PROCEDURE ComputeHash( r: Files.Reader; h: Hashes.Hash; out: Streams.Writer );
-	VAR 
-		buf: ARRAY 128 OF CHAR;  
+	VAR
+		buf: ARRAY 128 OF CHAR;
 		got, i, x: LONGINT;
 		got, i, x: LONGINT;
 	BEGIN
 	BEGIN
 		h.Initialize;
 		h.Initialize;
@@ -68,7 +68,7 @@ VAR
 			r.Bytes( buf, 0, 64, got );
 			r.Bytes( buf, 0, 64, got );
 			h.Update( buf, 0, got )
 			h.Update( buf, 0, got )
 		END;
 		END;
-		h.GetHash( buf, 0 );  
+		h.GetHash( buf, 0 );
 		FOR i := 0 TO h.size - 1 DO
 		FOR i := 0 TO h.size - 1 DO
 			x := ORD( buf[i] );
 			x := ORD( buf[i] );
 			out.Char( hexdigits[x DIV 16] );
 			out.Char( hexdigits[x DIV 16] );
@@ -77,20 +77,20 @@ VAR
 	END ComputeHash;
 	END ComputeHash;
 
 
 
 
-BEGIN 
+BEGIN
 	hexdigits := "0123456789abcdef"
 	hexdigits := "0123456789abcdef"
 END Checksum.
 END Checksum.
 
 
 
 
 
 
-	Checksum.MD5  
-			Files.Mod 
+	Checksum.MD5
+			Files.Mod
 			Unix.UnixFiles.Mod
 			Unix.UnixFiles.Mod
 			NoFile.Mod
 			NoFile.Mod
 			~
 			~
-	
+
 	Checksum.SHA1  Files.Mod  ~
 	Checksum.SHA1  Files.Mod  ~
-	
+
 	Checksum.SHA3  Files.Mod  ~
 	Checksum.SHA3  Files.Mod  ~
-	
+
 	System.Free Checksum ~
 	System.Free Checksum ~

+ 4 - 4
source/Clock.Mod

@@ -8,10 +8,10 @@
 MODULE Clock;
 MODULE Clock;
 
 
 TYPE
 TYPE
-	
+
 	(*
 	(*
 		Function for getting time from an RTC device
 		Function for getting time from an RTC device
-		
+
 		second: seconds \in [0,59]
 		second: seconds \in [0,59]
 		minute: minutes \in [0,59]
 		minute: minutes \in [0,59]
 		hour: hours \in [0,23]
 		hour: hours \in [0,23]
@@ -20,10 +20,10 @@ TYPE
 		year: the actual year minus 1900
 		year: the actual year minus 1900
 	*)
 	*)
 	GetRtcTimeFunc = PROCEDURE{DELEGATE}(VAR second, minute, hour, day, month: SHORTINT; VAR year: INTEGER): BOOLEAN;
 	GetRtcTimeFunc = PROCEDURE{DELEGATE}(VAR second, minute, hour, day, month: SHORTINT; VAR year: INTEGER): BOOLEAN;
-	
+
 	(*
 	(*
 		Function for setting up time on an RTC device
 		Function for setting up time on an RTC device
-		
+
 		second: seconds \in [0,59]
 		second: seconds \in [0,59]
 		minute: minutes \in [0,59]
 		minute: minutes \in [0,59]
 		hour: hours \in [0,23]
 		hour: hours \in [0,23]

+ 1 - 1
source/Commands.Mod

@@ -90,7 +90,7 @@ TYPE
 			AWAIT(state >= this);
 			AWAIT(state >= this);
 			res := SELF.res; COPY(SELF.msg, msg);
 			res := SELF.res; COPY(SELF.msg, msg);
 		END Join;
 		END Join;
-		
+
 	BEGIN {ACTIVE, SAFE}
 	BEGIN {ACTIVE, SAFE}
 		Objects.SetContext(context);
 		Objects.SetContext(context);
 		IF ~exception THEN
 		IF ~exception THEN

+ 19 - 19
source/Compiler.Mod

@@ -106,7 +106,7 @@ TYPE
 		BEGIN
 		BEGIN
 			message := "";
 			message := "";
 			IF module # NIL THEN
 			IF module # NIL THEN
-				Global.GetModuleName(module, message); 
+				Global.GetModuleName(module, message);
 			END;
 			END;
 			Strings.Append (message, msg);
 			Strings.Append (message, msg);
 			IF error THEN
 			IF error THEN
@@ -160,7 +160,7 @@ TYPE
 		REPEAT
 		REPEAT
 			(** first phase: scan and parse **)
 			(** first phase: scan and parse **)
 			module := options.frontend.Parse();
 			module := options.frontend.Parse();
-			IF options.frontend.Error() THEN 
+			IF options.frontend.Error() THEN
 				FinalMessage(TRUE," could not be compiled (parser errors).");
 				FinalMessage(TRUE," could not be compiled (parser errors).");
 				RETURN FALSE;
 				RETURN FALSE;
 			END;
 			END;
@@ -279,11 +279,11 @@ TYPE
 	BEGIN
 	BEGIN
 		result := TRUE;
 		result := TRUE;
 		NEW(options);
 		NEW(options);
-		
+
 		options.Add("p","platform",Options.String);
 		options.Add("p","platform",Options.String);
 		options.Add(0X,"showOptions",Options.Flag);
 		options.Add(0X,"showOptions",Options.Flag);
 		options.Add("l","lineNumbers", Options.Flag);
 		options.Add("l","lineNumbers", Options.Flag);
-		
+
 		options.Add(0X,"print",Options.Flag);
 		options.Add(0X,"print",Options.Flag);
 		options.Add(0X,"Print",Options.Flag);
 		options.Add(0X,"Print",Options.Flag);
 		options.Add(0X,"silent",Options.Flag);
 		options.Add(0X,"silent",Options.Flag);
@@ -312,14 +312,14 @@ TYPE
 		parsed := options.ParseStaged(input, error);
 		parsed := options.ParseStaged(input, error);
 		IF options.GetString("platform", name) OR GetDefaultPlatform(name) THEN
 		IF options.GetString("platform", name) OR GetDefaultPlatform(name) THEN
 			defaults := platforms.Get(name);
 			defaults := platforms.Get(name);
-			IF defaults = NIL THEN 	
+			IF defaults = NIL THEN
 				error.String("Unknown platform"); error.Ln; result := FALSE;
 				error.String("Unknown platform"); error.Ln; result := FALSE;
 			ELSE
 			ELSE
 				parsed := options.ParseStaged(defaults, error) & parsed;
 				parsed := options.ParseStaged(defaults, error) & parsed;
 				input.SetPos(position);
 				input.SetPos(position);
 				parsed := options.ParseStaged(input, error) & parsed; (* reparse overwrites *)
 				parsed := options.ParseStaged(input, error) & parsed; (* reparse overwrites *)
 			END;
 			END;
-		ELSE 
+		ELSE
 			defaults := NIL;
 			defaults := NIL;
 		END;
 		END;
 
 
@@ -334,7 +334,7 @@ TYPE
 		ELSE compilerOptions.backend := Backend.GetBackendByName(DefaultBackend);
 		ELSE compilerOptions.backend := Backend.GetBackendByName(DefaultBackend);
 			IF compilerOptions.backend = NIL THEN Error("default backend could not be installed"); result := FALSE END;
 			IF compilerOptions.backend = NIL THEN Error("default backend could not be installed"); result := FALSE END;
 		END;
 		END;
-		
+
 		IF options.GetString("F", name) THEN
 		IF options.GetString("F", name) THEN
 			IF name = "" THEN compilerOptions.frontend := NIL
 			IF name = "" THEN compilerOptions.frontend := NIL
 			ELSE
 			ELSE
@@ -518,20 +518,20 @@ TYPE
 		END;
 		END;
 	END CompileReader;
 	END CompileReader;
 
 
-	VAR 
+	VAR
 		platforms: Options.Defaults;
 		platforms: Options.Defaults;
 		defaultPlatform: ARRAY 32 OF CHAR;
 		defaultPlatform: ARRAY 32 OF CHAR;
-	
+
 	PROCEDURE DoAddPlatform(CONST name: ARRAY OF CHAR; CONST defaults: ARRAY OF CHAR);
 	PROCEDURE DoAddPlatform(CONST name: ARRAY OF CHAR; CONST defaults: ARRAY OF CHAR);
 	BEGIN
 	BEGIN
 		platforms.Add(name, defaults);
 		platforms.Add(name, defaults);
 	END DoAddPlatform;
 	END DoAddPlatform;
-	
+
 	PROCEDURE ShowDefaults*(context: Commands.Context);
 	PROCEDURE ShowDefaults*(context: Commands.Context);
 	BEGIN
 	BEGIN
 		platforms.Show(context.out)
 		platforms.Show(context.out)
 	END ShowDefaults;
 	END ShowDefaults;
-	
+
 	PROCEDURE AddPlatform*(context: Commands.Context);
 	PROCEDURE AddPlatform*(context: Commands.Context);
 	VAR name: ARRAY 32 OF CHAR; defaults: ARRAY 1024 OF CHAR;
 	VAR name: ARRAY 32 OF CHAR; defaults: ARRAY 1024 OF CHAR;
 	BEGIN
 	BEGIN
@@ -541,7 +541,7 @@ TYPE
 			context.result := Commands.CommandParseError;
 			context.result := Commands.CommandParseError;
 		END;
 		END;
 	END AddPlatform;
 	END AddPlatform;
-	
+
 	PROCEDURE SetDefaultPlatform*(context: Commands.Context);
 	PROCEDURE SetDefaultPlatform*(context: Commands.Context);
 	VAR name: ARRAY 32 OF CHAR;
 	VAR name: ARRAY 32 OF CHAR;
 	BEGIN
 	BEGIN
@@ -549,7 +549,7 @@ TYPE
 			COPY(name, defaultPlatform);
 			COPY(name, defaultPlatform);
 		END;
 		END;
 	END SetDefaultPlatform;
 	END SetDefaultPlatform;
-	
+
 	PROCEDURE GetDefaultPlatform(VAR name: ARRAY OF CHAR): BOOLEAN;
 	PROCEDURE GetDefaultPlatform(VAR name: ARRAY OF CHAR): BOOLEAN;
 	BEGIN
 	BEGIN
 		IF defaultPlatform # "" THEN
 		IF defaultPlatform # "" THEN
@@ -559,7 +559,7 @@ TYPE
 			RETURN FALSE
 			RETURN FALSE
 		END
 		END
 	END GetDefaultPlatform;
 	END GetDefaultPlatform;
-	
+
 	PROCEDURE SetupDefaults;
 	PROCEDURE SetupDefaults;
 	VAR extension: Files.FileName;
 	VAR extension: Files.FileName;
 	BEGIN
 	BEGIN
@@ -570,9 +570,9 @@ TYPE
 		(* infer platform from default object file extension *)
 		(* infer platform from default object file extension *)
 		platforms.Find("objectFileExtension", extension, defaultPlatform);
 		platforms.Find("objectFileExtension", extension, defaultPlatform);
 	END SetupDefaults;
 	END SetupDefaults;
-	
-	
-	
+
+
+
 BEGIN
 BEGIN
 	NEW(platforms);
 	NEW(platforms);
 
 
@@ -582,12 +582,12 @@ BEGIN
 	DoAddPlatform("Win32","-b=AMD --bits=32 --mergeSections --objectFileExtension=.GofW --symbolFileExtension=.SymW --preciseGC --trackLeave --cellsAreObjects --platformCC=WINAPI --define=WIN,I386");
 	DoAddPlatform("Win32","-b=AMD --bits=32 --mergeSections --objectFileExtension=.GofW --symbolFileExtension=.SymW --preciseGC --trackLeave --cellsAreObjects --platformCC=WINAPI --define=WIN,I386");
 	DoAddPlatform("Win64","-b=AMD --bits=64 --mergeSections --objectFileExtension=.GofWw --symbolFileExtension=.SymWw --preciseGC --trackLeave --cellsAreObjects --platformCC=WINAPI --define=WIN,AMD64");
 	DoAddPlatform("Win64","-b=AMD --bits=64 --mergeSections --objectFileExtension=.GofWw --symbolFileExtension=.SymWw --preciseGC --trackLeave --cellsAreObjects --platformCC=WINAPI --define=WIN,AMD64");
 	DoAddPlatform("ARM","-b=ARM --metaData=simple --objectFileExtension=.Goa --symbolFileExtension=.Sya --define=ARM");
 	DoAddPlatform("ARM","-b=ARM --metaData=simple --objectFileExtension=.Goa --symbolFileExtension=.Sya --define=ARM");
-	DoAddPlatform("Minos","-b=ARM --objectFile=Minos --define=ARM"); 
+	DoAddPlatform("Minos","-b=ARM --objectFile=Minos --define=ARM");
 	DoAddPlatform("TRM","-b=TRM --objectFile=Generic --metaData=simple --objectFileExtension=.GofT --symbolFileExtension=.SymT --define=TRM");
 	DoAddPlatform("TRM","-b=TRM --objectFile=Generic --metaData=simple --objectFileExtension=.GofT --symbolFileExtension=.SymT --define=TRM");
 	DoAddPlatform("TRMI","-b=TRM --objectFile=Intermediate --metaData=simple --objectFileExtension=.IroT --symbolFileExtension=.IrsT --define=TRM");
 	DoAddPlatform("TRMI","-b=TRM --objectFile=Intermediate --metaData=simple --objectFileExtension=.IroT --symbolFileExtension=.IrsT --define=TRM");
 	DoAddPlatform("ARMA2","-b=ARM --mergeSections --define=ARM --objectFileExtension=.Gof --symbolFileExtension=.Sym");
 	DoAddPlatform("ARMA2","-b=ARM --mergeSections --define=ARM --objectFileExtension=.Gof --symbolFileExtension=.Sym");
 	DoAddPlatform("Unix32","-b=AMD --bits=32 --mergeSections --traceModule=Trace --objectFileExtension=.GofU --symbolFileExtension=.SymU --preciseGC --cellsAreObjects --platformCC=C --define=UNIX,I386");
 	DoAddPlatform("Unix32","-b=AMD --bits=32 --mergeSections --traceModule=Trace --objectFileExtension=.GofU --symbolFileExtension=.SymU --preciseGC --cellsAreObjects --platformCC=C --define=UNIX,I386");
 	DoAddPlatform("Unix64","-b=AMD --bits=64 --mergeSections --traceModule=Trace --objectFileExtension=.GofUu --symbolFileExtension=.SymUu --preciseGC --cellsAreObjects --platformCC=C --define=UNIX,AMD64");
 	DoAddPlatform("Unix64","-b=AMD --bits=64 --mergeSections --traceModule=Trace --objectFileExtension=.GofUu --symbolFileExtension=.SymUu --preciseGC --cellsAreObjects --platformCC=C --define=UNIX,AMD64");
-	
+
 	SetupDefaults;
 	SetupDefaults;
 END Compiler.
 END Compiler.

+ 1 - 1
source/ComplexNumbers.Mod

@@ -1,5 +1,5 @@
 MODULE ComplexNumbers;
 MODULE ComplexNumbers;
-(* 
+(*
 	operators for complex numbers
 	operators for complex numbers
 	this module is automatically loaded (FoxSemanticChecker) when operators on complex numbers are encountered
 	this module is automatically loaded (FoxSemanticChecker) when operators on complex numbers are encountered
 *)
 *)

+ 6 - 6
source/ComponentViewer.Mod

@@ -10,7 +10,7 @@ CONST
 	InvalidPosition* =MIN(LONGINT);
 	InvalidPosition* =MIN(LONGINT);
 	FlagMoveable* = 20;
 	FlagMoveable* = 20;
 	FlagSmoothGraphics* = 21;
 	FlagSmoothGraphics* = 21;
-	
+
 TYPE
 TYPE
 
 
 	KillerMsg = OBJECT
 	KillerMsg = OBJECT
@@ -59,7 +59,7 @@ TYPE
 			ELSE Handle^(m);
 			ELSE Handle^(m);
 			END;
 			END;
 		END Handle;
 		END Handle;
-		
+
 		PROCEDURE PointerDown*(x, y:LONGINT; keys:SET);
 		PROCEDURE PointerDown*(x, y:LONGINT; keys:SET);
 		BEGIN
 		BEGIN
 			lastX := bounds.l + x; lastY:=bounds.t + y;
 			lastX := bounds.l + x; lastY:=bounds.t + y;
@@ -67,7 +67,7 @@ TYPE
 				dragging := TRUE;
 				dragging := TRUE;
 				PointerDown^(x,y,keys);
 				PointerDown^(x,y,keys);
 			ELSE
 			ELSE
-				PointerDown^(x,y,keys); 
+				PointerDown^(x,y,keys);
 			END;
 			END;
 		END PointerDown;
 		END PointerDown;
 
 
@@ -88,7 +88,7 @@ TYPE
 			dragging := FALSE;
 			dragging := FALSE;
 			PointerDown^(x,y,keys);
 			PointerDown^(x,y,keys);
 		END PointerUp;
 		END PointerUp;
-		
+
 	END Window;
 	END Window;
 
 
 VAR
 VAR
@@ -143,7 +143,7 @@ BEGIN
 	ELSE
 	ELSE
 		window.SetContent(vc);
 		window.SetContent(vc);
 	END;
 	END;
-	
+
 END DoShow;
 END DoShow;
 
 
 PROCEDURE DoLoad*(CONST filename: ARRAY OF CHAR; error: Streams.Writer): WMComponents.VisualComponent;
 PROCEDURE DoLoad*(CONST filename: ARRAY OF CHAR; error: Streams.Writer): WMComponents.VisualComponent;
@@ -208,7 +208,7 @@ PROCEDURE SetProperties(c:WMComponents.Component; CONST attr: ARRAY OF CHAR);
 VAR property, value: ARRAY 32 OF CHAR;
 VAR property, value: ARRAY 32 OF CHAR;
 VAR r: Streams.StringReader;
 VAR r: Streams.StringReader;
 BEGIN
 BEGIN
-	NEW(r, LEN(attr)); 
+	NEW(r, LEN(attr));
 	r.Set(attr);
 	r.Set(attr);
 	WHILE r.GetString(property) & r.GetString(value) DO
 	WHILE r.GetString(property) & r.GetString(value) DO
 		IF ~c.properties.SetPropertyValue(property, value) THEN END;
 		IF ~c.properties.SetPropertyValue(property, value) THEN END;

+ 3 - 3
source/Coop.ARM.Machine.Mod

@@ -52,7 +52,7 @@ TYPE
 		adr*: ADDRESS;		(* lowest address on allocated stack *)	(* exported for Objects only *)
 		adr*: ADDRESS;		(* lowest address on allocated stack *)	(* exported for Objects only *)
 		high*: ADDRESS;	(* next virtual address after stack *)	(* exported for Objects only *)
 		high*: ADDRESS;	(* next virtual address after stack *)	(* exported for Objects only *)
 	END;
 	END;
-	
+
 	Address32* = LONGINT;
 	Address32* = LONGINT;
 
 
 VAR
 VAR
@@ -322,12 +322,12 @@ END NumberOfProcessors;
 
 
 PROCEDURE InvalidateDCacheRange*(a: ADDRESS; s: SIZE);
 PROCEDURE InvalidateDCacheRange*(a: ADDRESS; s: SIZE);
 BEGIN
 BEGIN
-	
+
 END InvalidateDCacheRange;
 END InvalidateDCacheRange;
 
 
 PROCEDURE FlushDCacheRange*(a: ADDRESS; s: SIZE);
 PROCEDURE FlushDCacheRange*(a: ADDRESS; s: SIZE);
 BEGIN
 BEGIN
-	
+
 END FlushDCacheRange;
 END FlushDCacheRange;
 
 
 
 

+ 1 - 1
source/Coop.Kernel.Mod

@@ -1,4 +1,4 @@
-	
+
 (* Aos, Copyright 2001, Pieter Muller, ETH Zurich *)
 (* Aos, Copyright 2001, Pieter Muller, ETH Zurich *)
 (* red marked parts are specific for WinAos, fof *)
 (* red marked parts are specific for WinAos, fof *)
 
 

+ 3 - 3
source/Coop.Machine.Mod

@@ -64,7 +64,7 @@ TYPE
 		adr*: ADDRESS;		(* lowest address on allocated stack *)	(* exported for Objects only *)
 		adr*: ADDRESS;		(* lowest address on allocated stack *)	(* exported for Objects only *)
 		high*: ADDRESS;	(* next virtual address after stack *)	(* exported for Objects only *)
 		high*: ADDRESS;	(* next virtual address after stack *)	(* exported for Objects only *)
 	END;
 	END;
-	
+
 	Address32* = LONGINT;
 	Address32* = LONGINT;
 
 
 VAR
 VAR
@@ -792,12 +792,12 @@ END PutNVByte;
 
 
 PROCEDURE InvalidateDCacheRange*(a: ADDRESS; s: SIZE);
 PROCEDURE InvalidateDCacheRange*(a: ADDRESS; s: SIZE);
 BEGIN
 BEGIN
-	
+
 END InvalidateDCacheRange;
 END InvalidateDCacheRange;
 
 
 PROCEDURE FlushDCacheRange*(a: ADDRESS; s: SIZE);
 PROCEDURE FlushDCacheRange*(a: ADDRESS; s: SIZE);
 BEGIN
 BEGIN
-	
+
 END FlushDCacheRange;
 END FlushDCacheRange;
 
 
 
 

+ 8 - 8
source/Coop.Objects.Mod

@@ -22,7 +22,7 @@ CONST
 
 
 	(** Process priorities *)
 	(** Process priorities *)
 	Low* = Activities.DefaultPriority;								(* "user" priorities *)
 	Low* = Activities.DefaultPriority;								(* "user" priorities *)
-	Normal* = Activities.DefaultPriority;	
+	Normal* = Activities.DefaultPriority;
 	High* = Activities.HighPriority;
 	High* = Activities.HighPriority;
 	Realtime* = Activities.RealtimePriority;						(* reserved for interrupt handling and realtime apps *)
 	Realtime* = Activities.RealtimePriority;						(* reserved for interrupt handling and realtime apps *)
 
 
@@ -91,7 +91,7 @@ TYPE
 		restartSP-: LONGINT;   (** stack level at start of body, for SAFE exception recovery *)
 		restartSP-: LONGINT;   (** stack level at start of body, for SAFE exception recovery *)
 		cpuCycles, lastCpuCycles : CpuCyclesArray;
 		cpuCycles, lastCpuCycles : CpuCyclesArray;
 	END Process;
 	END Process;
-	
+
 	InterruptList = POINTER TO RECORD
 	InterruptList = POINTER TO RECORD
 		next: InterruptList;
 		next: InterruptList;
 		handler: EventHandler
 		handler: EventHandler
@@ -102,7 +102,7 @@ TYPE
 		VAR root: InterruptList;
 		VAR root: InterruptList;
 		VAR cancelled: BOOLEAN;
 		VAR cancelled: BOOLEAN;
 		VAR interrupt: Interrupts.Interrupt;
 		VAR interrupt: Interrupts.Interrupt;
-		
+
 		PROCEDURE &Init (irq: SIZE);
 		PROCEDURE &Init (irq: SIZE);
 		BEGIN
 		BEGIN
 			Interrupts.Install (interrupt, irq);
 			Interrupts.Install (interrupt, irq);
@@ -116,7 +116,7 @@ TYPE
 			item.handler := handler;
 			item.handler := handler;
 			root := item;
 			root := item;
 		END Add;
 		END Add;
-		
+
 		PROCEDURE Remove (handler: EventHandler);
 		PROCEDURE Remove (handler: EventHandler);
 		VAR previous, current: InterruptList;
 		VAR previous, current: InterruptList;
 		BEGIN {EXCLUSIVE}
 		BEGIN {EXCLUSIVE}
@@ -132,7 +132,7 @@ TYPE
 				END;
 				END;
 			END;
 			END;
 		END Remove;
 		END Remove;
-		
+
 		PROCEDURE Count(): SIZE;
 		PROCEDURE Count(): SIZE;
 		VAR count := 0: SIZE; item: InterruptList;
 		VAR count := 0: SIZE; item: InterruptList;
 		BEGIN {EXCLUSIVE}
 		BEGIN {EXCLUSIVE}
@@ -140,7 +140,7 @@ TYPE
 			WHILE item # NIL DO INC (count); item := item.next END;
 			WHILE item # NIL DO INC (count); item := item.next END;
 			RETURN count;
 			RETURN count;
 		END Count;
 		END Count;
-		
+
 		PROCEDURE Cancel;
 		PROCEDURE Cancel;
 		BEGIN {EXCLUSIVE}
 		BEGIN {EXCLUSIVE}
 			IF ~cancelled THEN
 			IF ~cancelled THEN
@@ -178,7 +178,7 @@ VAR
 
 
 	(* for compatibility and later extension *)
 	(* for compatibility and later extension *)
 	TraceProcessHook* := NIL: PROCEDURE (prcoess: Process; pc, bp: ADDRESS; stacklow, stackhigh: ADDRESS);
 	TraceProcessHook* := NIL: PROCEDURE (prcoess: Process; pc, bp: ADDRESS; stacklow, stackhigh: ADDRESS);
-	
+
 (* Set the current process' priority. *)
 (* Set the current process' priority. *)
 PROCEDURE SetPriority*( priority: LONGINT );
 PROCEDURE SetPriority*( priority: LONGINT );
 BEGIN
 BEGIN
@@ -249,7 +249,7 @@ PROCEDURE TerminateThis*( t: Process;  halt: BOOLEAN );
 END TerminateThis;
 END TerminateThis;
 
 
 (* called by WMProcessInfo to obtain the current state of a running process *)
 (* called by WMProcessInfo to obtain the current state of a running process *)
-PROCEDURE UpdateProcessState*( p: Process );	
+PROCEDURE UpdateProcessState*( p: Process );
 BEGIN
 BEGIN
 	(*  update p.stat.{PC,BP,SP}  *)
 	(*  update p.stat.{PC,BP,SP}  *)
 END UpdateProcessState;
 END UpdateProcessState;

+ 1 - 1
source/Coop.Windows.Display.Mod

@@ -405,7 +405,7 @@ VAR
 	VAR m: AosInputs.AbsMouseMsg;  oldx, oldy: LONGINT;  keys: SET; ret: Kernel32.BOOL;
 	VAR m: AosInputs.AbsMouseMsg;  oldx, oldy: LONGINT;  keys: SET; ret: Kernel32.BOOL;
 	BEGIN
 	BEGIN
 		(* User32.SetCursor(hCurrentCursor);*)
 		(* User32.SetCursor(hCurrentCursor);*)
-		oldx := win.track.X;  oldy := win.track.Y;  
+		oldx := win.track.X;  oldy := win.track.Y;
 		win.track.X := SHORT( lParam MOD ASH( 1, 16 ) ) - win.dx;
 		win.track.X := SHORT( lParam MOD ASH( 1, 16 ) ) - win.dx;
 		win.track.Y := SHORT( (* win.height-*) ASH( lParam, -16 ) - 1 ) - win.dy;
 		win.track.Y := SHORT( (* win.height-*) ASH( lParam, -16 ) - 1 ) - win.dy;
 		m.x := win.track.X;  m.y := win.track.Y;  m.z := win.track.Z;
 		m.x := win.track.X;  m.y := win.track.Y;  m.z := win.track.Z;

+ 19 - 19
source/Coop.Windows.I386.Kernel32.Mod

@@ -56,7 +56,7 @@ CONST
 	HeapNoSerialize* = 2H;
 	HeapNoSerialize* = 2H;
 	HeapGenerateExceptions* = 4H;
 	HeapGenerateExceptions* = 4H;
 	HeapZeroMemory* = 8H;
 	HeapZeroMemory* = 8H;
-	
+
 	(** protect (VirtualAlloc) flags *)
 	(** protect (VirtualAlloc) flags *)
 	PageReadWrite* = 2;  PageExecuteReadWrite* = 6;
 	PageReadWrite* = 2;  PageExecuteReadWrite* = 6;
 
 
@@ -152,7 +152,7 @@ CONST
 	(** GetLastError *)
 	(** GetLastError *)
 	ErrorSuccess* = 0;  ErrorFileNotFound* = 2;  ErrorAccessDenied* = 5;
 	ErrorSuccess* = 0;  ErrorFileNotFound* = 2;  ErrorAccessDenied* = 5;
 	ErrorInvalidParameter* = 87;
 	ErrorInvalidParameter* = 87;
-	
+
 	ErrorIoPending* = 997; (** Overlapped I/O operation is in progress *)
 	ErrorIoPending* = 997; (** Overlapped I/O operation is in progress *)
 TYPE
 TYPE
 	(* OutputStringProc* = PROCEDURE (VAR str: ARRAY OF CHAR); *)
 	(* OutputStringProc* = PROCEDURE (VAR str: ARRAY OF CHAR); *)
@@ -216,7 +216,7 @@ TYPE
 	Wow64Context*= RECORD (Context)
 	Wow64Context*= RECORD (Context)
 		extension: ARRAY 512 (* MaxWOW64Extension *) OF CHAR;
 		extension: ARRAY 512 (* MaxWOW64Extension *) OF CHAR;
 	END;
 	END;
-	
+
 	ExceptionRecordPtr* = POINTER TO ExceptionRecord;
 	ExceptionRecordPtr* = POINTER TO ExceptionRecord;
 	ExceptionRecord* = RECORD
 	ExceptionRecord* = RECORD
 		ExceptionCode*, ExceptionFlags*: LONGINT;
 		ExceptionCode*, ExceptionFlags*: LONGINT;
@@ -338,7 +338,7 @@ TYPE
 		DaylightDate*: SystemTime;
 		DaylightDate*: SystemTime;
 		DaylightBias*: LONGINT;
 		DaylightBias*: LONGINT;
 	END;
 	END;
-	
+
 	(** Contains information used in asynchronous (or overlapped) input and output (I/O). *)
 	(** Contains information used in asynchronous (or overlapped) input and output (I/O). *)
 	Overlapped* = RECORD
 	Overlapped* = RECORD
 		Internal*: LONGINT;
 		Internal*: LONGINT;
@@ -518,11 +518,11 @@ VAR
 	(** The GetModuleHandle function returns a module handle for the specified module if the file has been mapped
 	(** The GetModuleHandle function returns a module handle for the specified module if the file has been mapped
 			into the address space of the calling process. *)
 			into the address space of the calling process. *)
 	GetModuleHandle-: PROCEDURE {WINAPI} ( CONST lpModuleName: ARRAY   OF CHAR ): HMODULE;
 	GetModuleHandle-: PROCEDURE {WINAPI} ( CONST lpModuleName: ARRAY   OF CHAR ): HMODULE;
-	
-	(** Retrieves the results of an overlapped operation on the specified file, named pipe, or communications device. 
+
+	(** Retrieves the results of an overlapped operation on the specified file, named pipe, or communications device.
 			To specify a timeout interval or wait on an alertable thread. *)
 			To specify a timeout interval or wait on an alertable thread. *)
 	GetOverlappedResult-: PROCEDURE {WINAPI} ( hFile: HANDLE; VAR lpOverlapped: Overlapped; VAR lpNumberOfBytesTransferred: LONGINT; bWait: BOOL ): BOOL;
 	GetOverlappedResult-: PROCEDURE {WINAPI} ( hFile: HANDLE; VAR lpOverlapped: Overlapped; VAR lpNumberOfBytesTransferred: LONGINT; bWait: BOOL ): BOOL;
-	
+
 	(** The GetPrivateProfileString function retrieves a string from the specified section in an initialization file.*)
 	(** The GetPrivateProfileString function retrieves a string from the specified section in an initialization file.*)
 	GetPrivateProfileString-: PROCEDURE {WINAPI} ( CONST lpAppName: ARRAY OF CHAR;
 	GetPrivateProfileString-: PROCEDURE {WINAPI} ( CONST lpAppName: ARRAY OF CHAR;
 																			CONST lpKeyName: ARRAY OF CHAR;
 																			CONST lpKeyName: ARRAY OF CHAR;
@@ -996,9 +996,9 @@ VAR
 		IF isEXE THEN hInstance := GetModuleHandle( NIL ) END;
 		IF isEXE THEN hInstance := GetModuleHandle( NIL ) END;
 		END Init;
 		END Init;
 
 
-		(* The following procedure is linked as the first block in the code section of a PE32 executable file 
+		(* The following procedure is linked as the first block in the code section of a PE32 executable file
 			It contains the import table for the two procedures Kernel32.GetProcAddress and Kernel32.LoadLibrary that
 			It contains the import table for the two procedures Kernel32.GetProcAddress and Kernel32.LoadLibrary that
-			are patched by the PE linker. 
+			are patched by the PE linker.
 			[CF. Microsoft Portable Executable and Common Object File Format Specification]
 			[CF. Microsoft Portable Executable and Common Object File Format Specification]
 		*)
 		*)
 		PROCEDURE {NOPAF, FIXED(401000H)} EntryPoint;
 		PROCEDURE {NOPAF, FIXED(401000H)} EntryPoint;
@@ -1009,31 +1009,31 @@ VAR
 			DB 0
 			DB 0
 
 
 		ImportTable:
 		ImportTable:
-			DD Kernel32Import + 1000H 
+			DD Kernel32Import + 1000H
 			DD 0
 			DD 0
 			DD -1
 			DD -1
 			DD Kernel32Name + 1000H
 			DD Kernel32Name + 1000H
 			DD Kernel32Import + 1000H
 			DD Kernel32Import + 1000H
 			DD 0, 0, 0, 0, 0
 			DD 0, 0, 0, 0, 0
-		
+
 		Kernel32Import:
 		Kernel32Import:
-		adrLoadLibrary:			
+		adrLoadLibrary:
 			DD LoadLibraryA + 1000H
 			DD LoadLibraryA + 1000H
-		adrGetProcAddress:			
+		adrGetProcAddress:
 			DD GetProcAddress + 1000H
 			DD GetProcAddress + 1000H
 			DD 0
 			DD 0
-			
+
 		Kernel32Name:
 		Kernel32Name:
 			DB 'KERNEL32.DLL' , 0
 			DB 'KERNEL32.DLL' , 0
-			
-		LoadLibraryA:			
+
+		LoadLibraryA:
 			DW 0
 			DW 0
 			DB 'LoadLibraryA',0,0
 			DB 'LoadLibraryA',0,0
-			
+
 		GetProcAddress:
 		GetProcAddress:
 			DW 0
 			DW 0
 			DB 'GetProcAddress',0
 			DB 'GetProcAddress',0
-			
+
 		end:
 		end:
 			MOV EAX,[401000H+adrLoadLibrary]
 			MOV EAX,[401000H+adrLoadLibrary]
 			MOV LoadLibrary, EAX
 			MOV LoadLibrary, EAX
@@ -1043,4 +1043,4 @@ VAR
 		END EntryPoint;
 		END EntryPoint;
 
 
 END Kernel32.
 END Kernel32.
-	
+

+ 20 - 20
source/CryptoAES.Mod

@@ -5,16 +5,16 @@ MODULE CryptoAES;   (** AES (Rijndael) de/encryption *)
 IMPORT  S := SYSTEM, Ciphers := CryptoCiphers, U := CryptoUtils;
 IMPORT  S := SYSTEM, Ciphers := CryptoCiphers, U := CryptoUtils;
 
 
 CONST
 CONST
-	MaxRounds = 14;  
+	MaxRounds = 14;
 	ECB = Ciphers.ECB;  CBC = Ciphers.CBC;  CTR = Ciphers.CTR;
 	ECB = Ciphers.ECB;  CBC = Ciphers.CBC;  CTR = Ciphers.CTR;
-	
-	b0 = S.VAL( SET32, 0000000FFH );  b1 = S.VAL( SET32, 00000FF00H );  
+
+	b0 = S.VAL( SET32, 0000000FFH );  b1 = S.VAL( SET32, 00000FF00H );
 	b2 = S.VAL( SET32, 000FF0000H );  b3 = S.VAL( SET32, 0FF000000H );
 	b2 = S.VAL( SET32, 000FF0000H );  b3 = S.VAL( SET32, 0FF000000H );
 
 
 TYPE
 TYPE
 	RTable = ARRAY 256 OF SET32;
 	RTable = ARRAY 256 OF SET32;
 	RKeys = ARRAY 4*(MaxRounds + 1) OF SET32;
 	RKeys = ARRAY 4*(MaxRounds + 1) OF SET32;
-	
+
 VAR
 VAR
 	e0, e1, e2, e3, e4: RTable;
 	e0, e1, e2, e3, e4: RTable;
 	d0, d1, d2, d3, d4: RTable;
 	d0, d1, d2, d3, d4: RTable;
@@ -45,7 +45,7 @@ TYPE
 					SetIV^( src, mode );   (* set mode *)
 					SetIV^( src, mode );   (* set mode *)
 					U.BufferToBlockBE( src, 0, iv );
 					U.BufferToBlockBE( src, 0, iv );
 				END SetIV;
 				END SetIV;
-				
+
 				PROCEDURE IncIV;
 				PROCEDURE IncIV;
 				VAR i, x: LONGINT;
 				VAR i, x: LONGINT;
 				BEGIN
 				BEGIN
@@ -157,7 +157,7 @@ TYPE
 					b[2] := (d4[t2.d]*b3)/(d4[t1.c]*b2)/(d4[t0.b]*b1)/(d4[t3.a]*b0)/dkey[p + 2];
 					b[2] := (d4[t2.d]*b3)/(d4[t1.c]*b2)/(d4[t0.b]*b1)/(d4[t3.a]*b0)/dkey[p + 2];
 					b[3] := (d4[t3.d]*b3)/(d4[t2.c]*b2)/(d4[t1.b]*b1)/(d4[t0.a]*b0)/dkey[p + 3];
 					b[3] := (d4[t3.d]*b3)/(d4[t2.c]*b2)/(d4[t1.b]*b1)/(d4[t0.a]*b0)/dkey[p + 3];
 				END RoundD;
 				END RoundD;
-				
+
 				PROCEDURE -split( s: SET32;  VAR b: Ind4 );   (* split set into 4 indexes *)
 				PROCEDURE -split( s: SET32;  VAR b: Ind4 );   (* split set into 4 indexes *)
 				BEGIN
 				BEGIN
 					b.a := S.VAL( LONGINT, s ) MOD 100H;
 					b.a := S.VAL( LONGINT, s ) MOD 100H;
@@ -184,7 +184,7 @@ TYPE
 					END;
 					END;
 					RETURN 10
 					RETURN 10
 				END Init128;
 				END Init128;
-				
+
 				PROCEDURE Init192( CONST src: ARRAY OF CHAR ): SHORTINT;
 				PROCEDURE Init192( CONST src: ARRAY OF CHAR ): SHORTINT;
 				VAR i, p: LONGINT;  ib: Ind4;
 				VAR i, p: LONGINT;  ib: Ind4;
 				BEGIN
 				BEGIN
@@ -204,7 +204,7 @@ TYPE
 					END;
 					END;
 					RETURN 12
 					RETURN 12
 				END Init192;
 				END Init192;
-	
+
 				PROCEDURE Init256( CONST src: ARRAY OF CHAR ): SHORTINT;
 				PROCEDURE Init256( CONST src: ARRAY OF CHAR ): SHORTINT;
 				VAR i, p: LONGINT;  ib: Ind4;
 				VAR i, p: LONGINT;  ib: Ind4;
 				BEGIN
 				BEGIN
@@ -227,16 +227,16 @@ TYPE
 					END;
 					END;
 					RETURN 14
 					RETURN 14
 				END Init256;
 				END Init256;
-				
-				
+
+
 				PROCEDURE InvertKeys;
 				PROCEDURE InvertKeys;
 				VAR i, j, k, p: LONGINT;  t: SET32;  ib: Ind4;
 				VAR i, j, k, p: LONGINT;  t: SET32;  ib: Ind4;
-				
+
 					PROCEDURE ind( s: SET32 ): LONGINT;   (* extract index byte 0 *)
 					PROCEDURE ind( s: SET32 ): LONGINT;   (* extract index byte 0 *)
 					BEGIN
 					BEGIN
 						RETURN S.VAL( LONGINT, s ) MOD 100H
 						RETURN S.VAL( LONGINT, s ) MOD 100H
 					END ind;
 					END ind;
-					
+
 				BEGIN
 				BEGIN
 					dkey := key;
 					dkey := key;
 					(* invert the order of the round keys: *)
 					(* invert the order of the round keys: *)
@@ -247,7 +247,7 @@ TYPE
 					END;
 					END;
 					(* apply the inverse MixColumn transform to all round keys but the first and the last: *)
 					(* apply the inverse MixColumn transform to all round keys but the first and the last: *)
 					FOR i := 1 TO rounds - 1 DO
 					FOR i := 1 TO rounds - 1 DO
-						p := 4*i;  
+						p := 4*i;
 						split( dkey[p + 0], ib );
 						split( dkey[p + 0], ib );
 						dkey[p + 0] := d0[ind( e4[ib.d] )] / d1[ind( e4[ib.c] )] / d2[ind( e4[ib.b] )] / d3[ind( e4[ib.a] )];
 						dkey[p + 0] := d0[ind( e4[ib.d] )] / d1[ind( e4[ib.c] )] / d2[ind( e4[ib.b] )] / d3[ind( e4[ib.a] )];
 						split( dkey[p + 1], ib );
 						split( dkey[p + 1], ib );
@@ -258,8 +258,8 @@ TYPE
 						dkey[p + 3] := d0[ind( e4[ib.d] )] / d1[ind( e4[ib.c] )] / d2[ind( e4[ib.b] )] / d3[ind( e4[ib.a] )];
 						dkey[p + 3] := d0[ind( e4[ib.d] )] / d1[ind( e4[ib.c] )] / d2[ind( e4[ib.b] )] / d3[ind( e4[ib.a] )];
 					END;
 					END;
 				END InvertKeys;
 				END InvertKeys;
-	
-	
+
+
 				PROCEDURE & Init*;
 				PROCEDURE & Init*;
 				BEGIN
 				BEGIN
 					SetNameAndBlocksize( "aes", 16 )
 					SetNameAndBlocksize( "aes", 16 )
@@ -276,7 +276,7 @@ TYPE
 (*-------------------------------------------------------------------------------*)
 (*-------------------------------------------------------------------------------*)
 
 
 	PROCEDURE Initialize;
 	PROCEDURE Initialize;
-	VAR 
+	VAR
 		i1, i2, i4, i8, i9, ib, id, ie, v1, v2, v3, t: LONGINT;
 		i1, i2, i4, i8, i9, ib, id, ie, v1, v2, v3, t: LONGINT;
 		buf: U.InitBuffer;
 		buf: U.InitBuffer;
 
 
@@ -284,7 +284,7 @@ TYPE
 		BEGIN
 		BEGIN
 			RETURN S.VAL( LONGINT, S.VAL( SET32, a ) / S.VAL( SET32, b ) )
 			RETURN S.VAL( LONGINT, S.VAL( SET32, a ) / S.VAL( SET32, b ) )
 		END xor;
 		END xor;
-		
+
 		PROCEDURE f1( x: LONGINT ): LONGINT;
 		PROCEDURE f1( x: LONGINT ): LONGINT;
 		VAR y: LONGINT;
 		VAR y: LONGINT;
 		BEGIN
 		BEGIN
@@ -310,10 +310,10 @@ TYPE
 		buf.Add( " 70 3E B5 66 48 03 F6 0E 61 35 57 B9 86 C1 1D 9E " );
 		buf.Add( " 70 3E B5 66 48 03 F6 0E 61 35 57 B9 86 C1 1D 9E " );
 		buf.Add( " E1 F8 98 11 69 D9 8E 94 9B 1E 87 E9 CE 55 28 DF " );
 		buf.Add( " E1 F8 98 11 69 D9 8E 94 9B 1E 87 E9 CE 55 28 DF " );
 		buf.Add( " 8C A1 89 0D BF E6 42 68 41 99 2D 0F B0 54 BB 16 " );
 		buf.Add( " 8C A1 89 0D BF E6 42 68 41 99 2D 0F B0 54 BB 16 " );
-		
+
 		FOR i1 := 0 TO 255 DO
 		FOR i1 := 0 TO 255 DO
 			v1 := buf.GetInt();  v2 := f1( v1 );  v3 := xor( v2, v1 );
 			v1 := buf.GetInt();  v2 := f1( v1 );  v3 := xor( v2, v1 );
-			i2 := f1( i1 );  i4 := f1( i2 );  i8 := f1( i4 );  i9 := xor( i8, i1 );  
+			i2 := f1( i1 );  i4 := f1( i2 );  i8 := f1( i4 );  i9 := xor( i8, i1 );
 			ib := xor( i9, i2 );  id := xor( i9, i4 );  ie := xor( i8, xor( i4, i2 ) );
 			ib := xor( i9, i2 );  id := xor( i9, i4 );  ie := xor( i8, xor( i4, i2 ) );
 
 
 			e0[i1] := S.VAL( SET32, ((v2*100H + v1)*100H + v1)*100H + v3 );
 			e0[i1] := S.VAL( SET32, ((v2*100H + v1)*100H + v1)*100H + v3 );
@@ -334,7 +334,7 @@ TYPE
 			t := f1( t );
 			t := f1( t );
 		END;
 		END;
 	END Initialize;
 	END Initialize;
-	
+
 
 
 BEGIN
 BEGIN
 	Initialize;
 	Initialize;

+ 0 - 1
source/CryptoARC4.Mod

@@ -74,4 +74,3 @@ TYPE
 
 
 END CryptoARC4.
 END CryptoARC4.
 
 
- 

+ 39 - 39
source/CryptoBase64.Mod

@@ -16,23 +16,23 @@ VAR
 		group := 0;  i := 0;  ix := 0;  ox := 0;
 		group := 0;  i := 0;  ix := 0;  ox := 0;
 		WHILE ix < len DO
 		WHILE ix < len DO
 			group := group*100H + ORD( image[ix] );  INC( ix );  INC( i );
 			group := group*100H + ORD( image[ix] );  INC( ix );  INC( i );
-			IF i = 3 THEN  
-				b64[ox] := etab[group DIV 40000H MOD 64];  
-				b64[ox+1] := etab[group DIV 1000H MOD 64];  
-				b64[ox+2] := etab[group DIV 40H MOD 64];  
-				b64[ox+3] := etab[group MOD 64];  
+			IF i = 3 THEN
+				b64[ox] := etab[group DIV 40000H MOD 64];
+				b64[ox+1] := etab[group DIV 1000H MOD 64];
+				b64[ox+2] := etab[group DIV 40H MOD 64];
+				b64[ox+3] := etab[group MOD 64];
 				INC( ox, 4 );
 				INC( ox, 4 );
 				group := 0;
 				group := 0;
-				i := 0 
+				i := 0
 			END;
 			END;
 		END;
 		END;
-		
+
 		IF i > 0 THEN	(*encode rest *)
 		IF i > 0 THEN	(*encode rest *)
 			IF i = 1 THEN  group := group*256  END;
 			IF i = 1 THEN  group := group*256  END;
-			b64[ox] := etab[group DIV 400H MOD 64];  
-			b64[ox+1] := etab[group DIV 10H MOD 64];  
+			b64[ox] := etab[group DIV 400H MOD 64];
+			b64[ox+1] := etab[group DIV 10H MOD 64];
 			IF i = 1 THEN  b64[ox+2] := '='  ELSE  b64[ox+2] := etab[group*4 MOD 64]  END;
 			IF i = 1 THEN  b64[ox+2] := '='  ELSE  b64[ox+2] := etab[group*4 MOD 64]  END;
-			b64[ox+3] := '=';  
+			b64[ox+3] := '=';
 			INC( ox, 4 );
 			INC( ox, 4 );
 		END;
 		END;
 		b64[ox] := 0X;
 		b64[ox] := 0X;
@@ -47,30 +47,30 @@ VAR
 		c: CHAR;
 		c: CHAR;
 	BEGIN
 	BEGIN
 		len := 0;  ix := 0;  group := 0;  i := 0;
 		len := 0;  ix := 0;  group := 0;  i := 0;
-		
+
 		REPEAT  c := b64[ix];  INC( ix )  UNTIL (c > ' ') OR (c = 0X);
 		REPEAT  c := b64[ix];  INC( ix )  UNTIL (c > ' ') OR (c = 0X);
-		code := dtab[ORD( c )]; 
+		code := dtab[ORD( c )];
 		WHILE code >= 0 DO
 		WHILE code >= 0 DO
 			group := group*64 + code;  INC( i );
 			group := group*64 + code;  INC( i );
-			IF i = 4 THEN  
+			IF i = 4 THEN
 				image[len] := CHR( group DIV 10000H MOD 100H );  INC( len );
 				image[len] := CHR( group DIV 10000H MOD 100H );  INC( len );
 				image[len] := CHR( group DIV 100H MOD 100H );  INC( len );
 				image[len] := CHR( group DIV 100H MOD 100H );  INC( len );
 				image[len] := CHR( group MOD 100H );  INC( len );
 				image[len] := CHR( group MOD 100H );  INC( len );
 				group := 0;  i := 0
 				group := 0;  i := 0
 			END;
 			END;
 			REPEAT  c := b64[ix];  INC( ix )  UNTIL (c > ' ') OR (c = 0X);
 			REPEAT  c := b64[ix];  INC( ix )  UNTIL (c > ' ') OR (c = 0X);
-			code := dtab[ORD( c )]; 
+			code := dtab[ORD( c )];
 		END;
 		END;
-					
+
 		IF c = '=' THEN  (* decode rest *)
 		IF c = '=' THEN  (* decode rest *)
 			IF i < 2 THEN  (* error *)  RETURN -1  END;
 			IF i < 2 THEN  (* error *)  RETURN -1  END;
-			group := group*64;  d := 1;  c := b64[ix];  
+			group := group*64;  d := 1;  c := b64[ix];
 			IF c = '=' THEN  group := group*64;  d := 2  END;
 			IF c = '=' THEN  group := group*64;  d := 2  END;
 			image[len] := CHR( group DIV 10000H );  INC( len );
 			image[len] := CHR( group DIV 10000H );  INC( len );
 			IF d = 1 THEN  image[len] := CHR( group DIV 100H MOD 100H );  INC( len )  END
 			IF d = 1 THEN  image[len] := CHR( group DIV 100H MOD 100H );  INC( len )  END
 		ELSIF i > 0 THEN  (* error *)  RETURN -1
 		ELSIF i > 0 THEN  (* error *)  RETURN -1
 		END;
 		END;
-		
+
 		RETURN len
 		RETURN len
 	END Decode;
 	END Decode;
 
 
@@ -85,7 +85,7 @@ VAR
 		group := 0;  i := 0; ix := 0;  ll := 0;
 		group := 0;  i := 0; ix := 0;  ll := 0;
 		WHILE ix < len DO
 		WHILE ix < len DO
 			group := group*100H + ORD( image[ix] );  INC( ix );  INC( i );
 			group := group*100H + ORD( image[ix] );  INC( ix );  INC( i );
-			IF i = 3 THEN  
+			IF i = 3 THEN
 				w.Char( etab[group DIV 40000H MOD 64] );
 				w.Char( etab[group DIV 40000H MOD 64] );
 				w.Char( etab[group DIV 1000H MOD 64] );
 				w.Char( etab[group DIV 1000H MOD 64] );
 				w.Char( etab[group DIV 40H MOD 64] );
 				w.Char( etab[group DIV 40H MOD 64] );
@@ -93,16 +93,16 @@ VAR
 				INC( ll, 4 );
 				INC( ll, 4 );
 				IF ll >= 72 THEN  w.Ln;  ll := 0  END;
 				IF ll >= 72 THEN  w.Ln;  ll := 0  END;
 				group := 0;
 				group := 0;
-				i := 0  
+				i := 0
 			END;
 			END;
 		END;
 		END;
-		
+
 		IF i > 0 THEN   (* encode rest *)
 		IF i > 0 THEN   (* encode rest *)
 			IF i = 1 THEN  group := group*100H  END;
 			IF i = 1 THEN  group := group*100H  END;
-			w.Char( etab[group DIV 400H MOD 64] );  
-			w.Char( etab[group DIV 10H MOD 64] );  
+			w.Char( etab[group DIV 400H MOD 64] );
+			w.Char( etab[group DIV 10H MOD 64] );
 			IF i = 1 THEN  w.Char( '=' )  ELSE  w.Char( etab[group*4 MOD 64] )  END;
 			IF i = 1 THEN  w.Char( '=' )  ELSE  w.Char( etab[group*4 MOD 64] )  END;
-			w.Char( '=' );  
+			w.Char( '=' );
 		END;
 		END;
 		w.Update
 		w.Update
  	END EncodeStream;
  	END EncodeStream;
@@ -116,30 +116,30 @@ VAR
 		c: CHAR;
 		c: CHAR;
 	BEGIN
 	BEGIN
 		len := 0; group := 0;  i := 0;
 		len := 0; group := 0;  i := 0;
-		
+
 		REPEAT  r.Char( c )  UNTIL (c > ' ') OR (c = 0X);
 		REPEAT  r.Char( c )  UNTIL (c > ' ') OR (c = 0X);
-		code := dtab[ORD( c )]; 
+		code := dtab[ORD( c )];
 		WHILE code >= 0 DO
 		WHILE code >= 0 DO
 			group := group*64 + code;  INC( i );
 			group := group*64 + code;  INC( i );
-			IF i = 4 THEN  
+			IF i = 4 THEN
 				image[len] := CHR( group DIV 10000H MOD 100H );  INC( len );
 				image[len] := CHR( group DIV 10000H MOD 100H );  INC( len );
 				image[len] := CHR( group DIV 100H MOD 100H );  INC( len );
 				image[len] := CHR( group DIV 100H MOD 100H );  INC( len );
 				image[len] := CHR( group MOD 100H );  INC( len );
 				image[len] := CHR( group MOD 100H );  INC( len );
 				group := 0;  i := 0
 				group := 0;  i := 0
 			END;
 			END;
 			REPEAT  r.Char( c )  UNTIL (c > ' ') OR (c = 0X);
 			REPEAT  r.Char( c )  UNTIL (c > ' ') OR (c = 0X);
-			code := dtab[ORD( c )];  
+			code := dtab[ORD( c )];
 		END;
 		END;
-		
+
 		IF c = '=' THEN   (* decode rest *)
 		IF c = '=' THEN   (* decode rest *)
 			IF i < 2 THEN  (* error *)  RETURN -1  END;
 			IF i < 2 THEN  (* error *)  RETURN -1  END;
-			group := group*64;  rest := 2;  r.Char( c );  
+			group := group*64;  rest := 2;  r.Char( c );
 			IF c = '=' THEN  group := group*64;  rest := 1  END;
 			IF c = '=' THEN  group := group*64;  rest := 1  END;
 			image[len] := CHR( group DIV 10000H );  INC( len );
 			image[len] := CHR( group DIV 10000H );  INC( len );
 			IF rest = 2 THEN  image[len] := CHR( group DIV 100H MOD 100H );  INC( len )  END
 			IF rest = 2 THEN  image[len] := CHR( group DIV 100H MOD 100H );  INC( len )  END
 		ELSIF i > 0 THEN  (* error *)  RETURN -1
 		ELSIF i > 0 THEN  (* error *)  RETURN -1
 		END;
 		END;
-		
+
 		RETURN len
 		RETURN len
 	END DecodeStream;
 	END DecodeStream;
 
 
@@ -147,7 +147,7 @@ VAR
 	PROCEDURE InitTables;
 	PROCEDURE InitTables;
 	CONST
 	CONST
 		letters = 26;  digits = 10;
 		letters = 26;  digits = 10;
-	VAR 
+	VAR
 		i, j: INTEGER;
 		i, j: INTEGER;
 	BEGIN
 	BEGIN
 		j := 0;
 		j := 0;
@@ -159,13 +159,13 @@ VAR
 		FOR i := 0 TO 127 DO  dtab[i] := -1  END;
 		FOR i := 0 TO 127 DO  dtab[i] := -1  END;
 		FOR i := 0 TO 63 DO  dtab[ORD( etab[i] )] := i  END
 		FOR i := 0 TO 63 DO  dtab[ORD( etab[i] )] := i  END
 	END InitTables;
 	END InitTables;
-	
+
 	(*
 	(*
 	(* testing: expected behaviour:  "admin:1234"  =>  "YWRtaW46MTIzNA=="  =>  "admin:1234"*)
 	(* testing: expected behaviour:  "admin:1234"  =>  "YWRtaW46MTIzNA=="  =>  "admin:1234"*)
 	PROCEDURE Test*( c: Commands.Context );
 	PROCEDURE Test*( c: Commands.Context );
 	VAR image, base64: ARRAY 80 OF CHAR;  len: LONGINT; r: Streams.StringReader;
 	VAR image, base64: ARRAY 80 OF CHAR;  len: LONGINT; r: Streams.StringReader;
 	BEGIN
 	BEGIN
-		c.out.String( 'admin:1234  =>  ' ); 
+		c.out.String( 'admin:1234  =>  ' );
 		image := 'admin:123456789';
 		image := 'admin:123456789';
 		Encode( image, 10, base64 );
 		Encode( image, 10, base64 );
 		c.out.String( base64 ); c.out.String( "  =>  " );
 		c.out.String( base64 ); c.out.String( "  =>  " );
@@ -174,25 +174,25 @@ VAR
 			image[len] := 0X;
 			image[len] := 0X;
 			c.out.String(image); c.out.Ln;
 			c.out.String(image); c.out.Ln;
 		END;
 		END;
-		
+
 		c.out.String( 'admin:1234  =>  ' );
 		c.out.String( 'admin:1234  =>  ' );
 		EncodeStream( 'admin:123456789', 10, c.out );  c.out.String( "  =>  " );
 		EncodeStream( 'admin:123456789', 10, c.out );  c.out.String( "  =>  " );
 		NEW( r, 80 );  r.Set( base64 );
 		NEW( r, 80 );  r.Set( base64 );
-		len := DecodeStream( r, image );  
-		IF len > 0 THEN  
+		len := DecodeStream( r, image );
+		IF len > 0 THEN
 			image[len] := 0X;
 			image[len] := 0X;
 			c.out.String( image ); c.out.Ln
 			c.out.String( image ); c.out.Ln
 		END
 		END
 	END Test;
 	END Test;
 	*)
 	*)
-	
+
 
 
 BEGIN
 BEGIN
 	InitTables();
 	InitTables();
 END CryptoBase64.
 END CryptoBase64.
 
 
-	
-	
+
+
 	CryptoBase64.Test ~
 	CryptoBase64.Test ~
 
 
 	System.Free CryptoBase64 ~
 	System.Free CryptoBase64 ~

+ 17 - 17
source/CryptoBigNumbers.Mod

@@ -32,7 +32,7 @@ TYPE
 					END;
 					END;
 					len := 0;  neg := FALSE
 					len := 0;  neg := FALSE
 				END Init;
 				END Init;
-				
+
 				PROCEDURE Mask*( bits: LONGINT );
 				PROCEDURE Mask*( bits: LONGINT );
 				VAR w, b: LONGINT;
 				VAR w, b: LONGINT;
 				BEGIN
 				BEGIN
@@ -42,27 +42,27 @@ TYPE
 					END
 					END
 				END Mask;
 				END Mask;
 
 
-				
+
 				PROCEDURE IsZero*( ): BOOLEAN;
 				PROCEDURE IsZero*( ): BOOLEAN;
 				BEGIN
 				BEGIN
 					RETURN (len = 0) OR ((len = 1) & (d[0] = 0))
 					RETURN (len = 0) OR ((len = 1) & (d[0] = 0))
 				END IsZero;
 				END IsZero;
-				
+
 				PROCEDURE EQ* ( b: BigNumber ): BOOLEAN;
 				PROCEDURE EQ* ( b: BigNumber ): BOOLEAN;
 				BEGIN
 				BEGIN
 					RETURN Cmp( SELF, b ) = 0
 					RETURN Cmp( SELF, b ) = 0
 				END EQ;
 				END EQ;
-				
+
 				PROCEDURE NEQ* ( b: BigNumber ): BOOLEAN;
 				PROCEDURE NEQ* ( b: BigNumber ): BOOLEAN;
 				BEGIN
 				BEGIN
 					RETURN Cmp( SELF, b ) # 0
 					RETURN Cmp( SELF, b ) # 0
 				END NEQ;
 				END NEQ;
-				
+
 				PROCEDURE GT* ( b: BigNumber ): BOOLEAN;
 				PROCEDURE GT* ( b: BigNumber ): BOOLEAN;
 				BEGIN
 				BEGIN
 					RETURN Cmp( SELF, b ) > 0
 					RETURN Cmp( SELF, b ) > 0
 				END GT;
 				END GT;
-				
+
 				PROCEDURE GEQ* ( b: BigNumber ): BOOLEAN;
 				PROCEDURE GEQ* ( b: BigNumber ): BOOLEAN;
 				BEGIN
 				BEGIN
 					RETURN Cmp( SELF, b ) >= 0
 					RETURN Cmp( SELF, b ) >= 0
@@ -76,16 +76,16 @@ TYPE
 					IF len = 0 THEN  RETURN  END;
 					IF len = 0 THEN  RETURN  END;
 					IF n < 0 THEN  right := TRUE;  n := ABS( n )  ELSE  right := FALSE  END;
 					IF n < 0 THEN  right := TRUE;  n := ABS( n )  ELSE  right := FALSE  END;
 					w := n DIV 32;  bits := n MOD 32;
 					w := n DIV 32;  bits := n MOD 32;
-					IF ~right THEN  
+					IF ~right THEN
 						adjust( len + w + 1 );
 						adjust( len + w + 1 );
 						IF w > 0 THEN
 						IF w > 0 THEN
 							FOR i := len - 1 TO 0 BY -1 DO  d[i + w] := d[i]  END;
 							FOR i := len - 1 TO 0 BY -1 DO  d[i + w] := d[i]  END;
 							FOR i := 0 TO w - 1 DO  d[i] := 0  END;
 							FOR i := 0 TO w - 1 DO  d[i] := 0  END;
 							INC( len, w )
 							INC( len, w )
 						END;
 						END;
-						IF bits > 0 THEN  
+						IF bits > 0 THEN
 							d[len] := 0;
 							d[len] := 0;
-							FOR i := len TO 0 BY -1 DO  
+							FOR i := len TO 0 BY -1 DO
 								a := d[i];
 								a := d[i];
 								IF i > 0 THEN  b := d[i - 1]  ELSE  b := 0  END;
 								IF i > 0 THEN  b := d[i - 1]  ELSE  b := 0  END;
 								d[i] := LSH( a, bits ) + LSH( b, -32 + bits )
 								d[i] := LSH( a, bits ) + LSH( b, -32 + bits )
@@ -97,7 +97,7 @@ TYPE
 							FOR i := 0 TO len - w - 1 DO  d[i] := d[i + w]  END;
 							FOR i := 0 TO len - w - 1 DO  d[i] := d[i + w]  END;
 							DEC( len, w )
 							DEC( len, w )
 						END;
 						END;
-						IF bits > 0 THEN  
+						IF bits > 0 THEN
 							l := len;
 							l := len;
 							FOR i := 0 TO  l - 1 DO  a := d[i];
 							FOR i := 0 TO  l - 1 DO  a := d[i];
 								IF i < l - 1 THEN  b := d[i + 1]  ELSE  b := 0  END;
 								IF i < l - 1 THEN  b := d[i + 1]  ELSE  b := 0  END;
@@ -107,7 +107,7 @@ TYPE
 						END
 						END
 					END;
 					END;
 				END Shift;
 				END Shift;
-				
+
 
 
 				PROCEDURE Dec*;
 				PROCEDURE Dec*;
 				VAR i: LONGINT;
 				VAR i: LONGINT;
@@ -141,7 +141,7 @@ TYPE
 				BEGIN
 				BEGIN
 					IF ~IsZero( ) THEN  neg := ~neg  END
 					IF ~IsZero( ) THEN  neg := ~neg  END
 				END Negate;
 				END Negate;
-	
+
 				PROCEDURE BitSize*( ): LONGINT;
 				PROCEDURE BitSize*( ): LONGINT;
 				VAR n: LONGINT; t: BNdigit;
 				VAR n: LONGINT; t: BNdigit;
 				BEGIN
 				BEGIN
@@ -150,7 +150,7 @@ TYPE
 					END;
 					END;
 					t := d[len - 1];
 					t := d[len - 1];
 					WHILE t # 0 DO  INC( n );  t := LSH( t, -1 )  END;
 					WHILE t # 0 DO  INC( n );  t := LSH( t, -1 )  END;
-					RETURN n 
+					RETURN n
 				END BitSize;
 				END BitSize;
 
 
 				PROCEDURE BitSet*( n: LONGINT ): BOOLEAN;
 				PROCEDURE BitSet*( n: LONGINT ): BOOLEAN;
@@ -197,7 +197,7 @@ TYPE
 				PROCEDURE Convert( VAR val: BigNumber ); 	(* val := val ^ R mod n *)
 				PROCEDURE Convert( VAR val: BigNumber ); 	(* val := val ^ R mod n *)
 				VAR i: LONGINT;
 				VAR i: LONGINT;
 				BEGIN
 				BEGIN
-					FOR i := 0 TO bits - 1 DO  
+					FOR i := 0 TO bits - 1 DO
 						val.Shift( 1 );
 						val.Shift( 1 );
 						IF ucmp( val, n ) >= 0 THEN  val := Sub( val, n )  END
 						IF ucmp( val, n ) >= 0 THEN  val := Sub( val, n )  END
 					END
 					END
@@ -841,9 +841,9 @@ VAR
 	BEGIN
 	BEGIN
 		REPEAT
 		REPEAT
 			REPEAT r.Char( c ) UNTIL (c > ' ') OR (r.Available() = 0);
 			REPEAT r.Char( c ) UNTIL (c > ' ') OR (r.Available() = 0);
-		UNTIL	(r.Available() = 0) OR 
-				(c >= '0') & (c <= '9') OR 
-				(c >= 'A') & (c <= 'F') OR 
+		UNTIL	(r.Available() = 0) OR
+				(c >= '0') & (c <= '9') OR
+				(c >= 'A') & (c <= 'F') OR
 				(c >= 'a') & (c <= 'f') OR (c = '.');
 				(c >= 'a') & (c <= 'f') OR (c = '.');
 		RETURN c
 		RETURN c
 	END nibble;
 	END nibble;

+ 17 - 17
source/CryptoBlowfish.Mod

@@ -9,11 +9,11 @@ MODULE CryptoBlowfish;   (** AUTHOR "GF"; PURPOSE "Blowfish en/decryption"; *)
 IMPORT Ciphers := CryptoCiphers, S := SYSTEM, U := CryptoUtils;
 IMPORT Ciphers := CryptoCiphers, S := SYSTEM, U := CryptoUtils;
 
 
 CONST
 CONST
-	N = 16;  
+	N = 16;
 
 
 TYPE
 TYPE
 	TP = ARRAY N + 2 OF SET32;
 	TP = ARRAY N + 2 OF SET32;
-	TS = RECORD 
+	TS = RECORD
 			a	: ARRAY 256 OF LONGINT;
 			a	: ARRAY 256 OF LONGINT;
 			b	: ARRAY 256 OF LONGINT;
 			b	: ARRAY 256 OF LONGINT;
 			c	: ARRAY 256 OF SET32;
 			c	: ARRAY 256 OF SET32;
@@ -34,32 +34,32 @@ TYPE
 				VAR i, m: LONGINT;  xl, xr: SET32;
 				VAR i, m: LONGINT;  xl, xr: SET32;
 				BEGIN
 				BEGIN
 					InitKey^( src, keybits );  m := keybits DIV 8;  s := s0;
 					InitKey^( src, keybits );  m := keybits DIV 8;  s := s0;
-					FOR i := 0 TO N + 1 DO  
-						p[i] := p0[i] / U.SetFromBufferBE( src, (4*i) MOD m )  
+					FOR i := 0 TO N + 1 DO
+						p[i] := p0[i] / U.SetFromBufferBE( src, (4*i) MOD m )
 					END;
 					END;
 					xl := {};  xr := {};
 					xl := {};  xr := {};
 					FOR i := 0 TO N BY 2 DO  encrypt0( xl, xr, xl, xr );  p[i] := xl;  p[i + 1] := xr  END;
 					FOR i := 0 TO N BY 2 DO  encrypt0( xl, xr, xl, xr );  p[i] := xl;  p[i + 1] := xr  END;
 					FOR i := 0 TO 254 BY 2 DO
 					FOR i := 0 TO 254 BY 2 DO
-						encrypt0( xl, xr, xl, xr );  
+						encrypt0( xl, xr, xl, xr );
 						s.a[i] := S.VAL( LONGINT, xl );  s.a[i + 1] := S.VAL( LONGINT, xr );
 						s.a[i] := S.VAL( LONGINT, xl );  s.a[i + 1] := S.VAL( LONGINT, xr );
 					END;
 					END;
 					FOR i := 0 TO 254 BY 2 DO
 					FOR i := 0 TO 254 BY 2 DO
-						encrypt0( xl, xr, xl, xr );  
+						encrypt0( xl, xr, xl, xr );
 						s.b[i] := S.VAL( LONGINT, xl );  s.b[i + 1] := S.VAL( LONGINT, xr );
 						s.b[i] := S.VAL( LONGINT, xl );  s.b[i + 1] := S.VAL( LONGINT, xr );
 					END;
 					END;
 					FOR i := 0 TO 254 BY 2 DO
 					FOR i := 0 TO 254 BY 2 DO
-						encrypt0( xl, xr, xl, xr );  
+						encrypt0( xl, xr, xl, xr );
 						s.c[i] := xl;  s.c[i + 1] := xr;
 						s.c[i] := xl;  s.c[i + 1] := xr;
 					END;
 					END;
 					FOR i := 0 TO 254 BY 2 DO
 					FOR i := 0 TO 254 BY 2 DO
-						encrypt0( xl, xr, xl, xr );  
+						encrypt0( xl, xr, xl, xr );
 						s.d[i] := S.VAL( LONGINT, xl );  s.d[i + 1] := S.VAL( LONGINT, xr );
 						s.d[i] := S.VAL( LONGINT, xl );  s.d[i + 1] := S.VAL( LONGINT, xr );
 					END
 					END
 				END InitKey;
 				END InitKey;
 
 
 				PROCEDURE SetIV*( CONST src: ARRAY OF CHAR; mode: SHORTINT );
 				PROCEDURE SetIV*( CONST src: ARRAY OF CHAR; mode: SHORTINT );
 				BEGIN
 				BEGIN
-					SetIV^( src, mode );  
+					SetIV^( src, mode );
 					ivl := U.SetFromBufferBE( src, 0 );  ivr := U.SetFromBufferBE( src, 4 );
 					ivl := U.SetFromBufferBE( src, 0 );  ivr := U.SetFromBufferBE( src, 4 );
 				END SetIV;
 				END SetIV;
 
 
@@ -99,11 +99,11 @@ TYPE
 					IF mode = Ciphers.CBC THEN  yl := yl/ivl;  yr := yr/ivr;  ivl := xl;  ivr := xr  END;
 					IF mode = Ciphers.CBC THEN  yl := yl/ivl;  yr := yr/ivr;  ivl := xl;  ivr := xr  END;
 					U.SetToBufferBE( yl, buf, pos );  U.SetToBufferBE( yr, buf, pos + 4 )
 					U.SetToBufferBE( yl, buf, pos );  U.SetToBufferBE( yr, buf, pos + 4 )
 				END DecryptBlock;
 				END DecryptBlock;
-				
-				
+
+
 				PROCEDURE F( x: LONGINT ): SET32;
 				PROCEDURE F( x: LONGINT ): SET32;
-				VAR 
-					ab, c: SET32; d: LONGINT; 
+				VAR
+					ab, c: SET32; d: LONGINT;
 				BEGIN
 				BEGIN
 					ab := S.VAL( SET32, s.a[x DIV 1000000H MOD 100H] + s.b[x DIV 10000H MOD 100H] );
 					ab := S.VAL( SET32, s.a[x DIV 1000000H MOD 100H] + s.b[x DIV 10000H MOD 100H] );
 					c := s.c[x DIV 100H MOD 100H];
 					c := s.c[x DIV 100H MOD 100H];
@@ -160,7 +160,7 @@ TYPE
 		buf.Add( "452821E6 38D01377 BE5466CF 34E90C6C C0AC29B7 C97C50DD 3F84D5B5 B5470917" );
 		buf.Add( "452821E6 38D01377 BE5466CF 34E90C6C C0AC29B7 C97C50DD 3F84D5B5 B5470917" );
 		buf.Add( "9216D5D9 8979FB1B" );
 		buf.Add( "9216D5D9 8979FB1B" );
 		FOR i := 0 TO N + 2 - 1 DO   p0[i] := buf.GetSet()  END;
 		FOR i := 0 TO N + 2 - 1 DO   p0[i] := buf.GetSet()  END;
-		
+
 		buf.Init( 4096 );
 		buf.Init( 4096 );
 		buf.Add( "D1310BA6 98DFB5AC 2FFD72DB D01ADFB7 B8E1AFED 6A267E96 BA7C9045 F12C7F99" );
 		buf.Add( "D1310BA6 98DFB5AC 2FFD72DB D01ADFB7 B8E1AFED 6A267E96 BA7C9045 F12C7F99" );
 		buf.Add( "24A19947 B3916CF7 0801F2E2 858EFC16 636920D8 71574E69 A458FEA3 F4933D7E" );
 		buf.Add( "24A19947 B3916CF7 0801F2E2 858EFC16 636920D8 71574E69 A458FEA3 F4933D7E" );
@@ -195,7 +195,7 @@ TYPE
 		buf.Add( "D60F573F BC9BC6E4 2B60A476 81E67400 08BA6FB5 571BE91F F296EC6B 2A0DD915" );
 		buf.Add( "D60F573F BC9BC6E4 2B60A476 81E67400 08BA6FB5 571BE91F F296EC6B 2A0DD915" );
 		buf.Add( "B6636521 E7B9F9B6 FF34052E C5855664 53B02D5D A99F8FA1 08BA4799 6E85076A" );
 		buf.Add( "B6636521 E7B9F9B6 FF34052E C5855664 53B02D5D A99F8FA1 08BA4799 6E85076A" );
 		FOR i := 0 TO 255 DO  s0.a[i] :=  buf.GetInt()  END;
 		FOR i := 0 TO 255 DO  s0.a[i] :=  buf.GetInt()  END;
-		
+
 		buf.Init( 4096 );
 		buf.Init( 4096 );
 		buf.Add( "4B7A70E9 B5B32944 DB75092E C4192623 AD6EA6B0 49A7DF7D 9CEE60B8 8FEDB266" );
 		buf.Add( "4B7A70E9 B5B32944 DB75092E C4192623 AD6EA6B0 49A7DF7D 9CEE60B8 8FEDB266" );
 		buf.Add( "ECAA8C71 699A17FF 5664526C C2B19EE1 193602A5 75094C29 A0591340 E4183A3E" );
 		buf.Add( "ECAA8C71 699A17FF 5664526C C2B19EE1 193602A5 75094C29 A0591340 E4183A3E" );
@@ -230,7 +230,7 @@ TYPE
 		buf.Add( "9E447A2E C3453484 FDD56705 0E1E9EC9 DB73DBD3 105588CD 675FDA79 E3674340" );
 		buf.Add( "9E447A2E C3453484 FDD56705 0E1E9EC9 DB73DBD3 105588CD 675FDA79 E3674340" );
 		buf.Add( "C5C43465 713E38D8 3D28F89E F16DFF20 153E21E7 8FB03D4A E6E39F2B DB83ADF7" );
 		buf.Add( "C5C43465 713E38D8 3D28F89E F16DFF20 153E21E7 8FB03D4A E6E39F2B DB83ADF7" );
 		FOR i := 0 TO 255 DO  s0.b[i] :=  buf.GetInt()  END;
 		FOR i := 0 TO 255 DO  s0.b[i] :=  buf.GetInt()  END;
-		
+
 		buf.Init( 4096 );
 		buf.Init( 4096 );
 		buf.Add( "E93D5A68 948140F7 F64C261C 94692934 411520F7 7602D4F7 BCF46B2E D4A20068" );
 		buf.Add( "E93D5A68 948140F7 F64C261C 94692934 411520F7 7602D4F7 BCF46B2E D4A20068" );
 		buf.Add( "D4082471 3320F46A 43B7D4B7 500061AF 1E39F62E 97244546 14214F74 BF8B8840" );
 		buf.Add( "D4082471 3320F46A 43B7D4B7 500061AF 1E39F62E 97244546 14214F74 BF8B8840" );
@@ -265,7 +265,7 @@ TYPE
 		buf.Add( "ED545578 08FCA5B5 D83D7CD3 4DAD0FC4 1E50EF5E B161E6F8 A28514D9 6C51133C" );
 		buf.Add( "ED545578 08FCA5B5 D83D7CD3 4DAD0FC4 1E50EF5E B161E6F8 A28514D9 6C51133C" );
 		buf.Add( "6FD5C7E7 56E14EC4 362ABFCE DDC6C837 D79A3234 92638212 670EFA8E 406000E0" );
 		buf.Add( "6FD5C7E7 56E14EC4 362ABFCE DDC6C837 D79A3234 92638212 670EFA8E 406000E0" );
 		FOR i := 0 TO 255 DO  s0.c[i] :=  buf.GetSet()  END;
 		FOR i := 0 TO 255 DO  s0.c[i] :=  buf.GetSet()  END;
-		
+
 		buf.Init( 4096 );
 		buf.Init( 4096 );
 		buf.Add( "3A39CE37 D3FAF5CF ABC27737 5AC52D1B 5CB0679E 4FA33742 D3822740 99BC9BBE" );
 		buf.Add( "3A39CE37 D3FAF5CF ABC27737 5AC52D1B 5CB0679E 4FA33742 D3822740 99BC9BBE" );
 		buf.Add( "D5118E9D BF0F7315 D62D1C7E C700C47B B78C1B6B 21A19045 B26EB1BE 6A366EB4" );
 		buf.Add( "D5118E9D BF0F7315 D62D1C7E C700C47B B78C1B6B 21A19045 B26EB1BE 6A366EB4" );

+ 5 - 5
source/CryptoCAST.Mod

@@ -196,7 +196,7 @@ TYPE
 		b := T1[t MOD 256];  t := t DIV 256;
 		b := T1[t MOD 256];  t := t DIV 256;
 		a := T0[t MOD 256];  t := t DIV 256;
 		a := T0[t MOD 256];  t := t DIV 256;
 		d := T3[t MOD 256];  t := t DIV 256;
 		d := T3[t MOD 256];  t := t DIV 256;
-		c := T2[t MOD 256];  
+		c := T2[t MOD 256];
 		L := L / (S.VAL( SET32, a - b + c ) / S.VAL( SET32, d ) );
 		L := L / (S.VAL( SET32, a - b + c ) / S.VAL( SET32, d ) );
 	END CAST2;
 	END CAST2;
 
 
@@ -207,7 +207,7 @@ TYPE
 		b := T1[t MOD 256];  t := t DIV 256;
 		b := T1[t MOD 256];  t := t DIV 256;
 		a := T0[t MOD 256];  t := t DIV 256;
 		a := T0[t MOD 256];  t := t DIV 256;
 		d := T3[t MOD 256];  t := t DIV 256;
 		d := T3[t MOD 256];  t := t DIV 256;
-		c := T2[t MOD 256];  
+		c := T2[t MOD 256];
 		L := L / S.VAL( SET32, S.VAL( LI, S.VAL( SET32, a + b ) / S.VAL( SET32, c ) ) - d );
 		L := L / S.VAL( SET32, S.VAL( LI, S.VAL( SET32, a + b ) / S.VAL( SET32, c ) ) - d );
 	END CAST3;
 	END CAST3;
 
 
@@ -244,7 +244,7 @@ TYPE
 	END decrypt;
 	END decrypt;
 
 
 
 
-	
+
 	PROCEDURE Init;
 	PROCEDURE Init;
 	VAR  buf: U.InitBuffer;  i: LONGINT;
 	VAR  buf: U.InitBuffer;  i: LONGINT;
 	BEGIN
 	BEGIN
@@ -282,7 +282,7 @@ TYPE
 		buf.Add( "BD91E046  9A56456E  DC39200C  20C8C571  962BDA1C  E1E696FF  B141AB08  7CCA89B9" );
 		buf.Add( "BD91E046  9A56456E  DC39200C  20C8C571  962BDA1C  E1E696FF  B141AB08  7CCA89B9" );
 		buf.Add( "1A69E783  02CC4843  A2F7C579  429EF47D  427B169C  5AC9F049  DD8F0F00  5C8165BF" );
 		buf.Add( "1A69E783  02CC4843  A2F7C579  429EF47D  427B169C  5AC9F049  DD8F0F00  5C8165BF" );
 		FOR i := 0 TO 255 DO  T0[i] := buf.GetInt()  END;
 		FOR i := 0 TO 255 DO  T0[i] := buf.GetInt()  END;
-		
+
 		buf.Init( 4096 );
 		buf.Init( 4096 );
 		buf.Add( "1F201094  EF0BA75B  69E3CF7E  393F4380  FE61CF7A  EEC5207A  55889C94  72FC0651" );
 		buf.Add( "1F201094  EF0BA75B  69E3CF7E  393F4380  FE61CF7A  EEC5207A  55889C94  72FC0651" );
 		buf.Add( "ADA7EF79  4E1D7235  D55A63CE  DE0436BA  99C430EF  5F0C0794  18DCDB7D  A1D6EFF3" );
 		buf.Add( "ADA7EF79  4E1D7235  D55A63CE  DE0436BA  99C430EF  5F0C0794  18DCDB7D  A1D6EFF3" );
@@ -528,7 +528,7 @@ TYPE
 		buf.Add( "04F19130  BA6E4EC0  99265164  1EE7230D  50B2AD80  EAEE6801  8DB2A283  EA8BF59E" );
 		buf.Add( "04F19130  BA6E4EC0  99265164  1EE7230D  50B2AD80  EAEE6801  8DB2A283  EA8BF59E" );
 		FOR i := 0 TO 255 DO  T7[i] := buf.GetSet()  END;
 		FOR i := 0 TO 255 DO  T7[i] := buf.GetSet()  END;
 	END Init;
 	END Init;
-	
+
 
 
 
 
 BEGIN
 BEGIN

+ 12 - 12
source/CryptoCSPRNG.Mod

@@ -1,19 +1,19 @@
 MODULE CryptoCSPRNG;	(** AUTHOR "GF"; PURPOSE "Cryptographically Secure Pseudo-Random Generator."*)
 MODULE CryptoCSPRNG;	(** AUTHOR "GF"; PURPOSE "Cryptographically Secure Pseudo-Random Generator."*)
- 
- 
+
+
 IMPORT  Machine, Clock, Heaps, SHA3 := CryptoSHA3(*, Out := KernelLog*);
 IMPORT  Machine, Clock, Heaps, SHA3 := CryptoSHA3(*, Out := KernelLog*);
 
 
 
 
 	PROCEDURE CSRand*( VAR rand: ARRAY OF CHAR; bits: LONGINT );
 	PROCEDURE CSRand*( VAR rand: ARRAY OF CHAR; bits: LONGINT );
-	VAR 
+	VAR
 		seed: HUGEINT; i, j, len: LONGINT;
 		seed: HUGEINT; i, j, len: LONGINT;
 		h: SHA3.Hash;
 		h: SHA3.Hash;
 		buf: ARRAY 64 OF CHAR;
 		buf: ARRAY 64 OF CHAR;
 	BEGIN
 	BEGIN
 		ASSERT( (bits MOD 8 = 0) & (bits DIV 8 <= LEN( rand )) );
 		ASSERT( (bits MOD 8 = 0) & (bits DIV 8 <= LEN( rand )) );
 		seed := Noise();
 		seed := Noise();
-		FOR i := 0 TO 7 DO  
-			buf[i] := CHR( seed MOD 100H );  seed := seed DIV 100H  
+		FOR i := 0 TO 7 DO
+			buf[i] := CHR( seed MOD 100H );  seed := seed DIV 100H
 		END;
 		END;
 		NEW( h );  h.SetNameAndSize( "", 64 );
 		NEW( h );  h.SetNameAndSize( "", 64 );
 		h.Update( buf, 0, 8 );
 		h.Update( buf, 0, 8 );
@@ -21,7 +21,7 @@ IMPORT  Machine, Clock, Heaps, SHA3 := CryptoSHA3(*, Out := KernelLog*);
 		i := 0;  j := 0;  len := bits DIV 8;
 		i := 0;  j := 0;  len := bits DIV 8;
 		WHILE j < len DO
 		WHILE j < len DO
 			IF i = 64 THEN
 			IF i = 64 THEN
-				h.Initialize;  
+				h.Initialize;
 				h.Update( buf, 0, 64 );
 				h.Update( buf, 0, 64 );
 				h.GetHash( buf, 0 );
 				h.GetHash( buf, 0 );
 				i := 0
 				i := 0
@@ -29,17 +29,17 @@ IMPORT  Machine, Clock, Heaps, SHA3 := CryptoSHA3(*, Out := KernelLog*);
 			rand[j] := buf[i];  INC( j ); INC( i )
 			rand[j] := buf[i];  INC( j ); INC( i )
 		END
 		END
 	END CSRand;
 	END CSRand;
-	
+
 	PROCEDURE Noise( ): HUGEINT;
 	PROCEDURE Noise( ): HUGEINT;
 	VAR tm, dt: HUGEINT; t, d: LONGINT;  total, free, largest: SIZE;
 	VAR tm, dt: HUGEINT; t, d: LONGINT;  total, free, largest: SIZE;
 	BEGIN
 	BEGIN
 		tm := Machine.GetTimer( );
 		tm := Machine.GetTimer( );
-		Clock.Get( t, d );  
+		Clock.Get( t, d );
 		dt := LONG( d ) * 1000000H + t;
 		dt := LONG( d ) * 1000000H + t;
-		Heaps.GetHeapInfo( total, free, largest ); 
+		Heaps.GetHeapInfo( total, free, largest );
 		RETURN  (tm + 4*dt + Heaps.Nmark) * (Heaps.Ngc + 1) + (total - free + largest )
 		RETURN  (tm + 4*dt + Heaps.Nmark) * (Heaps.Ngc + 1) + (total - free + largest )
 	END Noise;
 	END Noise;
-	
+
 	(*
 	(*
 	PROCEDURE Test*;
 	PROCEDURE Test*;
 	CONST HT = 09X;
 	CONST HT = 09X;
@@ -55,11 +55,11 @@ IMPORT  Machine, Clock, Heaps, SHA3 := CryptoSHA3(*, Out := KernelLog*);
 		Out.Ln
 		Out.Ln
 	END Test;
 	END Test;
 	*)
 	*)
-	
+
 
 
 END CryptoCSPRNG.
 END CryptoCSPRNG.
 
 
 
 
 	CryptoCSPRNG.Test ~
 	CryptoCSPRNG.Test ~
-	
+
 	System.Free CryptoCSPRNG ~
 	System.Free CryptoCSPRNG ~

+ 1 - 1
source/CryptoCiphers.Mod

@@ -50,7 +50,7 @@ TYPE
 				BEGIN
 				BEGIN
 					ASSERT( isKeyInitialized );   (* initKey must have been called before *)
 					ASSERT( isKeyInitialized );   (* initKey must have been called before *)
 					ASSERT( mode IN {CBC, CTR} );
 					ASSERT( mode IN {CBC, CTR} );
-					SELF.mode := mode;  
+					SELF.mode := mode;
 					IF mode = CBC THEN  appmode( "-cbc" ) ELSE  appmode( "-ctr" )  END
 					IF mode = CBC THEN  appmode( "-cbc" ) ELSE  appmode( "-ctr" )  END
 				END SetIV;
 				END SetIV;
 
 

+ 67 - 67
source/CryptoDES.Mod

@@ -5,7 +5,7 @@ MODULE CryptoDES;	(** AUTHOR "G.F."; PUROSE "DES Cipher";	 *)
 
 
 
 
 IMPORT S := SYSTEM, U := CryptoUtils, Ciphers := CryptoCiphers;
 IMPORT S := SYSTEM, U := CryptoUtils, Ciphers := CryptoCiphers;
-CONST 
+CONST
 	Mask01 = S.VAL( SET32, 0AAAAAAAAH );
 	Mask01 = S.VAL( SET32, 0AAAAAAAAH );
 	Mask02 = S.VAL( SET32, 33333333H );
 	Mask02 = S.VAL( SET32, 33333333H );
 	Mask04 = S.VAL( SET32, 0F0F0F0FH );
 	Mask04 = S.VAL( SET32, 0F0F0F0FH );
@@ -16,41 +16,41 @@ TYPE
 	Sandbox = ARRAY 64 OF SET32;
 	Sandbox = ARRAY 64 OF SET32;
 	BitSwap = ARRAY 16 OF SET32;
 	BitSwap = ARRAY 16 OF SET32;
 	Ind4* = RECORD a-, b-, c-, d-: LONGINT END;
 	Ind4* = RECORD a-, b-, c-, d-: LONGINT END;
-	
+
 VAR
 VAR
 	sb1-, sb2-, sb3-, sb4-, sb5-, sb6-, sb7-, sb8-: Sandbox;
 	sb1-, sb2-, sb3-, sb4-, sb5-, sb6-, sb7-, sb8-: Sandbox;
 	LHs, RHs: BitSwap;
 	LHs, RHs: BitSwap;
-	
-TYPE 
-	Cipher* = OBJECT (Ciphers.Cipher)		
+
+TYPE
+	Cipher* = OBJECT (Ciphers.Cipher)
 	VAR
 	VAR
 		ske, skd: ARRAY 32 OF SET32;  ki: LONGINT;
 		ske, skd: ARRAY 32 OF SET32;  ki: LONGINT;
 		ivx, ivy: SET32;
 		ivx, ivy: SET32;
-	
+
 		PROCEDURE InitKey*( CONST src: ARRAY OF CHAR;  keybits: LONGINT );
 		PROCEDURE InitKey*( CONST src: ARRAY OF CHAR;  keybits: LONGINT );
 		VAR X, Y: SET32;  i: LONGINT;
 		VAR X, Y: SET32;  i: LONGINT;
 		BEGIN
 		BEGIN
 			ASSERT( keybits = 64 );
 			ASSERT( keybits = 64 );
 			InitKey^( src, keybits );
 			InitKey^( src, keybits );
-			
+
 			X := U.SetFromBufferBE( src, 0 );  Y := U.SetFromBufferBE( src, 4 );
 			X := U.SetFromBufferBE( src, 0 );  Y := U.SetFromBufferBE( src, 4 );
-			
+
 			ComputeSubkeys( X, Y, ske, 0 );
 			ComputeSubkeys( X, Y, ske, 0 );
-			
-			FOR i := 0 TO 31 BY 2 DO  
-				skd[i] := ske[30 - i];  
+
+			FOR i := 0 TO 31 BY 2 DO
+				skd[i] := ske[30 - i];
 				skd[i + 1] := ske[31 - i]
 				skd[i + 1] := ske[31 - i]
 			END;
 			END;
 		END InitKey;
 		END InitKey;
-		
-		
+
+
 		PROCEDURE SetIV*( CONST src: ARRAY OF CHAR; mode: SHORTINT );
 		PROCEDURE SetIV*( CONST src: ARRAY OF CHAR; mode: SHORTINT );
 		BEGIN
 		BEGIN
 			SetIV^( src, mode );   (* set mode *)
 			SetIV^( src, mode );   (* set mode *)
 			ivx := U.SetFromBufferBE( src, 0 );  ivy := U.SetFromBufferBE( src, 4 )
 			ivx := U.SetFromBufferBE( src, 0 );  ivy := U.SetFromBufferBE( src, 4 )
 		END SetIV;
 		END SetIV;
-		
-		
+
+
 		PROCEDURE  Encrypt* ( VAR buf: ARRAY OF CHAR; ofs, len: LONGINT );
 		PROCEDURE  Encrypt* ( VAR buf: ARRAY OF CHAR; ofs, len: LONGINT );
 		VAR i, r: LONGINT;   X, Y: SET32;
 		VAR i, r: LONGINT;   X, Y: SET32;
 		BEGIN
 		BEGIN
@@ -60,19 +60,19 @@ TYPE
 			WHILE i < len DO
 			WHILE i < len DO
 				X := U.SetFromBufferBE( buf, ofs + i );  Y := U.SetFromBufferBE( buf, ofs + i + 4 );
 				X := U.SetFromBufferBE( buf, ofs + i );  Y := U.SetFromBufferBE( buf, ofs + i + 4 );
 				IF mode = Ciphers.CBC THEN  X := X / ivx;  Y := Y / ivy   END;
 				IF mode = Ciphers.CBC THEN  X := X / ivx;  Y := Y / ivy   END;
-				IP( X, Y );  
+				IP( X, Y );
 				ki := 0;
 				ki := 0;
-				FOR r := 0 TO 7 DO  
+				FOR r := 0 TO 7 DO
 					RoundE( Y, X );  RoundE( X, Y );
 					RoundE( Y, X );  RoundE( X, Y );
 				END;
 				END;
 				FP( Y, X );
 				FP( Y, X );
-				U.SetToBufferBE( Y, buf, ofs + i );   U.SetToBufferBE( X, buf, ofs + i + 4); 
+				U.SetToBufferBE( Y, buf, ofs + i );   U.SetToBufferBE( X, buf, ofs + i + 4);
 				IF mode = Ciphers.CBC THEN  ivx := Y;  ivy := X  END;
 				IF mode = Ciphers.CBC THEN  ivx := Y;  ivy := X  END;
 				INC( i, blockSize )
 				INC( i, blockSize )
 			END
 			END
-		END Encrypt;	
-		
-		
+		END Encrypt;
+
+
 		PROCEDURE  Decrypt* ( VAR buf: ARRAY OF CHAR; ofs, len: LONGINT );
 		PROCEDURE  Decrypt* ( VAR buf: ARRAY OF CHAR; ofs, len: LONGINT );
 		VAR i, r: LONGINT;  X, Y: SET32;  X0, Y0: SET32;
 		VAR i, r: LONGINT;  X, Y: SET32;  X0, Y0: SET32;
 		BEGIN
 		BEGIN
@@ -82,22 +82,22 @@ TYPE
 			WHILE i < len DO
 			WHILE i < len DO
 				X := U.SetFromBufferBE( buf, ofs + i );  Y := U.SetFromBufferBE( buf, ofs + i + 4 );
 				X := U.SetFromBufferBE( buf, ofs + i );  Y := U.SetFromBufferBE( buf, ofs + i + 4 );
 				IF mode = Ciphers.CBC THEN  X0 := X;  Y0 := Y  END;
 				IF mode = Ciphers.CBC THEN  X0 := X;  Y0 := Y  END;
-				IP( X, Y );  
+				IP( X, Y );
 				ki := 0;
 				ki := 0;
-				FOR r := 0 TO 7 DO  
+				FOR r := 0 TO 7 DO
 					RoundD( Y, X );  RoundD( X, Y );
 					RoundD( Y, X );  RoundD( X, Y );
 				END;
 				END;
 				FP( Y, X );
 				FP( Y, X );
-				IF mode = Ciphers.CBC THEN  
-					Y := Y / ivx;  X := X / ivy  ; 
-					ivx := X0;  ivy := Y0  
+				IF mode = Ciphers.CBC THEN
+					Y := Y / ivx;  X := X / ivy  ;
+					ivx := X0;  ivy := Y0
 				END;
 				END;
-				U.SetToBufferBE( Y, buf, ofs + i );   U.SetToBufferBE( X, buf, ofs + i + 4); 
+				U.SetToBufferBE( Y, buf, ofs + i );   U.SetToBufferBE( X, buf, ofs + i + 4);
 				INC( i, blockSize )
 				INC( i, blockSize )
 			END
 			END
 		END Decrypt;
 		END Decrypt;
-		
-				
+
+
 		PROCEDURE RoundE*( VAR x, y: SET32 );
 		PROCEDURE RoundE*( VAR x, y: SET32 );
 		VAR i: Ind4;
 		VAR i: Ind4;
 		BEGIN
 		BEGIN
@@ -106,7 +106,7 @@ TYPE
 			Split( ske[ki] / ROT( x, -4 ), i );  INC( ki );
 			Split( ske[ki] / ROT( x, -4 ), i );  INC( ki );
 			y := y / sb7[i.a] / sb5[i.b] / sb3[i.c] / sb1[i.d]
 			y := y / sb7[i.a] / sb5[i.b] / sb3[i.c] / sb1[i.d]
 		END RoundE;
 		END RoundE;
-		
+
 		PROCEDURE RoundD*( VAR x, y: SET32 );
 		PROCEDURE RoundD*( VAR x, y: SET32 );
 		VAR i: Ind4;
 		VAR i: Ind4;
 		BEGIN
 		BEGIN
@@ -115,32 +115,32 @@ TYPE
 			Split( skd[ki] / ROT( x, -4 ), i );  INC( ki );
 			Split( skd[ki] / ROT( x, -4 ), i );  INC( ki );
 			y := y / sb7[i.a] / sb5[i.b] / sb3[i.c] / sb1[i.d]
 			y := y / sb7[i.a] / sb5[i.b] / sb3[i.c] / sb1[i.d]
 		END RoundD;
 		END RoundD;
-		
-		
+
+
 		PROCEDURE & Init*;
 		PROCEDURE & Init*;
 		BEGIN
 		BEGIN
 			SetNameAndBlocksize( "des", 8 );
 			SetNameAndBlocksize( "des", 8 );
 		END Init;
 		END Init;
-	
+
 	END Cipher;
 	END Cipher;
-	
+
 	PROCEDURE -Split*( x: SET32; VAR i4: Ind4 );
 	PROCEDURE -Split*( x: SET32; VAR i4: Ind4 );
 	BEGIN
 	BEGIN
 		i4.a := S.VAL( LONGINT, x ) MOD 40H;
 		i4.a := S.VAL( LONGINT, x ) MOD 40H;
 		i4.b := S.VAL( LONGINT, x ) DIV 100H MOD 40H;
 		i4.b := S.VAL( LONGINT, x ) DIV 100H MOD 40H;
 		i4.c := S.VAL( LONGINT, x ) DIV 10000H MOD 40H;
 		i4.c := S.VAL( LONGINT, x ) DIV 10000H MOD 40H;
 		i4.d := S.VAL( LONGINT, x ) DIV 1000000H MOD 40H
 		i4.d := S.VAL( LONGINT, x ) DIV 1000000H MOD 40H
-	END Split; 
-	
-	
+	END Split;
+
+
 	PROCEDURE NewCipher*( ): Ciphers.Cipher;
 	PROCEDURE NewCipher*( ): Ciphers.Cipher;
 	VAR cipher: Cipher;
 	VAR cipher: Cipher;
 	BEGIN
 	BEGIN
 		NEW( cipher );  RETURN cipher
 		NEW( cipher );  RETURN cipher
 	END NewCipher;
 	END NewCipher;
-	
-	
-			
+
+
+
 	PROCEDURE IP*( VAR x, y: SET32 );	(* initial permutation *)
 	PROCEDURE IP*( VAR x, y: SET32 );	(* initial permutation *)
 	VAR t: SET32;
 	VAR t: SET32;
 	BEGIN
 	BEGIN
@@ -149,10 +149,10 @@ TYPE
 		t := (LSH( y,   -2 ) / x) * Mask02;	 x := x / t;  y := y / LSH( t, 2 );
 		t := (LSH( y,   -2 ) / x) * Mask02;	 x := x / t;  y := y / LSH( t, 2 );
 		t := (LSH( y,   -8 ) / x) * Mask08;	 x := x / t;  y := y / LSH( t, 8 );
 		t := (LSH( y,   -8 ) / x) * Mask08;	 x := x / t;  y := y / LSH( t, 8 );
 		y := ROT( y, 1 );
 		y := ROT( y, 1 );
-		t := (x / y) * Mask01;  y := y / t;  x := x / t; 
-		x := ROT( x, 1 );			
+		t := (x / y) * Mask01;  y := y / t;  x := x / t;
+		x := ROT( x, 1 );
 	END IP;
 	END IP;
-		
+
 	PROCEDURE FP*( VAR x, y: SET32 );	(* final permutation *)
 	PROCEDURE FP*( VAR x, y: SET32 );	(* final permutation *)
 	VAR t: SET32;
 	VAR t: SET32;
 	BEGIN
 	BEGIN
@@ -164,32 +164,32 @@ TYPE
 		t := (LSH( x, -16 ) / y) * Mask16;	 y := y / t;  x := x / LSH( t, 16 );
 		t := (LSH( x, -16 ) / y) * Mask16;	 y := y / t;  x := x / LSH( t, 16 );
 		t := (LSH( x,   -4 ) / y) * Mask04;	 y := y / t;  x := x / LSH( t, 4 );
 		t := (LSH( x,   -4 ) / y) * Mask04;	 y := y / t;  x := x / LSH( t, 4 );
 	END FP;
 	END FP;
-	
-	
-	
+
+
+
 	PROCEDURE ComputeSubkeys*( x, y: SET32;  VAR sk: ARRAY OF SET32; ofs: LONGINT );
 	PROCEDURE ComputeSubkeys*( x, y: SET32;  VAR sk: ARRAY OF SET32; ofs: LONGINT );
 	VAR t: SET32; i: LONGINT;
 	VAR t: SET32; i: LONGINT;
-		
+
 		PROCEDURE sms( CONST LRHs: BitSwap;  x: SET32; rs, ls: LONGINT ): SET32;
 		PROCEDURE sms( CONST LRHs: BitSwap;  x: SET32; rs, ls: LONGINT ): SET32;
 		VAR i: LONGINT;
 		VAR i: LONGINT;
 		BEGIN
 		BEGIN
 			i := S.VAL( LONGINT, LSH( x, -rs ) ) MOD 16;
 			i := S.VAL( LONGINT, LSH( x, -rs ) ) MOD 16;
-			RETURN LSH( LRHs[i], ls ) 
+			RETURN LSH( LRHs[i], ls )
 		END sms;
 		END sms;
-			
+
 		PROCEDURE sm( b: SET32; shift, mask: LONGINT ): SET32;
 		PROCEDURE sm( b: SET32; shift, mask: LONGINT ): SET32;
 		BEGIN
 		BEGIN
 			RETURN LSH( b, shift ) * S.VAL( SET32,  mask )
 			RETURN LSH( b, shift ) * S.VAL( SET32,  mask )
 		END sm;
 		END sm;
-		
+
 	BEGIN
 	BEGIN
-		t := (LSH( y, -4 ) / x) * S.VAL( SET32, 0F0F0F0FH );  x := x / t;  y := y / LSH( t, 4 );		
+		t := (LSH( y, -4 ) / x) * S.VAL( SET32, 0F0F0F0FH );  x := x / t;  y := y / LSH( t, 4 );
 		t := (y / x) * S.VAL( SET32, 10101010H ); x := x / t;  y := y / t;
 		t := (y / x) * S.VAL( SET32, 10101010H ); x := x / t;  y := y / t;
-			
-		x := 
+
+		x :=
 			sms( LHs, x, 0, 3 ) + sms( LHs, x, 8, 2 ) + sms( LHs, x, 16, 1 ) + sms( LHs, x, 24, 0 ) +
 			sms( LHs, x, 0, 3 ) + sms( LHs, x, 8, 2 ) + sms( LHs, x, 16, 1 ) + sms( LHs, x, 24, 0 ) +
 			sms( LHs, x, 5, 7 ) + sms( LHs, x, 13, 6 ) + sms( LHs, x, 21, 5 ) + sms( LHs, x, 29, 4 );
 			sms( LHs, x, 5, 7 ) + sms( LHs, x, 13, 6 ) + sms( LHs, x, 21, 5 ) + sms( LHs, x, 29, 4 );
-		y :=	
+		y :=
 			sms( RHs, y, 1, 3 ) + sms( RHs, y, 9, 2 ) + sms( RHs, y, 17, 1 ) + sms( RHs, y, 25, 0 ) +
 			sms( RHs, y, 1, 3 ) + sms( RHs, y, 9, 2 ) + sms( RHs, y, 17, 1 ) + sms( RHs, y, 25, 0 ) +
 			sms( RHs, y, 4, 7 ) + sms( RHs, y, 12, 6 ) + sms( RHs, y, 20, 5 ) + sms( RHs, y, 28, 4 );
 			sms( RHs, y, 4, 7 ) + sms( RHs, y, 12, 6 ) + sms( RHs, y, 20, 5 ) + sms( RHs, y, 28, 4 );
 
 
@@ -199,8 +199,8 @@ TYPE
 			ELSE
 			ELSE
 				x := LSH( x, 2 ) + LSH( x, -26 );  y := LSH( y, 2 ) + LSH( y, -26 )
 				x := LSH( x, 2 ) + LSH( x, -26 );  y := LSH( y, 2 ) + LSH( y, -26 )
 			END;
 			END;
-					
-			sk[ofs + 2*i] :=	
+
+			sk[ofs + 2*i] :=
 					sm( x, 4,		24000000H ) + sm( x, 28,	10000000H ) +
 					sm( x, 4,		24000000H ) + sm( x, 28,	10000000H ) +
 					sm( x, 14, 	08000000H ) + sm( x, 18,	02080000H ) +
 					sm( x, 14, 	08000000H ) + sm( x, 18,	02080000H ) +
 					sm( x, 6,		01000000H ) + sm( x, 9,		00200000H ) +
 					sm( x, 6,		01000000H ) + sm( x, 9,		00200000H ) +
@@ -213,7 +213,7 @@ TYPE
 					sm( y, -3,		00000008H ) + sm( y, -18,	00000004H ) +
 					sm( y, -3,		00000008H ) + sm( y, -18,	00000004H ) +
 					sm( y, -26,	00000002H ) + sm( y, -24,	00000001H );
 					sm( y, -26,	00000002H ) + sm( y, -24,	00000001H );
 
 
-	        	sk[ofs + 2*i + 1] :=   
+	        	sk[ofs + 2*i + 1] :=
 	        			sm( x, 15,		20000000H ) + sm( x, 17,	10000000H ) +
 	        			sm( x, 15,		20000000H ) + sm( x, 17,	10000000H ) +
 					sm( x, 10,		08000000H ) + sm( x, 22,	04000000H ) +
 					sm( x, 10,		08000000H ) + sm( x, 22,	04000000H ) +
 					sm( x, -2,		02000000H ) + sm( x, 1,		01000000H ) +
 					sm( x, -2,		02000000H ) + sm( x, 1,		01000000H ) +
@@ -228,18 +228,18 @@ TYPE
 		END
 		END
 	END ComputeSubkeys;
 	END ComputeSubkeys;
 
 
-	
+
 	PROCEDURE InitializeSandboxes;
 	PROCEDURE InitializeSandboxes;
-	VAR 
+	VAR
 		buf: U.InitBuffer;
 		buf: U.InitBuffer;
-		
-	
+
+
 		PROCEDURE InitTable( VAR tab: ARRAY OF SET32 );
 		PROCEDURE InitTable( VAR tab: ARRAY OF SET32 );
-		VAR i: LONGINT; 
+		VAR i: LONGINT;
 		BEGIN
 		BEGIN
 			FOR i := 0 TO LEN( tab ) - 1 DO  tab[i] := buf.GetSet( )  END
 			FOR i := 0 TO LEN( tab ) - 1 DO  tab[i] := buf.GetSet( )  END
 		END InitTable;
 		END InitTable;
-	
+
 	BEGIN
 	BEGIN
 		NEW( buf, 1024 );
 		NEW( buf, 1024 );
 		buf.Add( "01010400 00000000 00010000 01010404 01010004 00010404 00000004 00010000 " );
 		buf.Add( "01010400 00000000 00010000 01010404 01010004 00010404 00000004 00010000 " );
@@ -284,7 +284,7 @@ TYPE
 		buf.Add( "00802081 00000081 00000001 00002000 00800001 00002001 00802080 00800081 " );
 		buf.Add( "00802081 00000081 00000001 00002000 00800001 00002001 00802080 00800081 " );
 		buf.Add( "00002001 00002080 00800000 00802001 00000080 00800000 00002000 00802080 " );
 		buf.Add( "00002001 00002080 00800000 00802001 00000080 00800000 00002000 00802080 " );
 		InitTable( sb4 );
 		InitTable( sb4 );
-	    
+
 		buf.Init( 1024 );
 		buf.Init( 1024 );
 		buf.Add( "00000100 02080100 02080000 42000100 00080000 00000100 40000000 02080000 " );
 		buf.Add( "00000100 02080100 02080000 42000100 00080000 00000100 40000000 02080000 " );
 		buf.Add( "40080100 00080000 02000100 40080100 42000100 42080000 00080100 40000000 " );
 		buf.Add( "40080100 00080000 02000100 40080100 42000100 42080000 00080100 40000000 " );
@@ -328,17 +328,17 @@ TYPE
 		buf.Add( "00000000 10041040 00040040 10000040 10040000 10001000 10001040 00000000 " );
 		buf.Add( "00000000 10041040 00040040 10000040 10040000 10001000 10001040 00000000 " );
 		buf.Add( "10041040 00041000 00041000 00001040 00001040 00040040 10000000 10041000 " );
 		buf.Add( "10041040 00041000 00041000 00001040 00001040 00040040 10000000 10041000 " );
 		InitTable( sb8 );
 		InitTable( sb8 );
-		
+
 		buf.Init( 512 );
 		buf.Init( 512 );
 		buf.Add( "00000000 00000001 00000100 00000101 00010000 00010001 00010100 00010101 " );
 		buf.Add( "00000000 00000001 00000100 00000101 00010000 00010001 00010100 00010101 " );
 		buf.Add( "01000000 01000001 01000100 01000101 01010000 01010001 01010100 01010101 " );
 		buf.Add( "01000000 01000001 01000100 01000101 01010000 01010001 01010100 01010101 " );
 		InitTable( LHs );
 		InitTable( LHs );
-		
+
 		buf.Init( 512 );
 		buf.Init( 512 );
 		buf.Add( "00000000 01000000 00010000 01010000 00000100 01000100 00010100 01010100 " );
 		buf.Add( "00000000 01000000 00010000 01010000 00000100 01000100 00010100 01010100 " );
 		buf.Add( "00000001 01000001 00010001 01010001 00000101 01000101 00010101 01010101 " );
 		buf.Add( "00000001 01000001 00010001 01010001 00000101 01000101 00010101 01010101 " );
 		InitTable( RHs );
 		InitTable( RHs );
-				
+
 	END InitializeSandboxes;
 	END InitializeSandboxes;
 
 
 BEGIN
 BEGIN

+ 26 - 26
source/CryptoDES3.Mod

@@ -5,11 +5,11 @@ MODULE CryptoDES3;   (** AUTHOR "G.F."; PUROSE "Triple DES Cipher";	 *)
 
 
 IMPORT Ciphers := CryptoCiphers, U := CryptoUtils, D := CryptoDES;
 IMPORT Ciphers := CryptoCiphers, U := CryptoUtils, D := CryptoDES;
 
 
-	
-	
+
+
 TYPE
 TYPE
 	Cipher* = OBJECT (Ciphers.Cipher)
 	Cipher* = OBJECT (Ciphers.Cipher)
-			VAR 
+			VAR
 				ske, skd: ARRAY 96 OF SET32; ski: LONGINT;
 				ske, skd: ARRAY 96 OF SET32; ski: LONGINT;
 				ivx, ivy: SET32;
 				ivx, ivy: SET32;
 
 
@@ -18,23 +18,23 @@ TYPE
 				BEGIN
 				BEGIN
 					ASSERT( keybits = 192 );
 					ASSERT( keybits = 192 );
 					InitKey^( src, 64 );
 					InitKey^( src, 64 );
-					
+
 					X := U.SetFromBufferBE( src, 0 );  Y := U.SetFromBufferBE( src, 4 );
 					X := U.SetFromBufferBE( src, 0 );  Y := U.SetFromBufferBE( src, 4 );
 					D.ComputeSubkeys( X, Y, ske, 0 );
 					D.ComputeSubkeys( X, Y, ske, 0 );
-					
+
 					X := U.SetFromBufferBE( src, 8 );  Y := U.SetFromBufferBE( src, 12 );
 					X := U.SetFromBufferBE( src, 8 );  Y := U.SetFromBufferBE( src, 12 );
 					D.ComputeSubkeys( X, Y, skd, 32 );
 					D.ComputeSubkeys( X, Y, skd, 32 );
-					
+
 					X := U.SetFromBufferBE( src, 16);  Y := U.SetFromBufferBE( src, 20 );
 					X := U.SetFromBufferBE( src, 16);  Y := U.SetFromBufferBE( src, 20 );
 					D.ComputeSubkeys( X, Y, ske, 64 );
 					D.ComputeSubkeys( X, Y, ske, 64 );
-					
+
 					FOR i := 0 TO 30 BY 2 DO
 					FOR i := 0 TO 30 BY 2 DO
 						skd[i + 0] := ske[94 - i];
 						skd[i + 0] := ske[94 - i];
 						skd[i + 1] := ske[95 - i];
 						skd[i + 1] := ske[95 - i];
-						
+
 						ske[i + 32] := skd[62 - i];
 						ske[i + 32] := skd[62 - i];
 						ske[i + 33] := skd[63 - i];
 						ske[i + 33] := skd[63 - i];
-						
+
 						skd[i + 64] := ske[30 - i];
 						skd[i + 64] := ske[30 - i];
 						skd[i + 65] := ske[31 - i]
 						skd[i + 65] := ske[31 - i]
 					END
 					END
@@ -58,18 +58,18 @@ TYPE
 
 
 						D.IP( X, Y );
 						D.IP( X, Y );
 						ski := 0;
 						ski := 0;
-						FOR r := 0 TO 7 DO  
+						FOR r := 0 TO 7 DO
 							RoundE( Y, X );  RoundE( X, Y );
 							RoundE( Y, X );  RoundE( X, Y );
 						END;
 						END;
-						FOR r := 0 TO 7 DO  
+						FOR r := 0 TO 7 DO
 							RoundE( X, Y );  RoundE( Y, X );
 							RoundE( X, Y );  RoundE( Y, X );
 						END;
 						END;
-						FOR r := 0 TO 7 DO  
+						FOR r := 0 TO 7 DO
 							RoundE( Y, X );  RoundE( X, Y );
 							RoundE( Y, X );  RoundE( X, Y );
 						END;
 						END;
 						D.FP( Y, X );
 						D.FP( Y, X );
-						
-						U.SetToBufferBE( Y, buf, ofs + i );   U.SetToBufferBE( X, buf, ofs + i + 4); 
+
+						U.SetToBufferBE( Y, buf, ofs + i );   U.SetToBufferBE( X, buf, ofs + i + 4);
 						IF mode = Ciphers.CBC THEN  ivx := Y;  ivy := X  END;
 						IF mode = Ciphers.CBC THEN  ivx := Y;  ivy := X  END;
 						INC( i, blockSize )
 						INC( i, blockSize )
 					END
 					END
@@ -84,30 +84,30 @@ TYPE
 					WHILE i < len DO
 					WHILE i < len DO
 						X := U.SetFromBufferBE( buf, ofs + i );  Y := U.SetFromBufferBE( buf, ofs + i + 4 );
 						X := U.SetFromBufferBE( buf, ofs + i );  Y := U.SetFromBufferBE( buf, ofs + i + 4 );
 						IF mode = Ciphers.CBC THEN  X0 := X;  Y0 := Y  END;
 						IF mode = Ciphers.CBC THEN  X0 := X;  Y0 := Y  END;
-						
+
 						D.IP( X, Y );
 						D.IP( X, Y );
 						ski := 0;
 						ski := 0;
-						FOR r := 0 TO 7 DO  
+						FOR r := 0 TO 7 DO
 							RoundD( Y, X );  RoundD( X, Y );
 							RoundD( Y, X );  RoundD( X, Y );
 						END;
 						END;
-						FOR r := 0 TO 7 DO  
+						FOR r := 0 TO 7 DO
 							RoundD( X, Y );  RoundD( Y, X );
 							RoundD( X, Y );  RoundD( Y, X );
 						END;
 						END;
-						FOR r := 0 TO 7 DO  
+						FOR r := 0 TO 7 DO
 							RoundD( Y, X );  RoundD( X, Y );
 							RoundD( Y, X );  RoundD( X, Y );
 						END;
 						END;
 						D.FP( Y, X );
 						D.FP( Y, X );
-						
-						IF mode = Ciphers.CBC THEN  
-							Y := Y / ivx;  X := X / ivy  ; 
-							ivx := X0;  ivy := Y0  
+
+						IF mode = Ciphers.CBC THEN
+							Y := Y / ivx;  X := X / ivy  ;
+							ivx := X0;  ivy := Y0
 						END;
 						END;
-						U.SetToBufferBE( Y, buf, ofs + i );   U.SetToBufferBE( X, buf, ofs + i + 4); 
+						U.SetToBufferBE( Y, buf, ofs + i );   U.SetToBufferBE( X, buf, ofs + i + 4);
 						INC( i, blockSize )
 						INC( i, blockSize )
 					END
 					END
 				END Decrypt;
 				END Decrypt;
 
 
-				
+
 				PROCEDURE RoundE*( VAR x, y: SET32 );
 				PROCEDURE RoundE*( VAR x, y: SET32 );
 				VAR i: D.Ind4;
 				VAR i: D.Ind4;
 				BEGIN
 				BEGIN
@@ -116,7 +116,7 @@ TYPE
 					D.Split( ske[ski] / ROT( x, -4 ), i );  INC( ski );
 					D.Split( ske[ski] / ROT( x, -4 ), i );  INC( ski );
 					y := y / D.sb7[i.a] / D.sb5[i.b] / D.sb3[i.c] / D.sb1[i.d]
 					y := y / D.sb7[i.a] / D.sb5[i.b] / D.sb3[i.c] / D.sb1[i.d]
 				END RoundE;
 				END RoundE;
-				
+
 				PROCEDURE RoundD*( VAR x, y: SET32 );
 				PROCEDURE RoundD*( VAR x, y: SET32 );
 				VAR i: D.Ind4;
 				VAR i: D.Ind4;
 				BEGIN
 				BEGIN
@@ -132,7 +132,7 @@ TYPE
 				END Init;
 				END Init;
 
 
 			END Cipher;
 			END Cipher;
-			
+
 
 
 
 
 	PROCEDURE NewCipher*( ): Ciphers.Cipher;
 	PROCEDURE NewCipher*( ): Ciphers.Cipher;

+ 3 - 3
source/CryptoDiffieHellman.Mod

@@ -50,14 +50,14 @@ TYPE
 
 
 
 
 	PROCEDURE GetDHPrime( CONST name: ARRAY OF CHAR;  VAR p, g: B.BigNumber );
 	PROCEDURE GetDHPrime( CONST name: ARRAY OF CHAR;  VAR p, g: B.BigNumber );
-	VAR 
-		buf: ARRAY 1048 OF CHAR; 
+	VAR
+		buf: ARRAY 1048 OF CHAR;
 		pos: LONGINT;
 		pos: LONGINT;
 
 
 		PROCEDURE Append( CONST val: ARRAY OF CHAR );
 		PROCEDURE Append( CONST val: ARRAY OF CHAR );
 		VAR i: LONGINT;  c: CHAR;
 		VAR i: LONGINT;  c: CHAR;
 		BEGIN
 		BEGIN
-			FOR i := 0 TO LEN( val ) - 1 DO  
+			FOR i := 0 TO LEN( val ) - 1 DO
 				c := val[i];
 				c := val[i];
 				IF c > ' ' THEN  buf[pos] := c;  INC( pos )  END
 				IF c > ' ' THEN  buf[pos] := c;  INC( pos )  END
 			END;
 			END;

+ 40 - 40
source/CryptoKeccakF1600.Mod

@@ -10,19 +10,19 @@ IMPORT S := SYSTEM;
 CONST
 CONST
 	Width* = 1600;			(* state size in bits *)
 	Width* = 1600;			(* state size in bits *)
 	LaneSize* = 8;			(* lane size in bytes *)
 	LaneSize* = 8;			(* lane size in bytes *)
-	
-CONST 
+
+CONST
 	nrRounds = 24;  nrLanes = 25;
 	nrRounds = 24;  nrLanes = 25;
-	
+
 TYPE
 TYPE
 	Lane = RECORD  low, high: SET32  END;
 	Lane = RECORD  low, high: SET32  END;
 	State = ARRAY nrLanes OF Lane;
 	State = ARRAY nrLanes OF Lane;
 
 
-VAR 
+VAR
 	roundConstants: ARRAY nrRounds OF Lane;
 	roundConstants: ARRAY nrRounds OF Lane;
 	rhoOffsets: ARRAY nrLanes OF LONGINT;
 	rhoOffsets: ARRAY nrLanes OF LONGINT;
-	
-TYPE 
+
+TYPE
 	Instance* = OBJECT
 	Instance* = OBJECT
 	VAR
 	VAR
 		state: State;
 		state: State;
@@ -32,7 +32,7 @@ TYPE
 		BEGIN
 		BEGIN
 			Initialize
 			Initialize
 		END Init;
 		END Init;
-		
+
 		PROCEDURE Initialize*;
 		PROCEDURE Initialize*;
 		VAR i: LONGINT;
 		VAR i: LONGINT;
 		BEGIN
 		BEGIN
@@ -47,9 +47,9 @@ TYPE
 			ASSERT( (laneNo < nrLanes) & (laneOffset < LaneSize) & (laneOffset+length <= LaneSize) );
 			ASSERT( (laneNo < nrLanes) & (laneOffset < LaneSize) & (laneOffset+length <= LaneSize) );
 			lane.low := {};  lane.high := {};
 			lane.low := {};  lane.high := {};
 			S.MOVE( ADDRESSOF( data[dataOffset] ), ADDRESSOF( lane ) + laneOffset, length );
 			S.MOVE( ADDRESSOF( data[dataOffset] ), ADDRESSOF( lane ) + laneOffset, length );
-			
+
 			ToBitInterleaving( lane, lane );
 			ToBitInterleaving( lane, lane );
-			
+
 			state[laneNo].low := state[laneNo].low / lane.low;
 			state[laneNo].low := state[laneNo].low / lane.low;
 			state[laneNo].high := state[laneNo].high / lane.high;
 			state[laneNo].high := state[laneNo].high / lane.high;
 		END XORBytesInLane;
 		END XORBytesInLane;
@@ -62,9 +62,9 @@ TYPE
 			ASSERT( laneCount <= nrLanes );
 			ASSERT( laneCount <= nrLanes );
 			FOR laneNo := 0 TO laneCount - 1 DO
 			FOR laneNo := 0 TO laneCount - 1 DO
 				S.MOVE( ADDRESSOF( data[offset + laneNo*LaneSize] ), ADDRESSOF( lane ), LaneSize );
 				S.MOVE( ADDRESSOF( data[offset + laneNo*LaneSize] ), ADDRESSOF( lane ), LaneSize );
-				
+
 				ToBitInterleaving( lane, lane );
 				ToBitInterleaving( lane, lane );
-				
+
 				state[laneNo].low := state[laneNo].low / lane.low;
 				state[laneNo].low := state[laneNo].low / lane.low;
 				state[laneNo].high := state[laneNo].high / lane.high;
 				state[laneNo].high := state[laneNo].high / lane.high;
 			END
 			END
@@ -76,7 +76,7 @@ TYPE
 			laneNo, bit: LONGINT;
 			laneNo, bit: LONGINT;
 		BEGIN
 		BEGIN
 			ASSERT( position < 1600 );
 			ASSERT( position < 1600 );
-			laneNo := position DIV 64;  bit := position MOD 64; 
+			laneNo := position DIV 64;  bit := position MOD 64;
 			IF bit < 32 THEN
 			IF bit < 32 THEN
 				state[laneNo].low := SET32( state[laneNo].low / {bit} )
 				state[laneNo].low := SET32( state[laneNo].low / {bit} )
 			ELSE
 			ELSE
@@ -96,7 +96,7 @@ TYPE
 
 
 
 
 		PROCEDURE ExtractLanes*( VAR data: ARRAY OF CHAR; offset, laneCount: LONGINT );
 		PROCEDURE ExtractLanes*( VAR data: ARRAY OF CHAR; offset, laneCount: LONGINT );
-		VAR 
+		VAR
 			lane: Lane;  laneNo: LONGINT;
 			lane: Lane;  laneNo: LONGINT;
 		BEGIN
 		BEGIN
 			ASSERT( laneCount <= nrLanes );
 			ASSERT( laneCount <= nrLanes );
@@ -111,9 +111,9 @@ TYPE
 			XORLanes( inData, offset, count );
 			XORLanes( inData, offset, count );
 			Permute;
 			Permute;
 		END XORPermute;
 		END XORPermute;
-		
-		
-		PROCEDURE XORPermuteExtract*(	CONST inData: ARRAY OF CHAR; inOffset, inLaneCount: LONGINT; 
+
+
+		PROCEDURE XORPermuteExtract*(	CONST inData: ARRAY OF CHAR; inOffset, inLaneCount: LONGINT;
 												VAR outData: ARRAY OF CHAR; outOffset, outLaneCount: LONGINT );
 												VAR outData: ARRAY OF CHAR; outOffset, outLaneCount: LONGINT );
 		BEGIN
 		BEGIN
 			XORLanes( inData, inOffset, inLaneCount );
 			XORLanes( inData, inOffset, inLaneCount );
@@ -145,7 +145,7 @@ TYPE
 	        temp := (temp0 / LSH( temp0, -2 )) * S.VAL( SET32, 00C0C0C0CH );  temp0 := temp0 / temp / LSH( temp, 2 );
 	        temp := (temp0 / LSH( temp0, -2 )) * S.VAL( SET32, 00C0C0C0CH );  temp0 := temp0 / temp / LSH( temp, 2 );
 	        temp := (temp0 / LSH( temp0, -4 )) * S.VAL( SET32, 000F000F0H );  temp0 := temp0 / temp / LSH( temp, 4 );
 	        temp := (temp0 / LSH( temp0, -4 )) * S.VAL( SET32, 000F000F0H );  temp0 := temp0 / temp / LSH( temp, 4 );
 	        temp := (temp0 / LSH( temp0, -8 )) * S.VAL( SET32, 00000FF00H );  temp0 := temp0 / temp / LSH( temp, 8 );
 	        temp := (temp0 / LSH( temp0, -8 )) * S.VAL( SET32, 00000FF00H );  temp0 := temp0 / temp / LSH( temp, 8 );
-	        
+
 	        temp := (temp1 / LSH( temp1, -1 )) * S.VAL( SET32, 022222222H );  temp1 := temp1 / temp / LSH( temp, 1 );
 	        temp := (temp1 / LSH( temp1, -1 )) * S.VAL( SET32, 022222222H );  temp1 := temp1 / temp / LSH( temp, 1 );
 	        temp := (temp1 / LSH( temp1, -2 )) * S.VAL( SET32, 00C0C0C0CH );  temp1 := temp1 / temp / LSH( temp, 2 );
 	        temp := (temp1 / LSH( temp1, -2 )) * S.VAL( SET32, 00C0C0C0CH );  temp1 := temp1 / temp / LSH( temp, 2 );
 	        temp := (temp1 / LSH( temp1, -4 )) * S.VAL( SET32, 000F000F0H );  temp1 := temp1 / temp / LSH( temp, 4 );
 	        temp := (temp1 / LSH( temp1, -4 )) * S.VAL( SET32, 000F000F0H );  temp1 := temp1 / temp / LSH( temp, 4 );
@@ -158,16 +158,16 @@ TYPE
 	PROCEDURE FromBitInterleaving( CONST in: Lane;  VAR out: Lane );
 	PROCEDURE FromBitInterleaving( CONST in: Lane;  VAR out: Lane );
 	VAR temp, temp0, temp1: SET32;
 	VAR temp, temp0, temp1: SET32;
 	BEGIN
 	BEGIN
-	        temp0 := in.low; 
-	        temp1 := in.high; 
-	        temp := (temp0 * S.VAL( SET32, 00000FFFFH )) + LSH( temp1, 16 ); 
-	        temp1 := LSH( temp0, - 16) + (temp1 * S.VAL( SET32, 0FFFF0000H )); 
-	        temp0 := temp; 
-	        temp := (temp0 / LSH( temp0, -8 )) * S.VAL( SET32, 00000FF00H );  temp0 := temp0 / temp / LSH( temp, 8 ); 
-	        temp := (temp0 / LSH( temp0, -4 )) * S.VAL( SET32, 000F000F0H );  temp0 := temp0 / temp / LSH( temp, 4 ); 
-	        temp := (temp0 / LSH( temp0, -2 )) * S.VAL( SET32, 00C0C0C0CH );  temp0 := temp0 / temp / LSH( temp, 2 ); 
-	        temp := (temp0 / LSH( temp0, -1 )) * S.VAL( SET32, 022222222H );  temp0 := temp0 / temp / LSH( temp, 1 ); 
-	        
+	        temp0 := in.low;
+	        temp1 := in.high;
+	        temp := (temp0 * S.VAL( SET32, 00000FFFFH )) + LSH( temp1, 16 );
+	        temp1 := LSH( temp0, - 16) + (temp1 * S.VAL( SET32, 0FFFF0000H ));
+	        temp0 := temp;
+	        temp := (temp0 / LSH( temp0, -8 )) * S.VAL( SET32, 00000FF00H );  temp0 := temp0 / temp / LSH( temp, 8 );
+	        temp := (temp0 / LSH( temp0, -4 )) * S.VAL( SET32, 000F000F0H );  temp0 := temp0 / temp / LSH( temp, 4 );
+	        temp := (temp0 / LSH( temp0, -2 )) * S.VAL( SET32, 00C0C0C0CH );  temp0 := temp0 / temp / LSH( temp, 2 );
+	        temp := (temp0 / LSH( temp0, -1 )) * S.VAL( SET32, 022222222H );  temp0 := temp0 / temp / LSH( temp, 1 );
+
 	        temp := (temp1 / LSH( temp1, -8 )) * S.VAL( SET32, 00000FF00H );  temp1 := temp1 / temp / LSH( temp, 8 );
 	        temp := (temp1 / LSH( temp1, -8 )) * S.VAL( SET32, 00000FF00H );  temp1 := temp1 / temp / LSH( temp, 8 );
 	        temp := (temp1 / LSH( temp1, -4 )) * S.VAL( SET32, 000F000F0H );  temp1 := temp1 / temp / LSH( temp, 4 );
 	        temp := (temp1 / LSH( temp1, -4 )) * S.VAL( SET32, 000F000F0H );  temp1 := temp1 / temp / LSH( temp, 4 );
 	        temp := (temp1 / LSH( temp1, -2 )) * S.VAL( SET32, 00C0C0C0CH );  temp1 := temp1 / temp / LSH( temp, 2 );
 	        temp := (temp1 / LSH( temp1, -2 )) * S.VAL( SET32, 00C0C0C0CH );  temp1 := temp1 / temp / LSH( temp, 2 );
@@ -190,7 +190,7 @@ TYPE
 			lane.high := ROT( lane.high, offset DIV 2 )
 			lane.high := ROT( lane.high, offset DIV 2 )
 		END;
 		END;
 	END ROL64;
 	END ROL64;
-	
+
 
 
 	PROCEDURE ROL64_1XOR( CONST in1, in2: Lane; VAR out: Lane );
 	PROCEDURE ROL64_1XOR( CONST in1, in2: Lane; VAR out: Lane );
 	BEGIN
 	BEGIN
@@ -202,15 +202,15 @@ TYPE
 	PROCEDURE Round( VAR a: State; r: LONGINT );
 	PROCEDURE Round( VAR a: State; r: LONGINT );
 	VAR
 	VAR
 		x, y, i, i1, i2: LONGINT;
 		x, y, i, i1, i2: LONGINT;
-		c, d: ARRAY 5 OF Lane;  
-		a0: State;  
+		c, d: ARRAY 5 OF Lane;
+		a0: State;
 	BEGIN
 	BEGIN
 		(* theta *)
 		(* theta *)
 		FOR x := 0 TO 4 DO
 		FOR x := 0 TO 4 DO
 			c[x].low := {};  c[x].high := {};
 			c[x].low := {};  c[x].high := {};
 			FOR y := 0 TO 20 BY 5 DO
 			FOR y := 0 TO 20 BY 5 DO
-				c[x].low := c[x].low / a[x+y].low;  
-				c[x].high := c[x].high / a[x+y].high;	
+				c[x].low := c[x].low / a[x+y].low;
+				c[x].high := c[x].high / a[x+y].high;
 			END
 			END
 		END;
 		END;
 		FOR x := 0 TO 4 DO
 		FOR x := 0 TO 4 DO
@@ -219,13 +219,13 @@ TYPE
 		FOR x := 0 TO 4 DO
 		FOR x := 0 TO 4 DO
 			FOR y := 0 TO 4 DO
 			FOR y := 0 TO 4 DO
 				i := x + 5*y;
 				i := x + 5*y;
-				a[i].low := a[i].low / d[x].low;  
-				a[i].high := a[i].high / d[x].high	
+				a[i].low := a[i].low / d[x].low;
+				a[i].high := a[i].high / d[x].high
 			END
 			END
 		END;
 		END;
 		(* rho *)
 		(* rho *)
 		FOR i := 0 TO 24 DO
 		FOR i := 0 TO 24 DO
-			ROL64( a[i], rhoOffsets[i] );	
+			ROL64( a[i], rhoOffsets[i] );
 		END;
 		END;
 		(* pi *)
 		(* pi *)
 		a0 := a;
 		a0 := a;
@@ -247,7 +247,7 @@ TYPE
 			i := 4 + y;  i1 := 0 + y;  i2 := 1 + y;
 			i := 4 + y;  i1 := 0 + y;  i2 := 1 + y;
 			c[4].low := a[i].low / ((-a[i1].low) * a[i2].low);
 			c[4].low := a[i].low / ((-a[i1].low) * a[i2].low);
 			c[4].high := a[i].high / ((-a[i1].high) * a[i2].high);
 			c[4].high := a[i].high / ((-a[i1].high) * a[i2].high);
-			FOR x := 0 TO 4 DO  
+			FOR x := 0 TO 4 DO
 				a[x+y].low := c[x].low;
 				a[x+y].low := c[x].low;
 				a[x+y].high := c[x].high
 				a[x+y].high := c[x].high
 			END
 			END
@@ -256,8 +256,8 @@ TYPE
 		a[0].low := a[0].low / roundConstants[r].low;
 		a[0].low := a[0].low / roundConstants[r].low;
 		a[0].high := a[0].high / roundConstants[r].high;
 		a[0].high := a[0].high / roundConstants[r].high;
 	END Round;
 	END Round;
-	
-	
+
+
 
 
 	(* ---------------------------------------------------------------- *)
 	(* ---------------------------------------------------------------- *)
 
 
@@ -272,7 +272,7 @@ TYPE
 		FOR i := 0 TO nrRounds - 1 DO
 		FOR i := 0 TO nrRounds - 1 DO
 			lane.low := {};  lane.high := {};
 			lane.low := {};  lane.high := {};
 			FOR j := 0 TO 6 DO
 			FOR j := 0 TO 6 DO
-	       		bit := ASH( 1, j ) - 1; 
+	       		bit := ASH( 1, j ) - 1;
 	 			IF LFSR86540( LFSRstate ) THEN
 	 			IF LFSR86540( LFSRstate ) THEN
 	      			IF bit < 32 THEN  INCL( lane.low, bit )  ELSE  INCL( lane.high, bit - 32 )  END
 	      			IF bit < 32 THEN  INCL( lane.low, bit )  ELSE  INCL( lane.high, bit - 32 )  END
 	   			END
 	   			END
@@ -317,4 +317,4 @@ BEGIN
 	InitializeRhoOffsets;
 	InitializeRhoOffsets;
 END CryptoKeccakF1600.
 END CryptoKeccakF1600.
 
 
-	
+

+ 20 - 20
source/CryptoKeccakSponge.Mod

@@ -12,13 +12,13 @@ CONST
 	Width* = Keccak.Width;
 	Width* = Keccak.Width;
 	DefaultRate* = 1024;
 	DefaultRate* = 1024;
 	DefaultCapacity* = 576;
 	DefaultCapacity* = 576;
-	
-TYPE 
-	Instance* = OBJECT 
+
+TYPE
+	Instance* = OBJECT
 	VAR
 	VAR
 		state: Keccak.Instance;	(* The state processed by the permutation. *)
 		state: Keccak.Instance;	(* The state processed by the permutation. *)
 		chunk: LONGINT;		(* The value of the rate in bytes *)
 		chunk: LONGINT;		(* The value of the rate in bytes *)
-		index: LONGINT;			(* The position in the state of the next byte to be 
+		index: LONGINT;			(* The position in the state of the next byte to be
 									input (when absorbing) or output (when squeezing). *)
 									input (when absorbing) or output (when squeezing). *)
 		squeezing: BOOLEAN	;	(* false: in the absorbing phase; otherwise, in the squeezing phase. *)
 		squeezing: BOOLEAN	;	(* false: in the absorbing phase; otherwise, in the squeezing phase. *)
 		cmodl: LONGINT;		(* chunk MOD LaneSize *)
 		cmodl: LONGINT;		(* chunk MOD LaneSize *)
@@ -29,8 +29,8 @@ TYPE
 			NEW( state );
 			NEW( state );
 			Initialize( DefaultRate, DefaultCapacity )
 			Initialize( DefaultRate, DefaultCapacity )
 		END Init;
 		END Init;
-		
-		
+
+
 		PROCEDURE Initialize*( rate, capacity: LONGINT );
 		PROCEDURE Initialize*( rate, capacity: LONGINT );
 		BEGIN
 		BEGIN
 			ASSERT( rate + capacity = Width );
 			ASSERT( rate + capacity = Width );
@@ -42,20 +42,20 @@ TYPE
 			cdivl := chunk DIV LaneSize;
 			cdivl := chunk DIV LaneSize;
 			squeezing := FALSE
 			squeezing := FALSE
 		END Initialize;
 		END Initialize;
-	
-		
+
+
 		PROCEDURE Absorb*( CONST data: ARRAY OF CHAR; offset, len: LONGINT );
 		PROCEDURE Absorb*( CONST data: ARRAY OF CHAR; offset, len: LONGINT );
-		VAR 
+		VAR
 			piece, lanes, laneNo, laneOffset, bytes: LONGINT;
 			piece, lanes, laneNo, laneOffset, bytes: LONGINT;
 		BEGIN
 		BEGIN
-			ASSERT( squeezing = FALSE ); 
+			ASSERT( squeezing = FALSE );
 			WHILE len > 0 DO
 			WHILE len > 0 DO
 				IF (index = 0) & ( len >= chunk) THEN
 				IF (index = 0) & ( len >= chunk) THEN
 					(* fast lane: processing whole blocks first *)
 					(* fast lane: processing whole blocks first *)
 					state.XORLanes( data, offset, cdivl );
 					state.XORLanes( data, offset, cdivl );
 					IF cmodl # 0 THEN  state.XORBytesInLane( cdivl, 0, cmodl, data, offset )  END;
 					IF cmodl # 0 THEN  state.XORBytesInLane( cdivl, 0, cmodl, data, offset )  END;
 					state.Permute;
 					state.Permute;
-					INC( offset, chunk );  DEC( len, chunk );  
+					INC( offset, chunk );  DEC( len, chunk );
 				ELSE
 				ELSE
 					(* normal lane: using the message queue*)
 					(* normal lane: using the message queue*)
 					piece := len;
 					piece := len;
@@ -63,8 +63,8 @@ TYPE
 					IF (index = 0) & (piece >=  LaneSize) THEN
 					IF (index = 0) & (piece >=  LaneSize) THEN
 						lanes := piece DIV LaneSize;  bytes := lanes*LaneSize;
 						lanes := piece DIV LaneSize;  bytes := lanes*LaneSize;
 						state.XORLanes( data, offset, lanes );
 						state.XORLanes( data, offset, lanes );
-						INC( offset, bytes );  DEC( len, bytes );  DEC( piece, bytes ); 
-						INC( index, bytes );   
+						INC( offset, bytes );  DEC( len, bytes );  DEC( piece, bytes );
+						INC( index, bytes );
 					END;
 					END;
 					WHILE piece > 0 DO
 					WHILE piece > 0 DO
 						laneNo := index DIV LaneSize;
 						laneNo := index DIV LaneSize;
@@ -79,9 +79,9 @@ TYPE
 				END
 				END
 			END
 			END
 		END Absorb;
 		END Absorb;
-		
-		
-		
+
+
+
 		PROCEDURE Squeeze*( VAR data: ARRAY OF CHAR;  offset, len: LONGINT );
 		PROCEDURE Squeeze*( VAR data: ARRAY OF CHAR;  offset, len: LONGINT );
 		VAR piece, lanes, laneNo, laneOffset, bytes: LONGINT;
 		VAR piece, lanes, laneNo, laneOffset, bytes: LONGINT;
 		BEGIN
 		BEGIN
@@ -116,11 +116,11 @@ TYPE
 				END
 				END
 			END;
 			END;
 		END Squeeze;
 		END Squeeze;
-		
+
 		PROCEDURE AbsorbLastFewBits*( data: CHAR );
 		PROCEDURE AbsorbLastFewBits*( data: CHAR );
 		VAR tmp: ARRAY 4 OF CHAR;
 		VAR tmp: ARRAY 4 OF CHAR;
 		BEGIN
 		BEGIN
-			ASSERT( (data # 0X) & (squeezing = FALSE) ); 
+			ASSERT( (data # 0X) & (squeezing = FALSE) );
 			tmp[0] := data;
 			tmp[0] := data;
 			state.XORBytesInLane( index DIV LaneSize, index MOD LaneSize, 1, tmp, 0 );
 			state.XORBytesInLane( index DIV LaneSize, index MOD LaneSize, 1, tmp, 0 );
 			IF (data >= 80X) & (index = chunk - 1) THEN  state.Permute  END;
 			IF (data >= 80X) & (index = chunk - 1) THEN  state.Permute  END;
@@ -129,9 +129,9 @@ TYPE
 			index := 0;
 			index := 0;
 			squeezing := TRUE
 			squeezing := TRUE
 		END AbsorbLastFewBits;
 		END AbsorbLastFewBits;
-	
+
 	END Instance;
 	END Instance;
-	
+
 
 
 
 
 END CryptoKeccakSponge.
 END CryptoKeccakSponge.

+ 8 - 8
source/CryptoMD5.Mod

@@ -23,9 +23,9 @@ TYPE
 		BEGIN
 		BEGIN
 			N := 0;
 			N := 0;
 			(* Initialize chaining values *)
 			(* Initialize chaining values *)
-			A := LONGINT( 067452301H );  
-			B := LONGINT( 0EFCDAB89H );  
-			C := LONGINT( 098BADCFEH );  
+			A := LONGINT( 067452301H );
+			B := LONGINT( 0EFCDAB89H );
+			C := LONGINT( 098BADCFEH );
 			D := LONGINT( 010325476H );
 			D := LONGINT( 010325476H );
 			initialized := TRUE
 			initialized := TRUE
 		END Initialize;
 		END Initialize;
@@ -92,11 +92,11 @@ VAR
 		NEW( h );  RETURN h
 		NEW( h );  RETURN h
 	END NewHash;
 	END NewHash;
 
 
-	
+
 
 
 	PROCEDURE MD5( CONST X: Buffer; VAR A, B, C, D: LONGINT );
 	PROCEDURE MD5( CONST X: Buffer; VAR A, B, C, D: LONGINT );
 	VAR  a, b, c, d: LONGINT;
 	VAR  a, b, c, d: LONGINT;
-	
+
 		PROCEDURE -F1( VAR a: LONGINT;  b, c, d, x, s, t: LONGINT );
 		PROCEDURE -F1( VAR a: LONGINT;  b, c, d, x, s, t: LONGINT );
 		VAR f: LONGINT;
 		VAR f: LONGINT;
 		BEGIN
 		BEGIN
@@ -124,7 +124,7 @@ VAR
 			f := S.VAL( LONGINT, S.VAL( SET32, c ) / (S.VAL( SET32, b ) + (-S.VAL( SET32, d ))) );
 			f := S.VAL( LONGINT, S.VAL( SET32, c ) / (S.VAL( SET32, b ) + (-S.VAL( SET32, d ))) );
 			a := ROT( a + f + x + t, s ) + b
 			a := ROT( a + f + x + t, s ) + b
 		END F4;
 		END F4;
-	
+
 	BEGIN
 	BEGIN
 		a := A;  b := B;  c := C;  d := D;
 		a := A;  b := B;  c := C;  d := D;
 
 
@@ -166,9 +166,9 @@ VAR
 
 
 		INC( A, a );  INC( B, b );  INC( C, c );  INC( D, d );
 		INC( A, a );  INC( B, b );  INC( C, c );  INC( D, d );
 	END MD5;
 	END MD5;
-	
+
 	PROCEDURE Initialize;
 	PROCEDURE Initialize;
-	VAR 
+	VAR
 		buf: U.InitBuffer;  i: LONGINT;
 		buf: U.InitBuffer;  i: LONGINT;
 	BEGIN
 	BEGIN
 		NEW( buf, 1024 );
 		NEW( buf, 1024 );

+ 1 - 1
source/CryptoPrimes.Mod

@@ -220,6 +220,6 @@ VAR
 	END Init;
 	END Init;
 
 
 BEGIN
 BEGIN
-	Init;  B.AssignInt( one, 1 ); 
+	Init;  B.AssignInt( one, 1 );
 END CryptoPrimes.
 END CryptoPrimes.
 
 

+ 3 - 3
source/CryptoRSA.Mod

@@ -313,10 +313,10 @@ VAR
 	VAR str: ARRAY 64 OF CHAR;
 	VAR str: ARRAY 64 OF CHAR;
 	BEGIN
 	BEGIN
 		r.SkipWhitespace; r.String( str );
 		r.SkipWhitespace; r.String( str );
-		ASSERT( str = "ssh-rsa" );	
+		ASSERT( str = "ssh-rsa" );
 		RETURN ExtractPublicKey( r )
 		RETURN ExtractPublicKey( r )
 	END LoadPublicKey;
 	END LoadPublicKey;
-	
+
 	PROCEDURE ExtractPublicKey*( r: Streams.Reader ): Key;
 	PROCEDURE ExtractPublicKey*( r: Streams.Reader ): Key;
 	VAR buf: ARRAY 4096 OF CHAR; len, pos: LONGINT;
 	VAR buf: ARRAY 4096 OF CHAR; len, pos: LONGINT;
 		str: ARRAY 64 OF CHAR;
 		str: ARRAY 64 OF CHAR;
@@ -326,7 +326,7 @@ VAR
 		len := Base64.DecodeStream( r, buf );
 		len := Base64.DecodeStream( r, buf );
 		pos := 0;
 		pos := 0;
 		U.GetString( buf, pos, str );
 		U.GetString( buf, pos, str );
-		ASSERT( str = "ssh-rsa" );	
+		ASSERT( str = "ssh-rsa" );
 		U.GetBigNumber( buf, pos, k.exponent );
 		U.GetBigNumber( buf, pos, k.exponent );
 		U.GetBigNumber( buf, pos, k.modulus );
 		U.GetBigNumber( buf, pos, k.modulus );
 		RETURN k
 		RETURN k

+ 11 - 11
source/CryptoSHA1.Mod

@@ -15,8 +15,8 @@ TYPE
 			Nl, Nh: LONGINT;
 			Nl, Nh: LONGINT;
 			cdata: ARRAY BlockSize OF CHAR;	(* pending data *)
 			cdata: ARRAY BlockSize OF CHAR;	(* pending data *)
 			cn: LONGINT	(* number of chars in data *)
 			cn: LONGINT	(* number of chars in data *)
-			
-			
+
+
 		PROCEDURE &Init*;
 		PROCEDURE &Init*;
 		BEGIN
 		BEGIN
 			SetNameAndSize( "sha1", 20 );
 			SetNameAndSize( "sha1", 20 );
@@ -35,8 +35,8 @@ TYPE
 			cn := 0;
 			cn := 0;
 			initialized := TRUE
 			initialized := TRUE
 		END Initialize;
 		END Initialize;
-		
-		
+
+
 		PROCEDURE HashContextBlock;
 		PROCEDURE HashContextBlock;
 		BEGIN
 		BEGIN
 			HashBlock( hash, cdata, 0 );  cn := 0
 			HashBlock( hash, cdata, 0 );  cn := 0
@@ -65,7 +65,7 @@ TYPE
 			END;
 			END;
 
 
 			n := 0;
 			n := 0;
-			WHILE n < len DIV BlockSize  DO  
+			WHILE n < len DIV BlockSize  DO
 				HashBlock( hash, data, pos );  INC( n ); INC( pos, BlockSize )
 				HashBlock( hash, data, pos );  INC( n ); INC( pos, BlockSize )
 			END;
 			END;
 			len := len MOD BlockSize;
 			len := len MOD BlockSize;
@@ -122,7 +122,7 @@ TYPE
 
 
 	PROCEDURE -tr0019( a: LONGINT; VAR b: LONGINT; c, d, e: LONGINT; VAR  f: LONGINT; x: SET32 );
 	PROCEDURE -tr0019( a: LONGINT; VAR b: LONGINT; c, d, e: LONGINT; VAR  f: LONGINT; x: SET32 );
 	BEGIN
 	BEGIN
-		f := S.VAL( LONGINT, x ) + e + 5A827999H + ROT( a, 5 ) + 
+		f := S.VAL( LONGINT, x ) + e + 5A827999H + ROT( a, 5 ) +
 			(*F1( b, c, d );*)
 			(*F1( b, c, d );*)
 			S.VAL( LONGINT, ((S.VAL( SET32, c ) / S.VAL( SET32, d )) * S.VAL( SET32, b )) / S.VAL( SET32, d ) );
 			S.VAL( LONGINT, ((S.VAL( SET32, c ) / S.VAL( SET32, d )) * S.VAL( SET32, b )) / S.VAL( SET32, d ) );
 		b := ROT( b, 30 );
 		b := ROT( b, 30 );
@@ -130,7 +130,7 @@ TYPE
 
 
 	PROCEDURE -tr2039( a: LONGINT;  VAR b: LONGINT;  c, d, e: LONGINT;  VAR f: LONGINT;  x: SET32 );
 	PROCEDURE -tr2039( a: LONGINT;  VAR b: LONGINT;  c, d, e: LONGINT;  VAR f: LONGINT;  x: SET32 );
 	BEGIN
 	BEGIN
-		f := S.VAL( LONGINT, x ) + e + 6ED9EBA1H + ROT( a, 5 ) + 
+		f := S.VAL( LONGINT, x ) + e + 6ED9EBA1H + ROT( a, 5 ) +
 			(*F2( b, c, d );*)
 			(*F2( b, c, d );*)
 			S.VAL( LONGINT, S.VAL( SET32, b ) / S.VAL( SET32, c ) / S.VAL( SET32, d ) );
 			S.VAL( LONGINT, S.VAL( SET32, b ) / S.VAL( SET32, c ) / S.VAL( SET32, d ) );
 		b := ROT( b, 30 );
 		b := ROT( b, 30 );
@@ -138,7 +138,7 @@ TYPE
 
 
 	PROCEDURE -tr4059( a: LONGINT;  VAR b: LONGINT;  c, d, e: LONGINT;  VAR f: LONGINT;  x: SET32);
 	PROCEDURE -tr4059( a: LONGINT;  VAR b: LONGINT;  c, d, e: LONGINT;  VAR f: LONGINT;  x: SET32);
 	BEGIN
 	BEGIN
-		f := S.VAL( LONGINT, x ) + e + LONGINT(8F1BBCDCH) + ROT( a, 5 ) + 
+		f := S.VAL( LONGINT, x ) + e + LONGINT(8F1BBCDCH) + ROT( a, 5 ) +
 			(*F3( b, c, d );*)
 			(*F3( b, c, d );*)
 			S.VAL( LONGINT, (S.VAL( SET32, b ) * S.VAL( SET32, c )) + ((S.VAL( SET32, b ) + S.VAL( SET32, c )) * S.VAL( SET32, d )) );
 			S.VAL( LONGINT, (S.VAL( SET32, b ) * S.VAL( SET32, c )) + ((S.VAL( SET32, b ) + S.VAL( SET32, c )) * S.VAL( SET32, d )) );
 		b := ROT( b, 30 )
 		b := ROT( b, 30 )
@@ -146,14 +146,14 @@ TYPE
 
 
 	PROCEDURE -tr6079( a: LONGINT;  VAR b: LONGINT;  c, d, e: LONGINT;  VAR f: LONGINT;  x: SET32 );
 	PROCEDURE -tr6079( a: LONGINT;  VAR b: LONGINT;  c, d, e: LONGINT;  VAR f: LONGINT;  x: SET32 );
 	BEGIN
 	BEGIN
-		f := S.VAL( LONGINT, x ) + e + LONGINT(0CA62C1D6H) + ROT( a, 5 ) + 
+		f := S.VAL( LONGINT, x ) + e + LONGINT(0CA62C1D6H) + ROT( a, 5 ) +
 			(*F2( b, c, d );*)
 			(*F2( b, c, d );*)
 			S.VAL( LONGINT, S.VAL( SET32, b ) / S.VAL( SET32, c ) / S.VAL( SET32, d ) );
 			S.VAL( LONGINT, S.VAL( SET32, b ) / S.VAL( SET32, c ) / S.VAL( SET32, d ) );
 		b := ROT( b, 30 );
 		b := ROT( b, 30 );
 	END tr6079;
 	END tr6079;
 
 
 	PROCEDURE HashBlock( VAR state: State;  CONST buf: ARRAY OF CHAR;  pos: LONGINT );
 	PROCEDURE HashBlock( VAR state: State;  CONST buf: ARRAY OF CHAR;  pos: LONGINT );
-	VAR 
+	VAR
 		A, B, C, D, E, T: LONGINT;
 		A, B, C, D, E, T: LONGINT;
 		x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, xa, xb, xc, xd, xe, xf: SET32;
 		x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, xa, xb, xc, xd, xe, xf: SET32;
 	BEGIN
 	BEGIN
@@ -244,7 +244,7 @@ TYPE
 		xe := ROT( xe / x0 / x6 / xb, 1 );		tr6079( A, B, C, D, E, T, xe );
 		xe := ROT( xe / x0 / x6 / xb, 1 );		tr6079( A, B, C, D, E, T, xe );
 		xf  := ROT( xf  / x1 / x7 / xc, 1 );		tr6079( T, A, B, C, D, E, xf  );
 		xf  := ROT( xf  / x1 / x7 / xc, 1 );		tr6079( T, A, B, C, D, E, xf  );
 
 
-		INC( state[0], E );  INC( state[1], T );  INC( state[2], A );  
+		INC( state[0], E );  INC( state[1], T );  INC( state[2], A );
 		INC( state[3], B );  INC( state[4], C );
 		INC( state[3], B );  INC( state[4], C );
 	END HashBlock;
 	END HashBlock;
 
 

+ 23 - 23
source/CryptoSHA256.Mod

@@ -5,10 +5,10 @@ IMPORT
 
 
 CONST
 CONST
 	BlockSize = 64;
 	BlockSize = 64;
-	
-VAR 
+
+VAR
 	K256: ARRAY 64 OF LONGINT;
 	K256: ARRAY 64 OF LONGINT;
-	
+
 
 
 TYPE
 TYPE
 	Hash* = OBJECT (Hashes.Hash)
 	Hash* = OBJECT (Hashes.Hash)
@@ -20,7 +20,7 @@ TYPE
 
 
 		PROCEDURE &Init*;
 		PROCEDURE &Init*;
 		BEGIN
 		BEGIN
-			SetNameAndSize( "sha256", 32 ); 
+			SetNameAndSize( "sha256", 32 );
 			initialized := FALSE
 			initialized := FALSE
 		END Init;
 		END Init;
 
 
@@ -35,14 +35,14 @@ TYPE
 			cn := 0;
 			cn := 0;
 			initialized := TRUE
 			initialized := TRUE
 		END Initialize;
 		END Initialize;
-		
+
 		PROCEDURE HashBlock( CONST buf: ARRAY OF CHAR;  pos: LONGINT );
 		PROCEDURE HashBlock( CONST buf: ARRAY OF CHAR;  pos: LONGINT );
 		VAR a, b, c, d, e, f, g, h, s0, s1, s, T1, T2, i: LONGINT;
 		VAR a, b, c, d, e, f, g, h, s0, s1, s, T1, T2, i: LONGINT;
 			X: ARRAY 16 OF LONGINT
 			X: ARRAY 16 OF LONGINT
 		BEGIN
 		BEGIN
 			a := hash[0];  b := hash[1];  c := hash[2];  d := hash[3];
 			a := hash[0];  b := hash[1];  c := hash[2];  d := hash[3];
 			e := hash[4];  f := hash[5];  g := hash[6];  h := hash[7];
 			e := hash[4];  f := hash[5];  g := hash[6];  h := hash[7];
-				
+
 			FOR i := 0 TO 63 DO
 			FOR i := 0 TO 63 DO
 				IF i < 16 THEN
 				IF i < 16 THEN
 					X[i] := U.IntFromBufferBE( buf, pos );  INC( pos, 4 )
 					X[i] := U.IntFromBufferBE( buf, pos );  INC( pos, 4 )
@@ -50,25 +50,25 @@ TYPE
 					s0 := sigma0( X[(i + 1) MOD 16] );
 					s0 := sigma0( X[(i + 1) MOD 16] );
 					s1 := sigma1( X[(i + 14) MOD 16] );
 					s1 := sigma1( X[(i + 14) MOD 16] );
 					s := s0 + s1 + X[(i + 9) MOD 16];
 					s := s0 + s1 + X[(i + 9) MOD 16];
-					INC( X[i MOD 16], s );  
+					INC( X[i MOD 16], s );
 				END;
 				END;
 				T1 := X[i MOD 16] + h + Sigma1Ch( e, f, g ) + K256[i];
 				T1 := X[i MOD 16] + h + Sigma1Ch( e, f, g ) + K256[i];
 				T2 := Sigma0Maj( a, b, c );
 				T2 := Sigma0Maj( a, b, c );
 				h := g;  g := f;  f := e;  e := d + T1;
 				h := g;  g := f;  f := e;  e := d + T1;
 				d := c;  c := b;  b := a;  a := T1 + T2;
 				d := c;  c := b;  b := a;  a := T1 + T2;
 			END;
 			END;
-			
+
 			INC( hash[0], a );  INC( hash[1],  b );  INC( hash[2],  c );  INC( hash[3],  d );
 			INC( hash[0], a );  INC( hash[1],  b );  INC( hash[2],  c );  INC( hash[3],  d );
 			INC( hash[4], e );  INC( hash[5],  f );  INC( hash[6],  g );  INC( hash[7],  h );
 			INC( hash[4], e );  INC( hash[5],  f );  INC( hash[6],  g );  INC( hash[7],  h );
 		END HashBlock;
 		END HashBlock;
-	
-	
+
+
 		PROCEDURE HashContextBlock;
 		PROCEDURE HashContextBlock;
 		BEGIN
 		BEGIN
 			HashBlock( cdata, 0 );  cn := 0
 			HashBlock( cdata, 0 );  cn := 0
 		END HashContextBlock;
 		END HashContextBlock;
-		
-		
+
+
 		(** data: value to be hashed *)
 		(** data: value to be hashed *)
 		PROCEDURE Update*( CONST data: ARRAY OF CHAR;  pos, len: LONGINT );
 		PROCEDURE Update*( CONST data: ARRAY OF CHAR;  pos, len: LONGINT );
 			VAR n, i, l: LONGINT;
 			VAR n, i, l: LONGINT;
@@ -110,7 +110,7 @@ TYPE
 			WHILE cn < p  DO  cdata[cn] := 0X;  INC( cn )  END;
 			WHILE cn < p  DO  cdata[cn] := 0X;  INC( cn )  END;
 			U.IntToBufferBE( Nh, cdata, p );  U.IntToBufferBE( Nl, cdata, p + 4 );
 			U.IntToBufferBE( Nh, cdata, p );  U.IntToBufferBE( Nl, cdata, p + 4 );
 			HashContextBlock;
 			HashContextBlock;
-			
+
 			FOR i := 0 TO 7 DO  U.IntToBufferBE( hash[i], buf, pos );  INC( pos, 4 )  END;
 			FOR i := 0 TO 7 DO  U.IntToBufferBE( hash[i], buf, pos );  INC( pos, 4 )  END;
 		END GetHash;
 		END GetHash;
 
 
@@ -130,17 +130,17 @@ TYPE
 
 
 
 
 	PROCEDURE -Sigma0Maj( px, py, pz: LONGINT ): LONGINT;
 	PROCEDURE -Sigma0Maj( px, py, pz: LONGINT ): LONGINT;
-	VAR x, y, z, a, b: SET32; 
-	BEGIN 
+	VAR x, y, z, a, b: SET32;
+	BEGIN
 		x := S.VAL( SET32, px );  y := S.VAL( SET32, py );  z := S.VAL( SET32, pz );
 		x := S.VAL( SET32, px );  y := S.VAL( SET32, py );  z := S.VAL( SET32, pz );
 		a := ROT( x, 30 ) / ROT( x, 19 ) / ROT( x, 10 );
 		a := ROT( x, 30 ) / ROT( x, 19 ) / ROT( x, 10 );
 		b := (x*y) / (x*z) / (y*z);
 		b := (x*y) / (x*z) / (y*z);
 		RETURN S.VAL( LONGINT, a ) + S.VAL( LONGINT, b )
 		RETURN S.VAL( LONGINT, a ) + S.VAL( LONGINT, b )
 	END Sigma0Maj;
 	END Sigma0Maj;
-	
+
 	PROCEDURE -Sigma1Ch( px, py, pz: LONGINT ): LONGINT;
 	PROCEDURE -Sigma1Ch( px, py, pz: LONGINT ): LONGINT;
 	VAR x, y, z, a, b: SET32;
 	VAR x, y, z, a, b: SET32;
-	BEGIN 
+	BEGIN
 		x := S.VAL( SET32, px );  y := S.VAL( SET32, py );  z := S.VAL( SET32, pz );
 		x := S.VAL( SET32, px );  y := S.VAL( SET32, py );  z := S.VAL( SET32, pz );
 		a := ROT( x, 26 ) / ROT( x, 21 ) / ROT( x, 7 );
 		a := ROT( x, 26 ) / ROT( x, 21 ) / ROT( x, 7 );
 		b := (x*y) / ((-x)*z);
 		b := (x*y) / ((-x)*z);
@@ -149,23 +149,23 @@ TYPE
 
 
 	PROCEDURE -sigma0( px: LONGINT ): LONGINT;
 	PROCEDURE -sigma0( px: LONGINT ): LONGINT;
 	VAR x: SET32;
 	VAR x: SET32;
-	BEGIN 
+	BEGIN
 		x :=S.VAL( SET32, px );
 		x :=S.VAL( SET32, px );
 		RETURN S.VAL( LONGINT, ROT( x , 25 ) / ROT( x, 14 ) / LSH( x, -3 ) )
 		RETURN S.VAL( LONGINT, ROT( x , 25 ) / ROT( x, 14 ) / LSH( x, -3 ) )
 	END sigma0;
 	END sigma0;
-	
+
 	PROCEDURE -sigma1( px: LONGINT ): LONGINT;
 	PROCEDURE -sigma1( px: LONGINT ): LONGINT;
 	VAR x: SET32;
 	VAR x: SET32;
-	BEGIN 
+	BEGIN
 		x := S.VAL( SET32, px );
 		x := S.VAL( SET32, px );
 		RETURN S.VAL( LONGINT, ROT( x , 15 ) / ROT( x, 13 ) / LSH( x, -10 ) )
 		RETURN S.VAL( LONGINT, ROT( x , 15 ) / ROT( x, 13 ) / LSH( x, -10 ) )
 	END sigma1;
 	END sigma1;
-	
 
 
 
 
-	
+
+
 	PROCEDURE InitializeK;
 	PROCEDURE InitializeK;
-	VAR 
+	VAR
 		buf: U.InitBuffer; i: LONGINT;
 		buf: U.InitBuffer; i: LONGINT;
 	BEGIN
 	BEGIN
 		NEW( buf, 2048 );
 		NEW( buf, 2048 );

+ 8 - 8
source/CryptoSHA3.Mod

@@ -12,12 +12,12 @@ TYPE
 		VAR
 		VAR
 			sponge: Sponge.Instance;
 			sponge: Sponge.Instance;
 			capacity: LONGINT;
 			capacity: LONGINT;
-			
+
 		PROCEDURE &Init*;	(* sha3-256 (default) *)
 		PROCEDURE &Init*;	(* sha3-256 (default) *)
 		BEGIN
 		BEGIN
 			NEW( sponge );
 			NEW( sponge );
-			capacity := 2*256;   
-			Initialize	
+			capacity := 2*256;
+			Initialize
 		END Init;
 		END Init;
 
 
 		PROCEDURE Initialize*;
 		PROCEDURE Initialize*;
@@ -36,22 +36,22 @@ TYPE
 			sponge.Initialize( Sponge.Width - capacity, capacity );
 			sponge.Initialize( Sponge.Width - capacity, capacity );
 			initialized := TRUE
 			initialized := TRUE
 		END Initialize;
 		END Initialize;
-		
+
 		PROCEDURE SetNameAndSize*( CONST name: ARRAY OF CHAR; bytesize: LONGINT );
 		PROCEDURE SetNameAndSize*( CONST name: ARRAY OF CHAR; bytesize: LONGINT );
 		(* valid bytesize values: 28, 32(default), 48, 64 *)
 		(* valid bytesize values: 28, 32(default), 48, 64 *)
 		BEGIN
 		BEGIN
 			capacity := 2*8*bytesize;  Initialize;
 			capacity := 2*8*bytesize;  Initialize;
 			IF name # "" THEN  SetNameAndSize^( name, bytesize )  END
 			IF name # "" THEN  SetNameAndSize^( name, bytesize )  END
 		END SetNameAndSize;
 		END SetNameAndSize;
-		
+
 
 
 		(** data: value to be hashed *)
 		(** data: value to be hashed *)
 		PROCEDURE Update*( CONST data: ARRAY OF CHAR;  pos, len: LONGINT );
 		PROCEDURE Update*( CONST data: ARRAY OF CHAR;  pos, len: LONGINT );
 		BEGIN
 		BEGIN
-			ASSERT( initialized );	
+			ASSERT( initialized );
 			sponge.Absorb( data, pos, len )
 			sponge.Absorb( data, pos, len )
 		END Update;
 		END Update;
-		
+
 
 
 		(** get the hashvalue of length SELF.size *)
 		(** get the hashvalue of length SELF.size *)
 		PROCEDURE GetHash*( VAR buf: ARRAY OF CHAR;  pos: LONGINT );
 		PROCEDURE GetHash*( VAR buf: ARRAY OF CHAR;  pos: LONGINT );
@@ -64,7 +64,7 @@ TYPE
 
 
 
 
 
 
-	
+
 	(** get an instance of SHA-3 *)
 	(** get an instance of SHA-3 *)
 	PROCEDURE NewHash*( ) : Hashes.Hash;
 	PROCEDURE NewHash*( ) : Hashes.Hash;
 		VAR h: Hash;
 		VAR h: Hash;

+ 43 - 43
source/CryptoTestCiphers.Mod

@@ -27,7 +27,7 @@ IMPORT
 		cipher.InitKey( binkey, keybits );
 		cipher.InitKey( binkey, keybits );
 		cipher.Decrypt( bindata, 0, cipher.blockSize );
 		cipher.Decrypt( bindata, 0, cipher.blockSize );
 		Out.Ln; Out.String( "Decrypted: " ); U.PrintHex( bindata, 0, cipher.blockSize );
 		Out.Ln; Out.String( "Decrypted: " ); U.PrintHex( bindata, 0, cipher.blockSize );
-		bindata[cipher.blockSize] := 0X; 
+		bindata[cipher.blockSize] := 0X;
 		Out.Ln;
 		Out.Ln;
 		IF bindata = orig THEN  Out.String( "OK" )  ELSE  Out.String( "FAIL" )  END;
 		IF bindata = orig THEN  Out.String( "OK" )  ELSE  Out.String( "FAIL" )  END;
 		Out.Ln
 		Out.Ln
@@ -61,12 +61,12 @@ IMPORT
 		cipher.SetIV( iv, Ciphers.CBC );
 		cipher.SetIV( iv, Ciphers.CBC );
 		cipher.Decrypt( bindata, 0, 2 * cipher.blockSize );
 		cipher.Decrypt( bindata, 0, 2 * cipher.blockSize );
 		Out.Ln; Out.String( "Decrypted: " ); U.PrintHex( bindata, 0, 2 * cipher.blockSize );
 		Out.Ln; Out.String( "Decrypted: " ); U.PrintHex( bindata, 0, 2 * cipher.blockSize );
-		bindata[2 * cipher.blockSize] := 0X; 
+		bindata[2 * cipher.blockSize] := 0X;
 		Out.Ln;
 		Out.Ln;
 		IF bindata = orig THEN  Out.String( "OK" )  ELSE  Out.String( "FAIL" )  END;
 		IF bindata = orig THEN  Out.String( "OK" )  ELSE  Out.String( "FAIL" )  END;
 		Out.Ln
 		Out.Ln
 	END Cbc1;
 	END Cbc1;
-	
+
 	PROCEDURE  Ctr1*(context : Commands.Context);
 	PROCEDURE  Ctr1*(context : Commands.Context);
 		VAR
 		VAR
 			hex, bindata, binkey, modname, iv, orig: ARRAY 64 OF CHAR; cipher: Ciphers.Cipher;
 			hex, bindata, binkey, modname, iv, orig: ARRAY 64 OF CHAR; cipher: Ciphers.Cipher;
@@ -95,12 +95,12 @@ IMPORT
 		cipher.SetIV( iv, Ciphers.CTR );
 		cipher.SetIV( iv, Ciphers.CTR );
 		cipher.Decrypt( bindata, 0, 16 );
 		cipher.Decrypt( bindata, 0, 16 );
 		Out.Ln; Out.String( "Decrypted: " ); U.PrintHex( bindata, 0, 16 );
 		Out.Ln; Out.String( "Decrypted: " ); U.PrintHex( bindata, 0, 16 );
-		bindata[16] := 0X; 
+		bindata[16] := 0X;
 		Out.Ln;
 		Out.Ln;
 		IF bindata = orig THEN  Out.String( "OK" )  ELSE  Out.String( "FAIL" )  END;
 		IF bindata = orig THEN  Out.String( "OK" )  ELSE  Out.String( "FAIL" )  END;
 		Out.Ln
 		Out.Ln
 	END Ctr1;
 	END Ctr1;
-	
+
 
 
 	(** encrypt input with key (ebc-mode). output is a testvector *)
 	(** encrypt input with key (ebc-mode). output is a testvector *)
 	PROCEDURE  Ecb2*( CONST modname, input, output, key: ARRAY OF CHAR; datalen, keybits: LONGINT );
 	PROCEDURE  Ecb2*( CONST modname, input, output, key: ARRAY OF CHAR; datalen, keybits: LONGINT );
@@ -142,7 +142,7 @@ IMPORT
 		Out.Ln; Out.String( "Key: " ); U.PrintHex( temp1, 0, keybits DIV 8 );
 		Out.Ln; Out.String( "Key: " ); U.PrintHex( temp1, 0, keybits DIV 8 );
 		U.Hex2Bin( input, 0, temp1, 0, datalen );
 		U.Hex2Bin( input, 0, temp1, 0, datalen );
 		Out.Ln; Out.String( "plaintext: " ); U.PrintHex( temp1, 0, datalen );
 		Out.Ln; Out.String( "plaintext: " ); U.PrintHex( temp1, 0, datalen );
-		cipher.Encrypt( temp1, 0, datalen ); 
+		cipher.Encrypt( temp1, 0, datalen );
 		Out.Ln; Out.String( "encryption: " ); U.PrintHex( temp1, 0, datalen );
 		Out.Ln; Out.String( "encryption: " ); U.PrintHex( temp1, 0, datalen );
 		U.Hex2Bin( output, 0, temp2, 0, datalen );
 		U.Hex2Bin( output, 0, temp2, 0, datalen );
 		Out.Ln; Out.String( "correct encryption: " ); U.PrintHex( temp2, 0, datalen );
 		Out.Ln; Out.String( "correct encryption: " ); U.PrintHex( temp2, 0, datalen );
@@ -151,7 +151,7 @@ IMPORT
 		IF temp1 = temp2 THEN  Out.String( "OK" )  ELSE  Out.String( "FAIL" )  END;
 		IF temp1 = temp2 THEN  Out.String( "OK" )  ELSE  Out.String( "FAIL" )  END;
 		Out.Ln
 		Out.Ln
 	END Cbc2;
 	END Cbc2;
-	
+
 	(** decrypt input with key (cbc-mode). output is a testvector *)
 	(** decrypt input with key (cbc-mode). output is a testvector *)
 	PROCEDURE DecryptCbc2*(CONST modname, input, output, key, iv: ARRAY OF CHAR; datalen, keybits: LONGINT);
 	PROCEDURE DecryptCbc2*(CONST modname, input, output, key, iv: ARRAY OF CHAR; datalen, keybits: LONGINT);
 		VAR
 		VAR
@@ -168,7 +168,7 @@ IMPORT
 		Out.Ln; Out.String( "Key: " ); U.PrintHex( temp1, 0, keybits DIV 8 );
 		Out.Ln; Out.String( "Key: " ); U.PrintHex( temp1, 0, keybits DIV 8 );
 		U.Hex2Bin( input, 0, temp1, 0, datalen );
 		U.Hex2Bin( input, 0, temp1, 0, datalen );
 		Out.Ln; Out.String( "ciphertext: " ); U.PrintHex( temp1, 0, datalen );
 		Out.Ln; Out.String( "ciphertext: " ); U.PrintHex( temp1, 0, datalen );
-		cipher.Decrypt( temp1, 0, datalen ); 
+		cipher.Decrypt( temp1, 0, datalen );
 		Out.Ln; Out.String( "decryption: " ); U.PrintHex( temp1, 0, datalen );
 		Out.Ln; Out.String( "decryption: " ); U.PrintHex( temp1, 0, datalen );
 		U.Hex2Bin( output, 0, temp2, 0, datalen );
 		U.Hex2Bin( output, 0, temp2, 0, datalen );
 		Out.Ln; Out.String( "correct decryption: " ); U.PrintHex( temp2, 0, datalen );
 		Out.Ln; Out.String( "correct decryption: " ); U.PrintHex( temp2, 0, datalen );
@@ -177,7 +177,7 @@ IMPORT
 		IF temp1 = temp2 THEN  Out.String( "OK" )  ELSE  Out.String( "FAIL" )  END;
 		IF temp1 = temp2 THEN  Out.String( "OK" )  ELSE  Out.String( "FAIL" )  END;
 		Out.Ln
 		Out.Ln
 	END DecryptCbc2;
 	END DecryptCbc2;
-	
+
 	(** encrypt input with key (counter-mode). output is a testvector *)
 	(** encrypt input with key (counter-mode). output is a testvector *)
 	PROCEDURE  Ctr2*( CONST modname, input, output, key, iv: ARRAY OF CHAR; datalen, keybits: LONGINT );
 	PROCEDURE  Ctr2*( CONST modname, input, output, key, iv: ARRAY OF CHAR; datalen, keybits: LONGINT );
 		VAR
 		VAR
@@ -194,7 +194,7 @@ IMPORT
 		Out.Ln; Out.String( "Key: " ); U.PrintHex( temp1, 0, keybits DIV 8 );
 		Out.Ln; Out.String( "Key: " ); U.PrintHex( temp1, 0, keybits DIV 8 );
 		U.Hex2Bin( input, 0, temp1, 0, datalen );
 		U.Hex2Bin( input, 0, temp1, 0, datalen );
 		Out.Ln; Out.String( "plaintext: " ); U.PrintHex( temp1, 0, datalen );
 		Out.Ln; Out.String( "plaintext: " ); U.PrintHex( temp1, 0, datalen );
-		cipher.Encrypt( temp1, 0, datalen ); 
+		cipher.Encrypt( temp1, 0, datalen );
 		Out.Ln; Out.String( "encryption: " ); U.PrintHex( temp1, 0, datalen );
 		Out.Ln; Out.String( "encryption: " ); U.PrintHex( temp1, 0, datalen );
 		U.Hex2Bin( output, 0, temp2, 0, datalen );
 		U.Hex2Bin( output, 0, temp2, 0, datalen );
 		Out.Ln; Out.String( "correct encryption: " ); U.PrintHex( temp2, 0, datalen );
 		Out.Ln; Out.String( "correct encryption: " ); U.PrintHex( temp2, 0, datalen );
@@ -242,14 +242,14 @@ IMPORT
 		input := "4E6F772069732074";		output := "3FA40E8A984D4815";
 		input := "4E6F772069732074";		output := "3FA40E8A984D4815";
 		Ecb2( "CryptoDES", input, output, key, 8, 64 );
 		Ecb2( "CryptoDES", input, output, key, 8, 64 );
 	END DesEcb2;
 	END DesEcb2;
-	
+
 	PROCEDURE Des3Ecb2*;
 	PROCEDURE Des3Ecb2*;
 		VAR input, output, key: ARRAY 64 OF CHAR;
 		VAR input, output, key: ARRAY 64 OF CHAR;
 	BEGIN
 	BEGIN
 		key := "0123456789ABCDEF23456789ABCDEF01456789ABCDEF0123";
 		key := "0123456789ABCDEF23456789ABCDEF01456789ABCDEF0123";
 		input := "4E6F772069732074";		output := "314F8327FA7A09A8";
 		input := "4E6F772069732074";		output := "314F8327FA7A09A8";
 		Ecb2( "CryptoDES3", input, output, key, 8, 192 );
 		Ecb2( "CryptoDES3", input, output, key, 8, 192 );
-	END Des3Ecb2; 
+	END Des3Ecb2;
 
 
 	PROCEDURE  IdeaEcb2*;
 	PROCEDURE  IdeaEcb2*;
 		VAR input, output, key: ARRAY 64 OF CHAR;
 		VAR input, output, key: ARRAY 64 OF CHAR;
@@ -263,17 +263,17 @@ IMPORT
 		VAR input, output, key: ARRAY 128 OF CHAR;
 		VAR input, output, key: ARRAY 128 OF CHAR;
 	BEGIN
 	BEGIN
 		key := "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b";
 		key := "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b";
-		input := "6bc1bee22e409f96e93d7e117393172a";		
+		input := "6bc1bee22e409f96e93d7e117393172a";
 		output := "bd334f1d6e45f25ff712a214571fa5cc";
 		output := "bd334f1d6e45f25ff712a214571fa5cc";
 		Ecb2( "CryptoAES", input, output, key, 16, 192 );
 		Ecb2( "CryptoAES", input, output, key, 16, 192 );
-		
+
 		key := "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4";
 		key := "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4";
 		input := "6bc1bee22e409f96e93d7e117393172a";
 		input := "6bc1bee22e409f96e93d7e117393172a";
 		output := "f3eed1bdb5d2a03c064b5a7e3db181f8";
 		output := "f3eed1bdb5d2a03c064b5a7e3db181f8";
 		Ecb2( "CryptoAES", input, output, key, 16, 256 );
 		Ecb2( "CryptoAES", input, output, key, 16, 256 );
 	END AesEcb2;
 	END AesEcb2;
-	
-	
+
+
 	PROCEDURE  Arc4Ecb2*;
 	PROCEDURE  Arc4Ecb2*;
 		VAR input, output, key: ARRAY 64 OF CHAR;
 		VAR input, output, key: ARRAY 64 OF CHAR;
 	BEGIN
 	BEGIN
@@ -281,29 +281,29 @@ IMPORT
 		input := "0123456789abcdef";		output := "75b7878099e0c596";
 		input := "0123456789abcdef";		output := "75b7878099e0c596";
 		Ecb2( "CryptoARC4", input, output, key, 8, 64 );
 		Ecb2( "CryptoARC4", input, output, key, 8, 64 );
 	END Arc4Ecb2;
 	END Arc4Ecb2;
-	
-	
+
+
 	PROCEDURE  CastEcb2*;
 	PROCEDURE  CastEcb2*;
 		VAR input, output, key: ARRAY 64 OF CHAR;
 		VAR input, output, key: ARRAY 64 OF CHAR;
 	BEGIN
 	BEGIN
 		key := "0123456712345678234567893456789A";
 		key := "0123456712345678234567893456789A";
 		input := "0123456789abcdef";		output := "238B4FE5847E44B2";
 		input := "0123456789abcdef";		output := "238B4FE5847E44B2";
 		Ecb2( "CryptoCAST", input, output, key, 8, 128 );
 		Ecb2( "CryptoCAST", input, output, key, 8, 128 );
-		
+
 		output := "EB6A711A2C02271B";
 		output := "EB6A711A2C02271B";
 		Ecb2( "CryptoCAST", input, output, key, 8, 80 );
 		Ecb2( "CryptoCAST", input, output, key, 8, 80 );
-		
+
 		output := "7AC816D16E9B302E";
 		output := "7AC816D16E9B302E";
 		Ecb2( "CryptoCAST", input, output, key, 8, 40 );
 		Ecb2( "CryptoCAST", input, output, key, 8, 40 );
 	END CastEcb2;
 	END CastEcb2;
-	
-	
-	
+
+
+
 
 
 	PROCEDURE  DesCbc2*;
 	PROCEDURE  DesCbc2*;
 		VAR input, output, key, iv: ARRAY 64 OF CHAR;
 		VAR input, output, key, iv: ARRAY 64 OF CHAR;
 	BEGIN
 	BEGIN
-		key := "0123456789ABCDEF";		
+		key := "0123456789ABCDEF";
 		iv := "0123456789ABCDEF";
 		iv := "0123456789ABCDEF";
 		input := "4E6F772069732074";		output := "96C3D4A6DC1C0117";
 		input := "4E6F772069732074";		output := "96C3D4A6DC1C0117";
 		Cbc2( "CryptoDES", input, output, key, iv, 8, 64 );
 		Cbc2( "CryptoDES", input, output, key, iv, 8, 64 );
@@ -312,7 +312,7 @@ IMPORT
 	PROCEDURE  IdeaCbc2*;
 	PROCEDURE  IdeaCbc2*;
 		VAR input, output, key, iv: ARRAY 64 OF CHAR;
 		VAR input, output, key, iv: ARRAY 64 OF CHAR;
 	BEGIN
 	BEGIN
-		key := "00010002000300040005000600070008";		
+		key := "00010002000300040005000600070008";
 		iv := "0000000000000000";
 		iv := "0000000000000000";
 		input := "0000000100020003";		output := "11FBED2B01986DE5";
 		input := "0000000100020003";		output := "11FBED2B01986DE5";
 		Cbc2( "CryptoIDEA", input, output, key, iv, 8, 128 );
 		Cbc2( "CryptoIDEA", input, output, key, iv, 8, 128 );
@@ -321,21 +321,21 @@ IMPORT
 	PROCEDURE  AesCbc2*;
 	PROCEDURE  AesCbc2*;
 		VAR input, output, key, iv: ARRAY 256 OF CHAR;
 		VAR input, output, key, iv: ARRAY 256 OF CHAR;
 	BEGIN
 	BEGIN
-		key := "2b7e151628aed2a6abf7158809cf4f3c";		
+		key := "2b7e151628aed2a6abf7158809cf4f3c";
 		iv := "000102030405060708090A0B0C0D0E0F";
 		iv := "000102030405060708090A0B0C0D0E0F";
-		input := "6bc1bee22e409f96e93d7e117393172a";		
+		input := "6bc1bee22e409f96e93d7e117393172a";
 		output := "7649abac8119b246cee98e9b12e9197d";
 		output := "7649abac8119b246cee98e9b12e9197d";
 		Cbc2( "CryptoAES", input, output, key, iv, 16, 128 );
 		Cbc2( "CryptoAES", input, output, key, iv, 16, 128 );
-		
+
 		key := "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4";
 		key := "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4";
 		iv := "000102030405060708090A0B0C0D0E0F";
 		iv := "000102030405060708090A0B0C0D0E0F";
 		input := "6bc1bee22e409f96e93d7e117393172a";
 		input := "6bc1bee22e409f96e93d7e117393172a";
 		output := "f58c4c04d6e5f1ba779eabfb5f7bfbd6";
 		output := "f58c4c04d6e5f1ba779eabfb5f7bfbd6";
 		Cbc2( "CryptoAES", input, output, key, iv, 16, 256 );
 		Cbc2( "CryptoAES", input, output, key, iv, 16, 256 );
 
 
-		key := "2b7e151628aed2a6abf7158809cf4f3c";		
+		key := "2b7e151628aed2a6abf7158809cf4f3c";
 		iv := "000102030405060708090A0B0C0D0E0F";
 		iv := "000102030405060708090A0B0C0D0E0F";
-		output := "6bc1bee22e409f96e93d7e117393172a";		
+		output := "6bc1bee22e409f96e93d7e117393172a";
 		input := "7649abac8119b246cee98e9b12e9197d";
 		input := "7649abac8119b246cee98e9b12e9197d";
 		DecryptCbc2( "CryptoAES", input, output, key, iv, 16, 128 );
 		DecryptCbc2( "CryptoAES", input, output, key, iv, 16, 128 );
 
 
@@ -345,16 +345,16 @@ IMPORT
 		input := "f58c4c04d6e5f1ba779eabfb5f7bfbd6";
 		input := "f58c4c04d6e5f1ba779eabfb5f7bfbd6";
 		DecryptCbc2( "CryptoAES", input, output, key, iv, 16, 256 );
 		DecryptCbc2( "CryptoAES", input, output, key, iv, 16, 256 );
 	END AesCbc2;
 	END AesCbc2;
-	
+
 	PROCEDURE  AesCtr2*;
 	PROCEDURE  AesCtr2*;
 		VAR input, output, key, iv: ARRAY 256 OF CHAR;
 		VAR input, output, key, iv: ARRAY 256 OF CHAR;
 	BEGIN
 	BEGIN
-		key := "2b7e151628aed2a6abf7158809cf4f3c";		
+		key := "2b7e151628aed2a6abf7158809cf4f3c";
 		iv := "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff";
 		iv := "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff";
-		input := "6bc1bee22e409f96e93d7e117393172a";		
+		input := "6bc1bee22e409f96e93d7e117393172a";
 		output := "874d6191b620e3261bef6864990db6ce";
 		output := "874d6191b620e3261bef6864990db6ce";
 		Ctr2( "CryptoAES", input, output, key, iv, 16, 128 );
 		Ctr2( "CryptoAES", input, output, key, iv, 16, 128 );
-		
+
 		key := "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4";
 		key := "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4";
 		iv := "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff";
 		iv := "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff";
 		input := "6bc1bee22e409f96e93d7e117393172a";
 		input := "6bc1bee22e409f96e93d7e117393172a";
@@ -390,7 +390,7 @@ IMPORT
 		cipher.SetIV( iv, Ciphers.CBC );
 		cipher.SetIV( iv, Ciphers.CBC );
 		cipher.Decrypt( bindata, 0, 2 * cipher.blockSize );
 		cipher.Decrypt( bindata, 0, 2 * cipher.blockSize );
 		Out.Ln; Out.String( "Decrypted: " ); U.PrintHex( bindata, 0, 2 * cipher.blockSize );
 		Out.Ln; Out.String( "Decrypted: " ); U.PrintHex( bindata, 0, 2 * cipher.blockSize );
-		bindata[2 * cipher.blockSize] := 0X; 
+		bindata[2 * cipher.blockSize] := 0X;
 		Out.Ln;
 		Out.Ln;
 		IF bindata = orig THEN  Out.String( "OK" )  ELSE  Out.String( "FAIL" )  END;
 		IF bindata = orig THEN  Out.String( "OK" )  ELSE  Out.String( "FAIL" )  END;
 		Out.Ln
 		Out.Ln
@@ -398,8 +398,8 @@ IMPORT
 END CryptoTestCiphers.
 END CryptoTestCiphers.
 
 
 
 
-     System.Free  
-     		CryptoTestCiphers CryptoDES3 CryptoDES CryptoIDEA 
+     System.Free
+     		CryptoTestCiphers CryptoDES3 CryptoDES CryptoIDEA
      		CryptoARC4  CryptoCAST CryptoAES ~
      		CryptoARC4  CryptoCAST CryptoAES ~
 
 
      CryptoTestCiphers.DesEcb2 ~
      CryptoTestCiphers.DesEcb2 ~
@@ -414,10 +414,10 @@ END CryptoTestCiphers.
      CryptoTestCiphers.DesCbc2 ~
      CryptoTestCiphers.DesCbc2 ~
      CryptoTestCiphers.IdeaCbc2 ~
      CryptoTestCiphers.IdeaCbc2 ~
      CryptoTestCiphers.AesCbc2 ~
      CryptoTestCiphers.AesCbc2 ~
-     
+
      CryptoTestCiphers.AesCtr2 ~
      CryptoTestCiphers.AesCtr2 ~
-     
-     
+
+
 
 
      CryptoTestCiphers.Ecb1	CryptoDES	64 ~
      CryptoTestCiphers.Ecb1	CryptoDES	64 ~
      CryptoTestCiphers.Ecb1	CryptoDES3	192 ~
      CryptoTestCiphers.Ecb1	CryptoDES3	192 ~
@@ -434,7 +434,7 @@ END CryptoTestCiphers.
      CryptoTestCiphers.Cbc1	CryptoAES 128 ~
      CryptoTestCiphers.Cbc1	CryptoAES 128 ~
      CryptoTestCiphers.Cbc1	CryptoAES 256 ~
      CryptoTestCiphers.Cbc1	CryptoAES 256 ~
      CryptoTestCiphers.Cbc1	CryptoBlowfish 256 ~
      CryptoTestCiphers.Cbc1	CryptoBlowfish 256 ~
-     
+
      CryptoTestCiphers.CbcRandom CryptoDES	64 ~
      CryptoTestCiphers.CbcRandom CryptoDES	64 ~
      CryptoTestCiphers.CbcRandom CryptoDES3	192 ~
      CryptoTestCiphers.CbcRandom CryptoDES3	192 ~
      CryptoTestCiphers.CbcRandom CryptoIDEA	128 ~
      CryptoTestCiphers.CbcRandom CryptoIDEA	128 ~
@@ -445,7 +445,7 @@ END CryptoTestCiphers.
      CryptoTestCiphers.Ctr1		CryptoAES	128 ~
      CryptoTestCiphers.Ctr1		CryptoAES	128 ~
      CryptoTestCiphers.Ctr1		CryptoAES	256 ~
      CryptoTestCiphers.Ctr1		CryptoAES	256 ~
 
 
-     
+
      CryptoTestCiphers.MeasureTime	CryptoDES	ECB 64 ~
      CryptoTestCiphers.MeasureTime	CryptoDES	ECB 64 ~
      CryptoTestCiphers.MeasureTime	CryptoDES	CBC 64 ~
      CryptoTestCiphers.MeasureTime	CryptoDES	CBC 64 ~
      CryptoTestCiphers.MeasureTime	CryptoDES3	ECB 192 ~
      CryptoTestCiphers.MeasureTime	CryptoDES3	ECB 192 ~
@@ -457,4 +457,4 @@ END CryptoTestCiphers.
      CryptoTestCiphers.MeasureTime	CryptoARC4	ECB 128 ~
      CryptoTestCiphers.MeasureTime	CryptoARC4	ECB 128 ~
 
 
 
 
-	
+

+ 1 - 1
source/CryptoTestDH.Mod

@@ -51,7 +51,7 @@ IMPORT D := CryptoDiffieHellman, B := CryptoBigNumbers, Kernel, Out := KernelLog
 	BEGIN
 	BEGIN
 		Do( "dh.ssh.group1" )
 		Do( "dh.ssh.group1" )
 	END SSH;
 	END SSH;
-	
+
 	PROCEDURE SSL2048*;
 	PROCEDURE SSL2048*;
 	BEGIN
 	BEGIN
 		Do( "dh.2048.MODP.256"  )
 		Do( "dh.2048.MODP.256"  )

+ 17 - 17
source/CryptoTestHashes.Mod

@@ -50,10 +50,10 @@ IMPORT
 	PROCEDURE TestMD5*;
 	PROCEDURE TestMD5*;
 	BEGIN
 	BEGIN
 		CheckHash( "CryptoMD5", "", "D41D8CD98F00B204E9800998ECF8427E" );
 		CheckHash( "CryptoMD5", "", "D41D8CD98F00B204E9800998ECF8427E" );
-		CheckHash( "CryptoMD5", 
-						"abc", 
+		CheckHash( "CryptoMD5",
+						"abc",
 						"900150983CD24FB0D6963F7D28E17F72" );
 						"900150983CD24FB0D6963F7D28E17F72" );
-		CheckHash( "CryptoMD5", 
+		CheckHash( "CryptoMD5",
 						"abcdefghijklmnopqrstuvwxyz",
 						"abcdefghijklmnopqrstuvwxyz",
 						"C3FCD3D76192E4007DFB496CCA67E13B");
 						"C3FCD3D76192E4007DFB496CCA67E13B");
 		MeasureTime( "CryptoMD5" );
 		MeasureTime( "CryptoMD5" );
@@ -63,7 +63,7 @@ IMPORT
 	BEGIN
 	BEGIN
 		CheckHash( "CryptoSHA1", "", "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709" );
 		CheckHash( "CryptoSHA1", "", "DA39A3EE5E6B4B0D3255BFEF95601890AFD80709" );
 		CheckHash( "CryptoSHA1", "abc", "A9993E364706816ABA3E25717850C26C9CD0D89D" );
 		CheckHash( "CryptoSHA1", "abc", "A9993E364706816ABA3E25717850C26C9CD0D89D" );
-		CheckHash( "CryptoSHA1", 
+		CheckHash( "CryptoSHA1",
 						"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
 						"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
 						"84983E441C3BD26EBAAE4AA1F95129E5E54670F1");
 						"84983E441C3BD26EBAAE4AA1F95129E5E54670F1");
 		MeasureTime( "CryptoSHA1" );
 		MeasureTime( "CryptoSHA1" );
@@ -71,10 +71,10 @@ IMPORT
 
 
 	PROCEDURE TestSHA256*;
 	PROCEDURE TestSHA256*;
 	BEGIN
 	BEGIN
-		CheckHash( "CryptoSHA256", 
-				"abc", 
+		CheckHash( "CryptoSHA256",
+				"abc",
 				"BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD" );
 				"BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD" );
-		CheckHash( "CryptoSHA256", 
+		CheckHash( "CryptoSHA256",
 				"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
 				"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
 				"248D6A61D20638B8E5C026930C3E6039A33CE45964FF2167F6ECEDD419DB06C1" );
 				"248D6A61D20638B8E5C026930C3E6039A33CE45964FF2167F6ECEDD419DB06C1" );
 		MeasureTime( "CryptoSHA256" );
 		MeasureTime( "CryptoSHA256" );
@@ -82,25 +82,25 @@ IMPORT
 
 
 	PROCEDURE TestSHA3*;
 	PROCEDURE TestSHA3*;
 	BEGIN
 	BEGIN
-		CheckHash( "CryptoSHA3", 
-				"", 
+		CheckHash( "CryptoSHA3",
+				"",
 				"a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a" );
 				"a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a" );
-		CheckHash( "CryptoSHA3", 
-				"abc", 
+		CheckHash( "CryptoSHA3",
+				"abc",
 				"3a985da74fe225b2045c172d6bd390bd855f086e3e9d525b46bfe24511431532" );
 				"3a985da74fe225b2045c172d6bd390bd855f086e3e9d525b46bfe24511431532" );
-		CheckHash( "CryptoSHA3", 
+		CheckHash( "CryptoSHA3",
 				"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
 				"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
 				"41c0dba2a9d6240849100376a8235e2c82e1b9998a999e21db32dd97496d3376" );
 				"41c0dba2a9d6240849100376a8235e2c82e1b9998a999e21db32dd97496d3376" );
-		MeasureTime( "CryptoSHA3" );	
+		MeasureTime( "CryptoSHA3" );
 	END TestSHA3;
 	END TestSHA3;
 
 
 END CryptoTestHashes.
 END CryptoTestHashes.
 
 
 
 
-System.Free 
-	CryptoTestHashes 
-	CryptoSHA3 CryptoKeccakSponge CryptoKeccakF1600 
-	CryptoMD5 CryptoSHA1 CryptoSHA256 
+System.Free
+	CryptoTestHashes
+	CryptoSHA3 CryptoKeccakSponge CryptoKeccakF1600
+	CryptoMD5 CryptoSHA1 CryptoSHA256
 	CryptoHashes
 	CryptoHashes
 	~
 	~
 
 

+ 1 - 1
source/CryptoTools.Mod

@@ -63,6 +63,6 @@ IMPORT
 			context.error.Ln
 			context.error.Ln
 		END
 		END
 	END Hash;
 	END Hash;
-	
+
 
 
 END CryptoTools.
 END CryptoTools.

+ 15 - 15
source/CryptoTwofish.Mod

@@ -105,9 +105,9 @@ TYPE
 				VAR x0, x: Block;  t0, t1, i, r: LONGINT;  s0, s1: SET32;
 				VAR x0, x: Block;  t0, t1, i, r: LONGINT;  s0, s1: SET32;
 				BEGIN
 				BEGIN
 					(* copy in the block, add whitening *)
 					(* copy in the block, add whitening *)
-					FOR i := 0 TO 3 DO  
-						x0[i] := U.SetFromBufferLE( buf, pos + i*4 );  
-						x[i] := x0[i] / S.VAL( SET32, subkeys[4 + i] );   
+					FOR i := 0 TO 3 DO
+						x0[i] := U.SetFromBufferLE( buf, pos + i*4 );
+						x[i] := x0[i] / S.VAL( SET32, subkeys[4 + i] );
 					END;
 					END;
 					(* main Twofish decryption loop *)
 					(* main Twofish decryption loop *)
 					FOR r := N - 1 TO 0 BY -1 DO
 					FOR r := N - 1 TO 0 BY -1 DO
@@ -150,8 +150,8 @@ CONST
 	Byte0 = S.VAL( SET32, 0FFH );
 	Byte0 = S.VAL( SET32, 0FFH );
 	S14d = S.VAL( SET32, 14DH );
 	S14d = S.VAL( SET32, 14DH );
 	S0a6 = S.VAL( SET32, 0A6H );
 	S0a6 = S.VAL( SET32, 0A6H );
-	
-	
+
+
 	PROCEDURE m1( x: LONGINT ): SET32;
 	PROCEDURE m1( x: LONGINT ): SET32;
 	BEGIN
 	BEGIN
 		RETURN S.VAL( SET32, x )
 		RETURN S.VAL( SET32, x )
@@ -182,12 +182,12 @@ CONST
 		v[1] := S.VAL( SET32, x DIV 100H MOD 100H );
 		v[1] := S.VAL( SET32, x DIV 100H MOD 100H );
 		v[0] := S.VAL( SET32, x MOD 100H );
 		v[0] := S.VAL( SET32, x MOD 100H );
 	END split;
 	END split;
-	
+
 	PROCEDURE -Int( x: SET32 ): LONGINT;
 	PROCEDURE -Int( x: SET32 ): LONGINT;
 	BEGIN
 	BEGIN
 		RETURN S.VAL( LONGINT, x )
 		RETURN S.VAL( LONGINT, x )
 	END Int;
 	END Int;
-	
+
 
 
 	PROCEDURE F32( x: SET32;  CONST k32: ARRAY OF LONGINT;  keybits: LONGINT ): LONGINT;
 	PROCEDURE F32( x: SET32;  CONST k32: ARRAY OF LONGINT;  keybits: LONGINT ): LONGINT;
 	VAR a, b, c, d, l: LONGINT;  k, k1: SKey;
 	VAR a, b, c, d, l: LONGINT;  k, k1: SKey;
@@ -201,21 +201,21 @@ CONST
 
 
 		l := ((keybits + 63) DIV 64) MOD 4;
 		l := ((keybits + 63) DIV 64) MOD 4;
 		IF l = 0 THEN  (* 256 bits of key *)
 		IF l = 0 THEN  (* 256 bits of key *)
-			split( k32[3], k );  
-			a := Int( tab1[a] / k[0] );  
-			b := Int( tab0[b] / k[1] );  
+			split( k32[3], k );
+			a := Int( tab1[a] / k[0] );
+			b := Int( tab0[b] / k[1] );
 			c := Int( tab0[c] / k[2] );
 			c := Int( tab0[c] / k[2] );
 			d := Int( tab1[d] / k[3] );
 			d := Int( tab1[d] / k[3] );
 		END;
 		END;
 		IF l IN {0, 3} THEN  (* 192 <= bits of key *)
 		IF l IN {0, 3} THEN  (* 192 <= bits of key *)
-			split( k32[2], k );  
+			split( k32[2], k );
 			a := Int( tab1[a] / k[0] );
 			a := Int( tab1[a] / k[0] );
 			b := Int( tab1[b] / k[1] );
 			b := Int( tab1[b] / k[1] );
 			c := Int( tab0[c] / k[2] );
 			c := Int( tab0[c] / k[2] );
 			d := Int( tab0[d] / k[3] )
 			d := Int( tab0[d] / k[3] )
 		END;
 		END;
 		(* 128 <= bits of key *)
 		(* 128 <= bits of key *)
-		split( k32[1], k1 );  split( k32[0], k );  
+		split( k32[1], k1 );  split( k32[0], k );
 		a := Int( tab1[Int( tab0[Int( tab0[a] / k1[0] )] / k[0] )] );
 		a := Int( tab1[Int( tab0[Int( tab0[a] / k1[0] )] / k[0] )] );
 		b := Int( tab0[Int( tab0[Int( tab1[b] / k1[1] )] / k[1] )] );
 		b := Int( tab0[Int( tab0[Int( tab1[b] / k1[1] )] / k[1] )] );
 		c := Int( tab1[Int( tab1[Int( tab0[c] / k1[2] )] / k[2] )] );
 		c := Int( tab1[Int( tab1[Int( tab0[c] / k1[2] )] / k[2] )] );
@@ -247,7 +247,7 @@ CONST
 				g3s8 := LSH( g3, 8 );
 				g3s8 := LSH( g3, 8 );
 				g3s24 := LSH( g3s8, 16 );
 				g3s24 := LSH( g3s8, 16 );
 
 
-				r := LSH( r, 8 ) / g3s24 / g2s16 / g3s8 / S.VAL( SET32, b ) 
+				r := LSH( r, 8 ) / g3s24 / g2s16 / g3s8 / S.VAL( SET32, b )
 			END
 			END
 		END;
 		END;
 		RETURN S.VAL( LONGINT, r )
 		RETURN S.VAL( LONGINT, r )
@@ -296,8 +296,8 @@ CONST
 		buf.Add( "022 0C9 0C0 09B 089 0D4 0ED 0AB 012 0A2 00D 052 0BB 002 02F 0A9 " );
 		buf.Add( "022 0C9 0C0 09B 089 0D4 0ED 0AB 012 0A2 00D 052 0BB 002 02F 0A9 " );
 		buf.Add( "0D7 061 01E 0B4 050 004 0F6 0C2 016 025 086 056 055 009 0BE 091 " );
 		buf.Add( "0D7 061 01E 0B4 050 004 0F6 0C2 016 025 086 056 055 009 0BE 091 " );
 		FOR i := 0 TO 255 DO  tab1[i] :=  buf.GetSet()  END;
 		FOR i := 0 TO 255 DO  tab1[i] :=  buf.GetSet()  END;
-	END Init0;	
-		
+	END Init0;
+
 BEGIN
 BEGIN
 	Init0
 	Init0
 END CryptoTwofish.
 END CryptoTwofish.

+ 18 - 18
source/CryptoUtils.Mod

@@ -3,28 +3,28 @@ MODULE CryptoUtils; (** AUTHOR "GF"; PURPOSE ""; *)
 IMPORT S := SYSTEM, Out := KernelLog, Random, Kernel, B := CryptoBigNumbers;
 IMPORT S := SYSTEM, Out := KernelLog, Random, Kernel, B := CryptoBigNumbers;
 
 
 
 
-TYPE 
+TYPE
 	InitBuffer* = OBJECT	(**   buffer supporting initialization of large tables with hex values  *)
 	InitBuffer* = OBJECT	(**   buffer supporting initialization of large tables with hex values  *)
-	VAR 
+	VAR
 		buf: POINTER TO ARRAY OF CHAR;
 		buf: POINTER TO ARRAY OF CHAR;
 		in, out: LONGINT;
 		in, out: LONGINT;
-		
+
 		PROCEDURE & Init*( size: LONGINT );
 		PROCEDURE & Init*( size: LONGINT );
 		BEGIN
 		BEGIN
 			NEW( buf, size );  in := 0;  out := 0;
 			NEW( buf, size );  in := 0;  out := 0;
 		END Init;
 		END Init;
-		
+
 		PROCEDURE Add*( CONST x: ARRAY OF CHAR );
 		PROCEDURE Add*( CONST x: ARRAY OF CHAR );
 		VAR  i: LONGINT;  c: CHAR;
 		VAR  i: LONGINT;  c: CHAR;
 		BEGIN
 		BEGIN
 			c := x[0];  i := 1;
 			c := x[0];  i := 1;
-			WHILE c # 0X DO 
+			WHILE c # 0X DO
 				buf[in] := c;  INC( in );  c := x[i];  INC( i )
 				buf[in] := c;  INC( in );  c := x[i];  INC( i )
 			END;
 			END;
 			buf[in] := ' ';  INC( in );  buf[in] := 0X
 			buf[in] := ' ';  INC( in );  buf[in] := 0X
 		END Add;
 		END Add;
-		
-		
+
+
 		PROCEDURE GetInt*( ): LONGINT;
 		PROCEDURE GetInt*( ): LONGINT;
 		VAR x: LONGINT; c: CHAR;
 		VAR x: LONGINT; c: CHAR;
 		BEGIN
 		BEGIN
@@ -40,12 +40,12 @@ TYPE
 			UNTIL c <= ' ';
 			UNTIL c <= ' ';
 			RETURN x
 			RETURN x
 		END GetInt;
 		END GetInt;
-		
+
 		PROCEDURE GetSet*(): SET32;
 		PROCEDURE GetSet*(): SET32;
 		BEGIN
 		BEGIN
 			RETURN S.VAL( SET32, GetInt() )
 			RETURN S.VAL( SET32, GetInt() )
 		END GetSet;
 		END GetSet;
-		
+
 	END InitBuffer
 	END InitBuffer
 
 
 
 
@@ -272,8 +272,8 @@ VAR
 			INC( a, 4 );  INC( pos, 4 )
 			INC( a, 4 );  INC( pos, 4 )
 		END
 		END
 	END BufferToBlockBE;
 	END BufferToBlockBE;
-	
-	
+
+
 	(* copy char buffer to 32-bit words in block. little endian format *)
 	(* copy char buffer to 32-bit words in block. little endian format *)
 	PROCEDURE BufferToBlockLE*( CONST buf: ARRAY OF CHAR;  pos: LONGINT;  VAR block: ARRAY OF S.BYTE );
 	PROCEDURE BufferToBlockLE*( CONST buf: ARRAY OF CHAR;  pos: LONGINT;  VAR block: ARRAY OF S.BYTE );
 	VAR i: LONGINT;  a: ADDRESS;
 	VAR i: LONGINT;  a: ADDRESS;
@@ -318,7 +318,7 @@ VAR
 			INC( pos, 4 )
 			INC( pos, 4 )
 		END
 		END
 	END BlockToBufferLE;
 	END BlockToBufferLE;
-	
+
 	PROCEDURE SetToBufferBE*( val: SET32;  VAR buf: ARRAY OF CHAR;  pos: LONGINT );
 	PROCEDURE SetToBufferBE*( val: SET32;  VAR buf: ARRAY OF CHAR;  pos: LONGINT );
 	BEGIN
 	BEGIN
 		IntToBufferBE( S.VAL( LONGINT, val ), buf, pos );
 		IntToBufferBE( S.VAL( LONGINT, val ), buf, pos );
@@ -331,12 +331,12 @@ VAR
 		buf[pos + 1] := CHR( val MOD 256 );  val := val DIV 256;
 		buf[pos + 1] := CHR( val MOD 256 );  val := val DIV 256;
 		buf[pos + 0] := CHR( val MOD 256 );
 		buf[pos + 0] := CHR( val MOD 256 );
 	END IntToBufferBE;
 	END IntToBufferBE;
-	
+
 	PROCEDURE SetToBufferLE*( val: SET32;  VAR buf: ARRAY OF CHAR;  pos: LONGINT );
 	PROCEDURE SetToBufferLE*( val: SET32;  VAR buf: ARRAY OF CHAR;  pos: LONGINT );
 	BEGIN
 	BEGIN
 		IntToBufferLE( S.VAL( LONGINT, val ), buf, pos );
 		IntToBufferLE( S.VAL( LONGINT, val ), buf, pos );
 	END SetToBufferLE;
 	END SetToBufferLE;
-	
+
 	PROCEDURE IntToBufferLE*( val: LONGINT;  VAR buf: ARRAY OF CHAR;  pos: LONGINT );
 	PROCEDURE IntToBufferLE*( val: LONGINT;  VAR buf: ARRAY OF CHAR;  pos: LONGINT );
 	BEGIN
 	BEGIN
 		buf[pos + 0] := CHR( val MOD 256 );  val := val DIV 256;
 		buf[pos + 0] := CHR( val MOD 256 );  val := val DIV 256;
@@ -344,13 +344,13 @@ VAR
 		buf[pos + 2] := CHR( val MOD 256 );  val := val DIV 256;
 		buf[pos + 2] := CHR( val MOD 256 );  val := val DIV 256;
 		buf[pos + 3] := CHR( val MOD 256 );
 		buf[pos + 3] := CHR( val MOD 256 );
 	END IntToBufferLE;
 	END IntToBufferLE;
-	
-	
+
+
 	PROCEDURE SetFromBufferBE*( CONST buf: ARRAY OF CHAR;  pos: LONGINT ): SET32;
 	PROCEDURE SetFromBufferBE*( CONST buf: ARRAY OF CHAR;  pos: LONGINT ): SET32;
 	BEGIN
 	BEGIN
 		RETURN  S.VAL( SET32, IntFromBufferBE( buf, pos ) )
 		RETURN  S.VAL( SET32, IntFromBufferBE( buf, pos ) )
 	END SetFromBufferBE;
 	END SetFromBufferBE;
-	
+
 	PROCEDURE IntFromBufferBE*( CONST buf: ARRAY OF CHAR;  pos: LONGINT ): LONGINT;
 	PROCEDURE IntFromBufferBE*( CONST buf: ARRAY OF CHAR;  pos: LONGINT ): LONGINT;
 	BEGIN
 	BEGIN
 		RETURN	ASH( LONG( ORD( buf[pos + 0] ) ), 24 ) +
 		RETURN	ASH( LONG( ORD( buf[pos + 0] ) ), 24 ) +
@@ -372,7 +372,7 @@ VAR
 					ASH( LONG( ORD( buf[pos + 1] ) ), 8 ) +
 					ASH( LONG( ORD( buf[pos + 1] ) ), 8 ) +
 					ORD( buf[pos] );
 					ORD( buf[pos] );
 	END IntFromBufferLE;
 	END IntFromBufferLE;
-	
+
 
 
 
 
 BEGIN
 BEGIN

+ 1 - 1
source/DTPData.Mod

@@ -1471,4 +1471,4 @@ BEGIN
 END NewObject;
 END NewObject;
 
 
 
 
-END DTPData.	
+END DTPData.

+ 61 - 61
source/Darwin.Unix.Mod

@@ -76,7 +76,7 @@ CONST
 	rdonly* = SET32({});  rdwr* = SET32({1});  creat* = SET32({6});  trunc* = SET32({9});
 	rdonly* = SET32({});  rdwr* = SET32({1});  creat* = SET32({6});  trunc* = SET32({9});
 
 
 	(* access modes *)
 	(* access modes *)
-	rwrwr* = 1B4H;  rwxrwxrwx* = 1FFH;  
+	rwrwr* = 1B4H;  rwxrwxrwx* = 1FFH;
 
 
 	F_OK* = {};  X_Ok* = {0};  W_OK* = {1};  R_OK* = {2};
 	F_OK* = {};  X_Ok* = {0};  W_OK* = {1};  R_OK* = {2};
 
 
@@ -121,7 +121,7 @@ CONST
 	SIG_BLOCK		= 1;
 	SIG_BLOCK		= 1;
 	SIG_UNBLOCK	= 2;
 	SIG_UNBLOCK	= 2;
 	SIG_SETMASK	= 3;
 	SIG_SETMASK	= 3;
-	
+
 	SA_ONSTACK		= 0x0001;	(* take signal on signal stack *)
 	SA_ONSTACK		= 0x0001;	(* take signal on signal stack *)
 	SA_RESTART		= 0x0002;	(* restart system on signal return *)
 	SA_RESTART		= 0x0002;	(* restart system on signal return *)
 	SA_RESETHAND	= 0x0004;	(* reset to SIG_DFL when taking signal *)
 	SA_RESETHAND	= 0x0004;	(* reset to SIG_DFL when taking signal *)
@@ -132,13 +132,13 @@ CONST
 
 
 	PTHREAD_CREATE_JOINABLE	= 1;
 	PTHREAD_CREATE_JOINABLE	= 1;
 	PTHREAD_CREATE_DETACHED	= 2;
 	PTHREAD_CREATE_DETACHED	= 2;
-	
+
 	PTHREAD_CANCEL_ENABLE 	= 1;
 	PTHREAD_CANCEL_ENABLE 	= 1;
 	PTHREAD_CANCEL_DISABLE	= 0;
 	PTHREAD_CANCEL_DISABLE	= 0;
 
 
 	PTHREAD_CANCEL_ASYNCHRONOUS	= 0;
 	PTHREAD_CANCEL_ASYNCHRONOUS	= 0;
 	PTHREAD_CANCEL_DEFERRED	= 2;
 	PTHREAD_CANCEL_DEFERRED	= 2;
-	
+
 	PTHREAD_SCOPE_SYSTEM		= 1;
 	PTHREAD_SCOPE_SYSTEM		= 1;
 	PTHREAD_SCOPE_PROCESS	= 2;
 	PTHREAD_SCOPE_PROCESS	= 2;
 
 
@@ -146,7 +146,7 @@ CONST
 
 
 TYPE
 TYPE
 	MachPort = LONGINT;
 	MachPort = LONGINT;
-	
+
 	Thread_t* = ADDRESS;
 	Thread_t* = ADDRESS;
 	Mutex_t* = ADDRESS;
 	Mutex_t* = ADDRESS;
 	Condition_t* = ADDRESS;
 	Condition_t* = ADDRESS;
@@ -156,7 +156,7 @@ TYPE
 	MutexType			= ARRAY 44 OF CHAR;
 	MutexType			= ARRAY 44 OF CHAR;
 	MutexAttributeType	= ARRAY 12 OF CHAR;
 	MutexAttributeType	= ARRAY 12 OF CHAR;
 	ConditionType		= ARRAY 28 OF CHAR;
 	ConditionType		= ARRAY 28 OF CHAR;
-#ELSIF AMD64 THEN	
+#ELSIF AMD64 THEN
 	PThreadAttrType		= ARRAY 64 OF CHAR;
 	PThreadAttrType		= ARRAY 64 OF CHAR;
 	MutexType			= ARRAY 64 OF CHAR;
 	MutexType			= ARRAY 64 OF CHAR;
 	MutexAttributeType	= ARRAY 16 OF CHAR;
 	MutexAttributeType	= ARRAY 16 OF CHAR;
@@ -166,10 +166,10 @@ TYPE
 #END
 #END
 
 
 	Key_t* = ADDRESS;
 	Key_t* = ADDRESS;
-	
+
 	Sigset = ARRAY 4 OF CHAR;
 	Sigset = ARRAY 4 OF CHAR;
 	SignalTrap = PROCEDURE ( sig: LONGINT; mc: Mcontext );
 	SignalTrap = PROCEDURE ( sig: LONGINT; mc: Mcontext );
-	
+
 	path_t*	= ARRAY OF CHAR;
 	path_t*	= ARRAY OF CHAR;
 	arg_t*		= ARRAY OF CHAR;
 	arg_t*		= ARRAY OF CHAR;
 	argv_t*	= ARRAY OF arg_t;
 	argv_t*	= ARRAY OF arg_t;
@@ -177,7 +177,7 @@ TYPE
 
 
 CONST
 CONST
 	(* Thread priorities *)
 	(* Thread priorities *)
-	ThreadLow* = 15; ThreadNormal* = 20; ThreadHigh* = 47;	
+	ThreadLow* = 15; ThreadNormal* = 20; ThreadHigh* = 47;
 	NumPriorities* = 33;	(* number of priority levels *)
 	NumPriorities* = 33;	(* number of priority levels *)
 
 
 	(*---------------------------- IP -----------------------------------*)
 	(*---------------------------- IP -----------------------------------*)
@@ -186,14 +186,14 @@ CONST
 	(* domain *)
 	(* domain *)
 		AFINET*		= 2;
 		AFINET*		= 2;
 		AFINET6*	= 26;
 		AFINET6*	= 26;
-		
+
 		PFINET*		= AFINET;
 		PFINET*		= AFINET;
 		PFINET6*	= AFINET6;
 		PFINET6*	= AFINET6;
-		
+
 	(* types of connection *)
 	(* types of connection *)
 		SockStream*	= 1;
 		SockStream*	= 1;
 		SockDGram*	= 2;
 		SockDGram*	= 2;
-		
+
 	(* Protocols *)
 	(* Protocols *)
 		IpProtoUDP*		= 17;
 		IpProtoUDP*		= 17;
 		IpProtoTCP*		= 6;
 		IpProtoTCP*		= 6;
@@ -206,27 +206,27 @@ CONST
 
 
 	(* ioctl *)
 	(* ioctl *)
 		FioNRead*		= 4004667FH;	(* something to read ? *)
 		FioNRead*		= 4004667FH;	(* something to read ? *)
-		
-		
+
+
 	(* recv *)
 	(* recv *)
 		MsgPeek*		= 2;
 		MsgPeek*		= 2;
 		MsgDontWait*	= 80H;		(* non blocking read *)
 		MsgDontWait*	= 80H;		(* non blocking read *)
-		
+
 	(* shutdown *)
 	(* shutdown *)
 		ShutRDWR*	= 2;
 		ShutRDWR*	= 2;
 
 
 	SockAddrSizeV4*	= 16;
 	SockAddrSizeV4*	= 16;
 	SockAddrSizeV6*	= 28;
 	SockAddrSizeV6*	= 28;
 
 
-	
+
 	(*-------------------seral line ---------------------------------------*)
 	(*-------------------seral line ---------------------------------------*)
-	
+
 	FIONREAD*		= LONGINT( 4004667FH );
 	FIONREAD*		= LONGINT( 4004667FH );
 	TIOCMGET*		= LONGINT( 4004746AH );
 	TIOCMGET*		= LONGINT( 4004746AH );
 	TIOCMBIC*		= LONGINT( 8004746BH );
 	TIOCMBIC*		= LONGINT( 8004746BH );
 	TIOCMBIS*		= LONGINT( 8004746CH );
 	TIOCMBIS*		= LONGINT( 8004746CH );
 	TIOCMSET*		= LONGINT( 8004746DH );
 	TIOCMSET*		= LONGINT( 8004746DH );
-	
+
 	(* speeds *)
 	(* speeds *)
 	B0*	= 0;
 	B0*	= 0;
 	B50*	= 50;
 	B50*	= 50;
@@ -261,7 +261,7 @@ CONST
 	PARODD*	= {13};	(* odd parity, else even *)
 	PARODD*	= {13};	(* odd parity, else even *)
 	HUPCL*		= {14};	(* hang up on last close *)
 	HUPCL*		= {14};	(* hang up on last close *)
 	CLOCAL*	= {15};	(* ignore modem status lines *)
 	CLOCAL*	= {15};	(* ignore modem status lines *)
-	
+
 TYPE
 TYPE
 	Termios* = RECORD
 	Termios* = RECORD
 		iflags*, oflags*, cflags*, lflags*: SET32;
 		iflags*, oflags*, cflags*, lflags*: SET32;
@@ -357,7 +357,7 @@ TYPE
 
 
 CONST
 CONST
 	FdSetLen* = 32;
 	FdSetLen* = 32;
-	
+
 TYPE
 TYPE
 	FdSet* = ARRAY FdSetLen OF SET;
 	FdSet* = ARRAY FdSetLen OF SET;
 
 
@@ -368,8 +368,8 @@ TYPE
 				namlen-	: SHORTINT;
 				namlen-	: SHORTINT;
 				name-	:  (*array of*) CHAR;
 				name-	:  (*array of*) CHAR;
 			END;
 			END;
-			
-			
+
+
 
 
 	Stack* = RECORD
 	Stack* = RECORD
 				sp*		: ADDRESS;
 				sp*		: ADDRESS;
@@ -384,7 +384,7 @@ TYPE
 				stack-	: Stack;
 				stack-	: Stack;
 				link-		: ADDRESS;	(* Ucontext *)
 				link-		: ADDRESS;	(* Ucontext *)
 				mclen-	: SIZE;
 				mclen-	: SIZE;
-				mc-{UNTRACED}: Mcontext 
+				mc-{UNTRACED}: Mcontext
 			END;
 			END;
 
 
 	Mcontext* = POINTER TO McontextDesc;
 	Mcontext* = POINTER TO McontextDesc;
@@ -393,7 +393,7 @@ TYPE
 				trapno-	: LONGINT;
 				trapno-	: LONGINT;
 				err			: LONGINT;
 				err			: LONGINT;
 				faultvaddr	: ADDRESS;
 				faultvaddr	: ADDRESS;
-				
+
 				r_ax		: ADDRESS;
 				r_ax		: ADDRESS;
 				r_bx		: ADDRESS;
 				r_bx		: ADDRESS;
 				r_cx		: ADDRESS;
 				r_cx		: ADDRESS;
@@ -410,7 +410,7 @@ TYPE
 				r_es		: ADDRESS;
 				r_es		: ADDRESS;
 				r_fs		: ADDRESS;
 				r_fs		: ADDRESS;
 				r_gs		: ADDRESS;
 				r_gs		: ADDRESS;
-				
+
 				flavor		: LONGINT;
 				flavor		: LONGINT;
 				count		: LONGINT;
 				count		: LONGINT;
 				(* ... *)
 				(* ... *)
@@ -419,7 +419,7 @@ TYPE
 				cpu		: INTEGER;
 				cpu		: INTEGER;
 				err			: LONGINT;
 				err			: LONGINT;
 				faultvaddr	: HUGEINT;
 				faultvaddr	: HUGEINT;
-				
+
 				r_ax		: HUGEINT;
 				r_ax		: HUGEINT;
 				r_bx		: HUGEINT;
 				r_bx		: HUGEINT;
  				r_cx		: HUGEINT;
  				r_cx		: HUGEINT;
@@ -446,13 +446,13 @@ TYPE
 			#END
 			#END
 		END;
 		END;
 
 
-	Sigaction = RECORD	
+	Sigaction = RECORD
 		sa_handler: ADDRESS;
 		sa_handler: ADDRESS;
 		sa_mask: Sigset;
 		sa_mask: Sigset;
 		sa_flags: LONGINT;
 		sa_flags: LONGINT;
 	END;
 	END;
 
 
-	Sched_param = RECORD	
+	Sched_param = RECORD
 		sched_priority: LONGINT;
 		sched_priority: LONGINT;
 		safety: ARRAY 8 OF LONGINT;
 		safety: ARRAY 8 OF LONGINT;
 	END;
 	END;
@@ -491,7 +491,7 @@ VAR
 	pthread_kill		: PROCEDURE {C} (thr: ADDRESS; sigid: LONGINT): LONGINT;
 	pthread_kill		: PROCEDURE {C} (thr: ADDRESS; sigid: LONGINT): LONGINT;
 	pthread_cancel	: PROCEDURE {C} (thr: ADDRESS);
 	pthread_cancel	: PROCEDURE {C} (thr: ADDRESS);
 	pthread_self		: PROCEDURE {C} (): Thread_t;
 	pthread_self		: PROCEDURE {C} (): Thread_t;
-	
+
 	pthread_key_create	: PROCEDURE {C} ( key: ADDRESS; destructor: PROCEDURE {C} ( param: ADDRESS ) ): WORD;
 	pthread_key_create	: PROCEDURE {C} ( key: ADDRESS; destructor: PROCEDURE {C} ( param: ADDRESS ) ): WORD;
 	pthread_setspecific	: PROCEDURE {C} ( key: Key_t; value: ADDRESS ): WORD;
 	pthread_setspecific	: PROCEDURE {C} ( key: Key_t; value: ADDRESS ): WORD;
 	pthread_getspecific	: PROCEDURE {C} ( key: Key_t ): ADDRESS;
 	pthread_getspecific	: PROCEDURE {C} ( key: Key_t ): ADDRESS;
@@ -500,21 +500,21 @@ VAR
 	pthread_attr_setscope			: PROCEDURE {C} ( attr: ADDRESS; set: WORD );
 	pthread_attr_setscope			: PROCEDURE {C} ( attr: ADDRESS; set: WORD );
 	pthread_attr_setdetachstate	: PROCEDURE {C} ( attr: ADDRESS; set: WORD );
 	pthread_attr_setdetachstate	: PROCEDURE {C} ( attr: ADDRESS; set: WORD );
 	pthread_attr_setstacksize		: PROCEDURE {C} ( attr: ADDRESS; stackSize: SIZE );
 	pthread_attr_setstacksize		: PROCEDURE {C} ( attr: ADDRESS; stackSize: SIZE );
-	
+
 	pthread_mach_thread_np: PROCEDURE {C} ( thr: Thread_t ): MachPort;
 	pthread_mach_thread_np: PROCEDURE {C} ( thr: Thread_t ): MachPort;
-	
+
 	thread_suspend:	PROCEDURE {C} ( mthr: MachPort );
 	thread_suspend:	PROCEDURE {C} ( mthr: MachPort );
 	thread_resume:	PROCEDURE {C} ( mthr: MachPort );
 	thread_resume:	PROCEDURE {C} ( mthr: MachPort );
-	
+
 	sched_get_priority_max		: PROCEDURE {C} ( policy: LONGINT ): LONGINT;
 	sched_get_priority_max		: PROCEDURE {C} ( policy: LONGINT ): LONGINT;
 	sched_get_priority_min		: PROCEDURE {C} ( policy: LONGINT ): LONGINT;
 	sched_get_priority_min		: PROCEDURE {C} ( policy: LONGINT ): LONGINT;
-	
+
 	pthread_setschedparam 	: PROCEDURE {C} ( thread: Thread_t; policy: LONGINT; param: ADDRESS ): LONGINT;
 	pthread_setschedparam 	: PROCEDURE {C} ( thread: Thread_t; policy: LONGINT; param: ADDRESS ): LONGINT;
 	pthread_getschedparam	 	: PROCEDURE {C} ( thread: Thread_t; policy: ADDRESS; param: ADDRESS ): LONGINT;
 	pthread_getschedparam	 	: PROCEDURE {C} ( thread: Thread_t; policy: ADDRESS; param: ADDRESS ): LONGINT;
 	pthread_setcancelstate		: PROCEDURE {C} ( state: LONGINT; oldstate: ADDRESS ): LONGINT;
 	pthread_setcancelstate		: PROCEDURE {C} ( state: LONGINT; oldstate: ADDRESS ): LONGINT;
 	pthread_setcanceltype		: PROCEDURE {C} ( type: LONGINT; oldtype: ADDRESS ): LONGINT;
 	pthread_setcanceltype		: PROCEDURE {C} ( type: LONGINT; oldtype: ADDRESS ): LONGINT;
 	pthread_sigmask 			: PROCEDURE {C} ( how: LONGINT; set: ADDRESS; oldset: ADDRESS ): LONGINT;
 	pthread_sigmask 			: PROCEDURE {C} ( how: LONGINT; set: ADDRESS; oldset: ADDRESS ): LONGINT;
-	
+
 	sigaction		: PROCEDURE {C} (signum: LONGINT; CONST act, oldact: ADDRESS): LONGINT;
 	sigaction		: PROCEDURE {C} (signum: LONGINT; CONST act, oldact: ADDRESS): LONGINT;
 	sigemptyset	: PROCEDURE {C} (set: ADDRESS);
 	sigemptyset	: PROCEDURE {C} (set: ADDRESS);
 	sigfillset		: PROCEDURE {C} (set: ADDRESS): LONGINT;
 	sigfillset		: PROCEDURE {C} (set: ADDRESS): LONGINT;
@@ -523,15 +523,15 @@ VAR
 	sigdelset		: PROCEDURE {C} (set: ADDRESS; signo: LONGINT);
 	sigdelset		: PROCEDURE {C} (set: ADDRESS; signo: LONGINT);
 	nanosleep		: PROCEDURE {C} (req, rem: ADDRESS): LONGINT;
 	nanosleep		: PROCEDURE {C} (req, rem: ADDRESS): LONGINT;
 	sigaltstack	: PROCEDURE {C} (ss, oss: ADDRESS): LONGINT;
 	sigaltstack	: PROCEDURE {C} (ss, oss: ADDRESS): LONGINT;
-	
 
 
-	(*	pid: return param for process id. Only set if initialized non-null. path: pointer to string denoting the executable. 
-		file_actions: modify which files are open for the new process, if NIL it inherits open files from parent process. 
+
+	(*	pid: return param for process id. Only set if initialized non-null. path: pointer to string denoting the executable.
+		file_actions: modify which files are open for the new process, if NIL it inherits open files from parent process.
 		attrp: sets process groups, scheduler, signals etc, leave NIL. argv, evp: char** to the arguments and env. variables*)
 		attrp: sets process groups, scheduler, signals etc, leave NIL. argv, evp: char** to the arguments and env. variables*)
 	posix_spawnp- 	: PROCEDURE {C} ( pid: ADDRESS; path: ADDRESS; file_actions: ADDRESS; attrp: ADDRESS; argv: ADDRESS ; envp: ADDRESS ): LONGINT;
 	posix_spawnp- 	: PROCEDURE {C} ( pid: ADDRESS; path: ADDRESS; file_actions: ADDRESS; attrp: ADDRESS; argv: ADDRESS ; envp: ADDRESS ): LONGINT;
 	(*more restrictive than spawnp*)
 	(*more restrictive than spawnp*)
 	posix_spawn- 	: PROCEDURE {C} ( pid: ADDRESS; path: ADDRESS; file_actions: ADDRESS; attrp: ADDRESS; argv: ADDRESS ; envp: ADDRESS ): LONGINT;
 	posix_spawn- 	: PROCEDURE {C} ( pid: ADDRESS; path: ADDRESS; file_actions: ADDRESS; attrp: ADDRESS; argv: ADDRESS ; envp: ADDRESS ): LONGINT;
-	
+
 	waitpid-		: PROCEDURE {C} ( pid: pid_t; status: ADDRESS; options: LONGINT ): pid_t;
 	waitpid-		: PROCEDURE {C} ( pid: pid_t; status: ADDRESS; options: LONGINT ): pid_t;
 	pipe-			: PROCEDURE {C} ( pipefd: ADDRESS ): LONGINT; (*pipefd is assumed to be a pointer to a C array of 2 elements, after pipe creation the array will contain file descriptors for the input and output end of the pipe. returns 0 on success, or -1 on fail*)
 	pipe-			: PROCEDURE {C} ( pipefd: ADDRESS ): LONGINT; (*pipefd is assumed to be a pointer to a C array of 2 elements, after pipe creation the array will contain file descriptors for the input and output end of the pipe. returns 0 on success, or -1 on fail*)
 	dup2-			: PROCEDURE {C} ( oldfd, newfd: LONGINT ): LONGINT; (*overwrites file descriptor newfd with a copy of oldfd. useful for redirecting pipes.*)
 	dup2-			: PROCEDURE {C} ( oldfd, newfd: LONGINT ): LONGINT; (*overwrites file descriptor newfd with a copy of oldfd. useful for redirecting pipes.*)
@@ -565,7 +565,7 @@ VAR
 
 
 	getpid-		: PROCEDURE {C} ( ): LONGINT;
 	getpid-		: PROCEDURE {C} ( ): LONGINT;
 	getuid-		: PROCEDURE {C} ( ): LONGINT;
 	getuid-		: PROCEDURE {C} ( ): LONGINT;
-	
+
 	posix_memalign-	: PROCEDURE {C} ( VAR p: ADDRESS;  alignment, size: SIZE ): LONGINT;
 	posix_memalign-	: PROCEDURE {C} ( VAR p: ADDRESS;  alignment, size: SIZE ): LONGINT;
 	malloc-		: PROCEDURE {C} ( size: SIZE ): ADDRESS;
 	malloc-		: PROCEDURE {C} ( size: SIZE ): ADDRESS;
 	free-			: PROCEDURE {C} ( p: ADDRESS );
 	free-			: PROCEDURE {C} ( p: ADDRESS );
@@ -625,7 +625,7 @@ VAR
 		ASSERT(pthread_key_create(ADDRESSOF(key), NIL) = 0);
 		ASSERT(pthread_key_create(ADDRESSOF(key), NIL) = 0);
 		RETURN key;
 		RETURN key;
 	END NewKey;
 	END NewKey;
- 
+
 	PROCEDURE ReadKey* (key: Key_t): ADDRESS;
 	PROCEDURE ReadKey* (key: Key_t): ADDRESS;
 	BEGIN
 	BEGIN
 		RETURN pthread_getspecific(key);
 		RETURN pthread_getspecific(key);
@@ -635,8 +635,8 @@ VAR
 	BEGIN
 	BEGIN
 		ASSERT(pthread_setspecific(key, value) = 0);
 		ASSERT(pthread_setspecific(key, value) = 0);
 	END WriteKey;
 	END WriteKey;
-	
-	
+
+
 	PROCEDURE NewMtx*( ): Mutex_t;
 	PROCEDURE NewMtx*( ): Mutex_t;
 	VAR
 	VAR
 		mtx: Mutex_t;
 		mtx: Mutex_t;
@@ -727,7 +727,7 @@ VAR
 	BEGIN
 	BEGIN
 		res := pthread_getschedparam( thr, ADDRESSOF( policy ), ADDRESSOF( param ) );
 		res := pthread_getschedparam( thr, ADDRESSOF( policy ), ADDRESSOF( param ) );
 		param.sched_priority := prio;
 		param.sched_priority := prio;
-		res := pthread_setschedparam( thr, SCHED_RR, ADDRESSOF( param ) ) 
+		res := pthread_setschedparam( thr, SCHED_RR, ADDRESSOF( param ) )
 	END ThrSetPriority;
 	END ThrSetPriority;
 
 
 	PROCEDURE ThrGetPriority*( thr: Thread_t ): LONGINT;
 	PROCEDURE ThrGetPriority*( thr: Thread_t ): LONGINT;
@@ -770,12 +770,12 @@ VAR
 		sigdelset( ADDRESSOF( new ), SIGTERM );
 		sigdelset( ADDRESSOF( new ), SIGTERM );
 		sigdelset( ADDRESSOF( new ), SIGUSR1 );
 		sigdelset( ADDRESSOF( new ), SIGUSR1 );
 		res := pthread_sigmask( SIG_SETMASK, ADDRESSOF( new ), ADDRESSOF( old ) );
 		res := pthread_sigmask( SIG_SETMASK, ADDRESSOF( new ), ADDRESSOF( old ) );
-		
+
 		res := pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, NIL );
 		res := pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, NIL );
 		res := pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS, NIL );
 		res := pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS, NIL );
 		param.sched_priority := 0;
 		param.sched_priority := 0;
 		res := pthread_setschedparam( me, SCHED_RR, ADDRESSOF( param ) );
 		res := pthread_setschedparam( me, SCHED_RR, ADDRESSOF( param ) );
-		
+
 		proc();
 		proc();
 
 
 		pthread_exit( NIL );
 		pthread_exit( NIL );
@@ -830,23 +830,23 @@ VAR
 	BEGIN
 	BEGIN
 		machthr := pthread_mach_thread_np( thr );
 		machthr := pthread_mach_thread_np( thr );
 		thread_resume( machthr );
 		thread_resume( machthr );
-	END ThrResume;	
+	END ThrResume;
+
 
 
-	
 	PROCEDURE ThrSuspend*( thr: Thread_t; saveContext: BOOLEAN );
 	PROCEDURE ThrSuspend*( thr: Thread_t; saveContext: BOOLEAN );
 	VAR r: LONGINT;  machthr: MachPort;
 	VAR r: LONGINT;  machthr: MachPort;
 	BEGIN
 	BEGIN
 		IF saveContext THEN
 		IF saveContext THEN
 			handler_done := FALSE;
 			handler_done := FALSE;
-			r := pthread_kill( thr, SIGUSR1 );	
+			r := pthread_kill( thr, SIGUSR1 );
 			(*	not working in Solaris when the thread is stalled in a mutex.
 			(*	not working in Solaris when the thread is stalled in a mutex.
-				handler gets arrived but has bad side effects, 
+				handler gets arrived but has bad side effects,
 				yields traps and locks the system *)
 				yields traps and locks the system *)
 			WHILE ~handler_done DO  ThrSleep( 1 )  END;
 			WHILE ~handler_done DO  ThrSleep( 1 )  END;
 		END;
 		END;
 		machthr := pthread_mach_thread_np( thr );
 		machthr := pthread_mach_thread_np( thr );
 		thread_suspend( machthr )
 		thread_suspend( machthr )
-	END ThrSuspend;	
+	END ThrSuspend;
 
 
 
 
 
 
@@ -986,16 +986,16 @@ VAR
 	BEGIN
 	BEGIN
 		trap := h;
 		trap := h;
 	END InstallTrap;
 	END InstallTrap;
-	
-	
+
+
 	VAR suspendHandler*: PROCEDURE( c: Ucontext );
 	VAR suspendHandler*: PROCEDURE( c: Ucontext );
-	
+
 	PROCEDURE {C} SigHandler( sig: LONGINT; scp: ADDRESS; ucp: Ucontext ); (* reversed arguments !! *)
 	PROCEDURE {C} SigHandler( sig: LONGINT; scp: ADDRESS; ucp: Ucontext ); (* reversed arguments !! *)
 	BEGIN
 	BEGIN
 		IF sig = SIGUSR1 THEN
 		IF sig = SIGUSR1 THEN
 			suspendHandler( ucp );
 			suspendHandler( ucp );
 			handler_done := TRUE;
 			handler_done := TRUE;
-		ELSIF trap # NIL THEN 
+		ELSIF trap # NIL THEN
 			trap( sig, ucp.mc );
 			trap( sig, ucp.mc );
 		ELSE
 		ELSE
 			Trace.String( "Unix.SigHandler: sig = " ); Trace.Int( sig, 0 ); Trace.Ln;  exit( -1 );
 			Trace.String( "Unix.SigHandler: sig = " ); Trace.Int( sig, 0 ); Trace.Ln;  exit( -1 );
@@ -1021,13 +1021,13 @@ VAR
 		END;
 		END;
 	END InstallHandler;
 	END InstallHandler;
 
 
-	
+
 	PROCEDURE HandleSignal*( sig: LONGINT );
 	PROCEDURE HandleSignal*( sig: LONGINT );
 	BEGIN
 	BEGIN
 		InstallHandler( sig )
 		InstallHandler( sig )
 	END HandleSignal;
 	END HandleSignal;
-	
-	
+
+
 	PROCEDURE errno*(): LONGINT;
 	PROCEDURE errno*(): LONGINT;
 	VAR loc: ADDRESS;
 	VAR loc: ADDRESS;
 	BEGIN
 	BEGIN
@@ -1083,7 +1083,7 @@ VAR
 		noPaths := 4;
 		noPaths := 4;
 
 
 		libc := Dlopen( libcname, 2 );
 		libc := Dlopen( libcname, 2 );
-		libp := Dlopen( libpthreadname, 2 ); 
+		libp := Dlopen( libpthreadname, 2 );
 
 
 		Dlsym( libc, "exit",			ADDRESSOF(exit) );
 		Dlsym( libc, "exit",			ADDRESSOF(exit) );
 		Dlsym( libc, "sysconf", 	ADDRESSOF(sysconf) );
 		Dlsym( libc, "sysconf", 	ADDRESSOF(sysconf) );
@@ -1107,7 +1107,7 @@ VAR
 		Dlsym( libp, "pthread_detach",	ADDRESSOF(pthread_detach) );
 		Dlsym( libp, "pthread_detach",	ADDRESSOF(pthread_detach) );
 		Dlsym( libp, "pthread_cancel",	ADDRESSOF(pthread_cancel) );
 		Dlsym( libp, "pthread_cancel",	ADDRESSOF(pthread_cancel) );
 		Dlsym( libp, "pthread_kill",		ADDRESSOF(pthread_kill) );
 		Dlsym( libp, "pthread_kill",		ADDRESSOF(pthread_kill) );
-		
+
 		Dlsym( libp, "pthread_key_create", ADDRESSOF( pthread_key_create ) );
 		Dlsym( libp, "pthread_key_create", ADDRESSOF( pthread_key_create ) );
 		Dlsym( libp, "pthread_getspecific", ADDRESSOF( pthread_getspecific ) );
 		Dlsym( libp, "pthread_getspecific", ADDRESSOF( pthread_getspecific ) );
 		Dlsym( libp, "pthread_setspecific", ADDRESSOF( pthread_setspecific ) );
 		Dlsym( libp, "pthread_setspecific", ADDRESSOF( pthread_setspecific ) );
@@ -1120,7 +1120,7 @@ VAR
 		Dlsym( libp, "pthread_attr_setdetachstate", ADDRESSOF(pthread_attr_setdetachstate) );
 		Dlsym( libp, "pthread_attr_setdetachstate", ADDRESSOF(pthread_attr_setdetachstate) );
 		Dlsym( libp, "pthread_attr_setstacksize", ADDRESSOF(pthread_attr_setstacksize) );
 		Dlsym( libp, "pthread_attr_setstacksize", ADDRESSOF(pthread_attr_setstacksize) );
 		Dlsym( libp, "pthread_self", ADDRESSOF(pthread_self) );
 		Dlsym( libp, "pthread_self", ADDRESSOF(pthread_self) );
-		
+
 		Dlsym( libc, "pthread_mach_thread_np", ADDRESSOF( pthread_mach_thread_np ) );
 		Dlsym( libc, "pthread_mach_thread_np", ADDRESSOF( pthread_mach_thread_np ) );
 		Dlsym( libc, "thread_suspend", ADDRESSOF( thread_suspend ) );
 		Dlsym( libc, "thread_suspend", ADDRESSOF( thread_suspend ) );
 		Dlsym( libc, "thread_resume", ADDRESSOF( thread_resume ) );
 		Dlsym( libc, "thread_resume", ADDRESSOF( thread_resume ) );
@@ -1167,7 +1167,7 @@ VAR
 		Dlsym( libc, "chdir",	ADDRESSOF( chdir ) );
 		Dlsym( libc, "chdir",	ADDRESSOF( chdir ) );
 		Dlsym( libc, "mkdir",	ADDRESSOF( mkdir ) );
 		Dlsym( libc, "mkdir",	ADDRESSOF( mkdir ) );
 		Dlsym( libc, "rmdir",	ADDRESSOF( rmdir ) );
 		Dlsym( libc, "rmdir",	ADDRESSOF( rmdir ) );
-		
+
 #IF I386 THEN
 #IF I386 THEN
 		Dlsym( libc, "stat",		ADDRESSOF( stat ) );
 		Dlsym( libc, "stat",		ADDRESSOF( stat ) );
 		Dlsym( libc, "lstat",	ADDRESSOF( lstat ) );
 		Dlsym( libc, "lstat",	ADDRESSOF( lstat ) );

+ 0 - 1
source/DataErrors.Mod

@@ -543,4 +543,3 @@ DataErrors.Close ~
 EditTools.OpenAscii  Error.Log ~
 EditTools.OpenAscii  Error.Log ~
 EditTools.OpenAscii  Error.Log.Bak ~
 EditTools.OpenAscii  Error.Log.Bak ~
 
 
-			

+ 2 - 2
source/Dates.Mod

@@ -10,7 +10,7 @@ MODULE Dates; (** AUTHOR "be, tf, staubesv"; PURPOSE "Date and time functions";
 					4-0: day of month
 					4-0: day of month
 *)
 *)
 
 
-(*	Problem of leap seconds is handled as in POSIX: 
+(*	Problem of leap seconds is handled as in POSIX:
 		http://www.eecis.udel.edu/~mills/leap.html
 		http://www.eecis.udel.edu/~mills/leap.html
 		http://en.wikipedia.org/wiki/Leap_second
 		http://en.wikipedia.org/wiki/Leap_second
 *)
 *)
@@ -164,7 +164,7 @@ BEGIN
 	RETURN result;
 	RETURN result;
 END CompareDateTime;
 END CompareDateTime;
 
 
-(** Absolute time difference between t1 and t2. 
+(** Absolute time difference between t1 and t2.
 Note that leap seconds are not counted, see http://www.eecis.udel.edu/~mills/leap.html *)
 Note that leap seconds are not counted, see http://www.eecis.udel.edu/~mills/leap.html *)
 PROCEDURE TimeDifference*(t1, t2 : DateTime; VAR days, hours, minutes, seconds : LONGINT);
 PROCEDURE TimeDifference*(t1, t2 : DateTime; VAR days, hours, minutes, seconds : LONGINT);
 CONST SecondsPerMinute = 60; SecondsPerHour = 3600; SecondsPerDay = 86400;
 CONST SecondsPerMinute = 60; SecondsPerHour = 3600; SecondsPerDay = 86400;

+ 14 - 14
source/Debugging.Mod

@@ -21,18 +21,18 @@ VAR
 		Log.Update;
 		Log.Update;
 	END Memory;
 	END Memory;
 
 
-	
+
 	PROCEDURE CallerBP(bp: ADDRESS): ADDRESS;
 	PROCEDURE CallerBP(bp: ADDRESS): ADDRESS;
 	VAR n: ADDRESS;
 	VAR n: ADDRESS;
 	BEGIN
 	BEGIN
 		IF bp # NIL THEN
 		IF bp # NIL THEN
 			SYSTEM.GET(bp, n);
 			SYSTEM.GET(bp, n);
 			IF ODD(n) THEN INC(bp, SIZEOF(ADDRESS)) END;
 			IF ODD(n) THEN INC(bp, SIZEOF(ADDRESS)) END;
-			SYSTEM.GET(bp, bp);			
+			SYSTEM.GET(bp, bp);
 		END;
 		END;
 		RETURN bp;
 		RETURN bp;
 	END CallerBP;
 	END CallerBP;
-	
+
 	PROCEDURE ViewStack( ebp, esp: ADDRESS; CONST s: ARRAY OF CHAR);
 	PROCEDURE ViewStack( ebp, esp: ADDRESS; CONST s: ARRAY OF CHAR);
 	VAR i: ADDRESS; val: LONGINT; prevBP:ADDRESS;
 	VAR i: ADDRESS; val: LONGINT; prevBP:ADDRESS;
 	CONST adrSize= SIZEOF(ADDRESS);
 	CONST adrSize= SIZEOF(ADDRESS);
@@ -206,13 +206,13 @@ VAR
 	PROCEDURE DisableGC*;
 	PROCEDURE DisableGC*;
 	BEGIN
 	BEGIN
 		Heaps.GC := Nothing;
 		Heaps.GC := Nothing;
-		TRACE(Heaps.GC, "disabled"); 
+		TRACE(Heaps.GC, "disabled");
 	END DisableGC;
 	END DisableGC;
 
 
 	PROCEDURE EnableGC*;
 	PROCEDURE EnableGC*;
 	BEGIN
 	BEGIN
 		Heaps.GC := Heaps.InvokeGC;
 		Heaps.GC := Heaps.InvokeGC;
-		TRACE(Heaps.GC, "enabled"); 
+		TRACE(Heaps.GC, "enabled");
 	END EnableGC;
 	END EnableGC;
 
 
 	(* useful for debugging the GC / metadata *)
 	(* useful for debugging the GC / metadata *)
@@ -221,17 +221,17 @@ VAR
 	BEGIN
 	BEGIN
 		m := Modules.root;
 		m := Modules.root;
 		WHILE (m # NIL) DO
 		WHILE (m # NIL) DO
-			TRACE(m.name); 
-			IF m.procTable # NIL THEN 
+			TRACE(m.name);
+			IF m.procTable # NIL THEN
 				FOR i := 0 TO LEN(m.procTable)-1 DO
 				FOR i := 0 TO LEN(m.procTable)-1 DO
 					(*TRACE(m.procTable[i]);*)
 					(*TRACE(m.procTable[i]);*)
-					Log.Address(m.procTable[i]); 
-					Log.String(":"); 
-					Reflection.WriteProc(Log, m.procTable[i].pcFrom); 
+					Log.Address(m.procTable[i]);
+					Log.String(":");
+					Reflection.WriteProc(Log, m.procTable[i].pcFrom);
 					Log.String(" ptrs @ ");
 					Log.String(" ptrs @ ");
 					FOR j := 0 TO LEN(m.procTable[i].offsets)-1 DO
 					FOR j := 0 TO LEN(m.procTable[i].offsets)-1 DO
-						Log.Int(m.procTable[i].offsets[j],1); 
-						Log.String(" "); 
+						Log.Int(m.procTable[i].offsets[j],1);
+						Log.String(" ");
 					END;
 					END;
 					Log.Ln;
 					Log.Ln;
 				END;
 				END;
@@ -258,12 +258,12 @@ VAR
 		END;
 		END;
 		context.result := Commands.CommandError;
 		context.result := Commands.CommandError;
 	END ReportModule;
 	END ReportModule;
-	
+
 	PROCEDURE Test*;
 	PROCEDURE Test*;
 	BEGIN
 	BEGIN
 		Stack("Stack");
 		Stack("Stack");
 	END Test;
 	END Test;
-	
+
 
 
 BEGIN
 BEGIN
 	Streams.OpenWriter( DefaultLog, KernelLog.Send );  Log := DefaultLog; NEW( lock );
 	Streams.OpenWriter( DefaultLog, KernelLog.Send );  Log := DefaultLog; NEW( lock );

+ 6 - 6
source/DiskCaches.Mod

@@ -13,8 +13,8 @@ IMPORT SYSTEM, Disks;
 		END;
 		END;
 
 
 	TYPE
 	TYPE
-	
-	(* Yet very simple disk cache. 
+
+	(* Yet very simple disk cache.
 		- synchronous
 		- synchronous
 		- One-way associative
 		- One-way associative
 		- Write-through
 		- Write-through
@@ -72,7 +72,7 @@ IMPORT SYSTEM, Disks;
 
 
 END DiskCaches.
 END DiskCaches.
 
 
-(** USAGE PATTERN: 
+(** USAGE PATTERN:
 
 
 	VirtualDisk = OBJECT(Disks.Device)
 	VirtualDisk = OBJECT(Disks.Device)
 	VAR
 	VAR
@@ -83,13 +83,13 @@ END DiskCaches.
 		BEGIN
 		BEGIN
 			.... OLD TRANSFER CODE
 			.... OLD TRANSFER CODE
 		END TransferX;
 		END TransferX;
-		
+
 		PROCEDURE Transfer(op, block, num: LONGINT; VAR data: ARRAY OF CHAR; ofs: LONGINT; VAR res: WORD);
 		PROCEDURE Transfer(op, block, num: LONGINT; VAR data: ARRAY OF CHAR; ofs: LONGINT; VAR res: WORD);
 		BEGIN{EXCLUSIVE}
 		BEGIN{EXCLUSIVE}
-			cache.Transfer(op,block,num,data,ofs,res) 
+			cache.Transfer(op,block,num,data,ofs,res)
 		END Transfer;
 		END Transfer;
 
 
-		....		
+		....
 
 
 		PROCEDURE &Init(CONST name : ARRAY OF CHAR; blockSize, cyls, hds, spt : LONGINT);
 		PROCEDURE &Init(CONST name : ARRAY OF CHAR; blockSize, cyls, hds, spt : LONGINT);
 		BEGIN
 		BEGIN

+ 16 - 16
source/DiskFS.Mod

@@ -385,14 +385,14 @@ TYPE
 					vol.MarkBlocks(mark,0,markPosition);
 					vol.MarkBlocks(mark,0,markPosition);
 					markPosition := 0;
 					markPosition := 0;
 				END FinishMarking;
 				END FinishMarking;
-				
+
 				PROCEDURE MarkSector(vol: Files.Volume (* ignored *); sec: LONGINT);
 				PROCEDURE MarkSector(vol: Files.Volume (* ignored *); sec: LONGINT);
 				BEGIN
 				BEGIN
 					mark[markPosition] := sec DIV SectorFactor;
 					mark[markPosition] := sec DIV SectorFactor;
-					INC(markPosition); 
+					INC(markPosition);
 					IF markPosition = LEN(mark) THEN
 					IF markPosition = LEN(mark) THEN
 						FinishMarking;
 						FinishMarking;
-					END; 
+					END;
 				END MarkSector;
 				END MarkSector;
 
 
 				PROCEDURE sift(L, R: LONGINT);
 				PROCEDURE sift(L, R: LONGINT);
@@ -783,14 +783,14 @@ TYPE
 				vol.FreeBlocks(free,0,freePosition);
 				vol.FreeBlocks(free,0,freePosition);
 				freePosition := 0;
 				freePosition := 0;
 			END FinishFreeing;
 			END FinishFreeing;
-			
+
 			PROCEDURE FreeSector(vol: Files.Volume (* ignored *); sec: LONGINT);
 			PROCEDURE FreeSector(vol: Files.Volume (* ignored *); sec: LONGINT);
 			BEGIN
 			BEGIN
 				free[freePosition] := sec DIV SectorFactor;
 				free[freePosition] := sec DIV SectorFactor;
-				INC(freePosition); 
+				INC(freePosition);
 				IF freePosition = LEN(free) THEN
 				IF freePosition = LEN(free) THEN
 					FinishFreeing;
 					FinishFreeing;
-				END; 
+				END;
 			END FreeSector;
 			END FreeSector;
 
 
 			PROCEDURE FreeExcept(sec: DiskAdr);
 			PROCEDURE FreeExcept(sec: DiskAdr);
@@ -901,20 +901,20 @@ TYPE
 			RETURN FALSE
 			RETURN FALSE
 		END Contains;
 		END Contains;
 	END DiskAdrList;
 	END DiskAdrList;
-			
+
 	DiskAdrTable = OBJECT
 	DiskAdrTable = OBJECT
 		VAR
 		VAR
 			table : DiskAdrArray;
 			table : DiskAdrArray;
 			count :SIZE;
 			count :SIZE;
 			size: SIZE; (* cache: invariant size  = LEN(table) *)
 			size: SIZE; (* cache: invariant size  = LEN(table) *)
-			
+
 		CONST
 		CONST
 			threshold = 4; (* 1/4 filled -> grow*)
 			threshold = 4; (* 1/4 filled -> grow*)
 
 
 		PROCEDURE &New*;
 		PROCEDURE &New*;
-		BEGIN NEW(table, 8); size := LEN(table)-1; count := 0; 
+		BEGIN NEW(table, 8); size := LEN(table)-1; count := 0;
 		END New;
 		END New;
-		
+
 		PROCEDURE Clear;
 		PROCEDURE Clear;
 		VAR i: SIZE;
 		VAR i: SIZE;
 		BEGIN{EXCLUSIVE}
 		BEGIN{EXCLUSIVE}
@@ -923,7 +923,7 @@ TYPE
 			END;
 			END;
 			count := 0;
 			count := 0;
 		END Clear;
 		END Clear;
-		
+
 		PROCEDURE Grow;
 		PROCEDURE Grow;
 		VAR old: DiskAdrArray; i,x: LONGINT; index: SIZE;
 		VAR old: DiskAdrArray; i,x: LONGINT; index: SIZE;
 		BEGIN
 		BEGIN
@@ -935,7 +935,7 @@ TYPE
 				x := old[i];
 				x := old[i];
 				IF (x # 0) THEN
 				IF (x # 0) THEN
 					index := HashValue(x);
 					index := HashValue(x);
-					IF (table[index] = 0) THEN 
+					IF (table[index] = 0) THEN
 						table[index] := x;
 						table[index] := x;
 						INC(count);
 						INC(count);
 					ELSE
 					ELSE
@@ -944,7 +944,7 @@ TYPE
 				END;
 				END;
 			END;
 			END;
 		END Grow;
 		END Grow;
-		
+
 		PROCEDURE HashValue(key: DiskAdr):SIZE;
 		PROCEDURE HashValue(key: DiskAdr):SIZE;
 		VAR index, h, i := 0 : SIZE;
 		VAR index, h, i := 0 : SIZE;
 		BEGIN
 		BEGIN
@@ -963,14 +963,14 @@ TYPE
 			ASSERT(x # 0);
 			ASSERT(x # 0);
 			IF count > size DIV threshold THEN Grow END;
 			IF count > size DIV threshold THEN Grow END;
 			index := HashValue(x);
 			index := HashValue(x);
-			IF table[index] = 0 THEN 
+			IF table[index] = 0 THEN
 				table[index] := x;
 				table[index] := x;
 				INC(count);
 				INC(count);
 			ELSE
 			ELSE
 				ASSERT(table[index] = x);
 				ASSERT(table[index] = x);
 			END;
 			END;
 		END Add;
 		END Add;
-		
+
 		PROCEDURE Contains(x: DiskAdr) : BOOLEAN;
 		PROCEDURE Contains(x: DiskAdr) : BOOLEAN;
 		BEGIN {EXCLUSIVE}
 		BEGIN {EXCLUSIVE}
 			RETURN table[HashValue(x)] = x;
 			RETURN table[HashValue(x)] = x;
@@ -1467,7 +1467,7 @@ VAR fs: FileSystem; fh: FileHeader; skipIndexMapWriteback: BOOLEAN; options: ARR
 BEGIN
 BEGIN
 	(* Get options *)
 	(* Get options *)
 	context.arg.SkipWhitespace;
 	context.arg.SkipWhitespace;
-	REPEAT UNTIL ~context.arg.GetString(options) OR (options = '|'); 
+	REPEAT UNTIL ~context.arg.GetString(options) OR (options = '|');
 	IF context.arg.GetString(options) THEN
 	IF context.arg.GetString(options) THEN
 		skipIndexMapWriteback := options = 'N'
 		skipIndexMapWriteback := options = 'N'
 	END;
 	END;

+ 1 - 1
source/Displays.Mod

@@ -42,7 +42,7 @@ TYPE
 				IF reverse THEN
 				IF reverse THEN
 				dispadr := fbadr + (height-y-1) * fbstride + (width-x-1) * format;
 				dispadr := fbadr + (height-y-1) * fbstride + (width-x-1) * format;
 				END;
 				END;
-				
+
 				ASSERT((dispadr >= fbadr) & ((y+h-1)*fbstride + (x+w-1)*format <=  fbsize));	(* display index check *)
 				ASSERT((dispadr >= fbadr) & ((y+h-1)*fbstride + (x+w-1)*format <=  fbsize));	(* display index check *)
 				w := w * format;	(* convert to bytes *)
 				w := w * format;	(* convert to bytes *)
 				CASE op OF
 				CASE op OF

+ 51 - 51
source/Drand48.Mod

@@ -4,146 +4,146 @@ MODULE Drand48;	(** AUTOR "G.F.";  PURPOSE "drand48 random generator"; *)
 CONST
 CONST
 	m = 1000000000000H;
 	m = 1000000000000H;
 	X = 1234ABCD330EH;   A = 5DEECE66DH;  C = 0BH;
 	X = 1234ABCD330EH;   A = 5DEECE66DH;  C = 0BH;
-	
-TYPE 
+
+TYPE
 	Generator* = OBJECT
 	Generator* = OBJECT
 	VAR
 	VAR
 		x, a: HUGEINT; c: LONGINT;
 		x, a: HUGEINT; c: LONGINT;
-		
+
 		PROCEDURE & Init*;
 		PROCEDURE & Init*;
 		BEGIN
 		BEGIN
 			x := X;   a := A;  c := C
 			x := X;   a := A;  c := C
 		END Init;
 		END Init;
-		
-		
+
+
 		PROCEDURE Drand48*(): LONGREAL;		(* [0.0 .. 1.0] *)
 		PROCEDURE Drand48*(): LONGREAL;		(* [0.0 .. 1.0] *)
 		CONST twom = 1.0D0 / m;
 		CONST twom = 1.0D0 / m;
 		BEGIN
 		BEGIN
-			x := (x*a + c) MOD m;  
-			RETURN twom*x 
+			x := (x*a + c) MOD m;
+			RETURN twom*x
 		END Drand48;
 		END Drand48;
-	
+
 		PROCEDURE Lrand48*(): LONGINT;		(* [0 .. 2^31-1] *)
 		PROCEDURE Lrand48*(): LONGINT;		(* [0 .. 2^31-1] *)
 		BEGIN
 		BEGIN
-			x := (x*a + c) MOD m;  
+			x := (x*a + c) MOD m;
 			RETURN SHORT( x DIV 20000H )
 			RETURN SHORT( x DIV 20000H )
 		END Lrand48;
 		END Lrand48;
-		
+
 		PROCEDURE Mrand48*(): LONGINT;		(* [0 .. 2^32-1] *)
 		PROCEDURE Mrand48*(): LONGINT;		(* [0 .. 2^32-1] *)
 		BEGIN
 		BEGIN
-			x := (x*a + c) MOD m;  
+			x := (x*a + c) MOD m;
 			RETURN SHORT( x DIV 10000H )
 			RETURN SHORT( x DIV 10000H )
 		END Mrand48;
 		END Mrand48;
-		
+
 		PROCEDURE Xrand48*(): HUGEINT;		(* [0 .. 2^48-1] *)
 		PROCEDURE Xrand48*(): HUGEINT;		(* [0 .. 2^48-1] *)
 		BEGIN
 		BEGIN
-			x := (x*a + c) MOD m;  
+			x := (x*a + c) MOD m;
 			RETURN x
 			RETURN x
 		END Xrand48;
 		END Xrand48;
-		
+
 		PROCEDURE Srand48*( seed: LONGINT );
 		PROCEDURE Srand48*( seed: LONGINT );
 		BEGIN
 		BEGIN
 			x := LONG(seed)*10000H + X MOD 10000H;  a := A
 			x := LONG(seed)*10000H + X MOD 10000H;  a := A
 		END Srand48;
 		END Srand48;
-		
-		
-		
+
+
+
 		PROCEDURE Seed48*( seed: HUGEINT ): HUGEINT;
 		PROCEDURE Seed48*( seed: HUGEINT ): HUGEINT;
 		VAR lastx: HUGEINT;
 		VAR lastx: HUGEINT;
 		BEGIN
 		BEGIN
 			lastx := x;
 			lastx := x;
 			x := seed MOD m;  a := A;
 			x := seed MOD m;  a := A;
-			RETURN lastx 
+			RETURN lastx
 		END Seed48;
 		END Seed48;
-		
+
 		PROCEDURE Lcong48*( par: ARRAY OF HUGEINT );
 		PROCEDURE Lcong48*( par: ARRAY OF HUGEINT );
 		BEGIN
 		BEGIN
 			x := par[0] MOD m;
 			x := par[0] MOD m;
 			a := par[1] MOD m;
 			a := par[1] MOD m;
 			c := SHORT( par[2] MOD 80000000H )
 			c := SHORT( par[2] MOD 80000000H )
 		END Lcong48;
 		END Lcong48;
-		
+
 	END Generator;
 	END Generator;
 
 
 
 
 (*========= Unix implementation =========
 (*========= Unix implementation =========
 CONST
 CONST
 	B = 10000H;	(* 16-bit barrier *)
 	B = 10000H;	(* 16-bit barrier *)
-	
+
 	X0 = 0330EH;  X1 = 0ABCDH;  X2 = 01234H;
 	X0 = 0330EH;  X1 = 0ABCDH;  X2 = 01234H;
 	A0 = 0E66DH;  A1 = 0DEECH;  A2 = 05H;
 	A0 = 0E66DH;  A1 = 0DEECH;  A2 = 05H;
-	
-TYPE 
+
+TYPE
 	Pair = RECORD h, l: LONGINT END;	(* unsigned 16-bit values *)
 	Pair = RECORD h, l: LONGINT END;	(* unsigned 16-bit values *)
-	
+
 	Triple* = ARRAY 3 OF LONGINT;		(* unsigned 16-bit values *)
 	Triple* = ARRAY 3 OF LONGINT;		(* unsigned 16-bit values *)
 	Seed16v* = POINTER TO Triple;
 	Seed16v* = POINTER TO Triple;
-	
+
 	Generator* = OBJECT
 	Generator* = OBJECT
 	VAR
 	VAR
 		x, a: Triple; c: LONGINT;
 		x, a: Triple; c: LONGINT;
-		
+
 		PROCEDURE & Init*;
 		PROCEDURE & Init*;
 		BEGIN
 		BEGIN
-			x[0] := X0;  x[1] := X1;  x[2] := X2;  
-			a[0] := A0;  a[1] := A1;  a[2] := A2;  
+			x[0] := X0;  x[1] := X1;  x[2] := X2;
+			a[0] := A0;  a[1] := A1;  a[2] := A2;
 			c := 0BH
 			c := 0BH
 		END Init;
 		END Init;
-		
-		
+
+
 		PROCEDURE Drand48*(): LONGREAL;
 		PROCEDURE Drand48*(): LONGREAL;
 		CONST two16m = 1.0D0 / B;
 		CONST two16m = 1.0D0 / B;
 		BEGIN
 		BEGIN
 			Next;  RETURN two16m*(two16m*(two16m*x[0] + x[1]) + x[2])
 			Next;  RETURN two16m*(two16m*(two16m*x[0] + x[1]) + x[2])
 		END Drand48;
 		END Drand48;
-	
+
 		PROCEDURE Lrand48*(): LONGINT;		(* [0 .. 2^31-1] *)
 		PROCEDURE Lrand48*(): LONGINT;		(* [0 .. 2^31-1] *)
 		BEGIN
 		BEGIN
 			Next;  RETURN x[2]*8000H + x[1] DIV 2 MOD 8000H
 			Next;  RETURN x[2]*8000H + x[1] DIV 2 MOD 8000H
 		END Lrand48;
 		END Lrand48;
-		
+
 		PROCEDURE Mrand48*(): LONGINT;		(* [0 .. 2^32-1] *)
 		PROCEDURE Mrand48*(): LONGINT;		(* [0 .. 2^32-1] *)
 		BEGIN
 		BEGIN
 			Next;  RETURN x[2]*B + x[1]
 			Next;  RETURN x[2]*B + x[1]
 		END Mrand48;
 		END Mrand48;
-		
+
 		PROCEDURE Xrand48*(): HUGEINT;		(* [0 .. 2^48-1] *)
 		PROCEDURE Xrand48*(): HUGEINT;		(* [0 .. 2^48-1] *)
 		BEGIN
 		BEGIN
 			Next;  RETURN ASH( LONG( x[2] ), 32 ) + x[1]*B + x[0]
 			Next;  RETURN ASH( LONG( x[2] ), 32 ) + x[1]*B + x[0]
 		END Xrand48;
 		END Xrand48;
-		
-		
+
+
 		PROCEDURE Srand48*( seedval: LONGINT );
 		PROCEDURE Srand48*( seedval: LONGINT );
 		BEGIN
 		BEGIN
 			Seed( X0, seedval MOD B, seedval DIV B  MOD B )
 			Seed( X0, seedval MOD B, seedval DIV B  MOD B )
 		END Srand48;
 		END Srand48;
-		
+
 		PROCEDURE Seed48*( CONST seed16v: ARRAY OF LONGINT ): Seed16v;
 		PROCEDURE Seed48*( CONST seed16v: ARRAY OF LONGINT ): Seed16v;
 		VAR lastx: Seed16v;
 		VAR lastx: Seed16v;
 		BEGIN
 		BEGIN
 			NEW( lastx );  lastx^ := x;
 			NEW( lastx );  lastx^ := x;
 			Seed( seed16v[0] MOD B, seed16v[1] MOD B, seed16v[2] MOD B );
 			Seed( seed16v[0] MOD B, seed16v[1] MOD B, seed16v[2] MOD B );
-			RETURN lastx 
+			RETURN lastx
 		END Seed48;
 		END Seed48;
-		
+
 		PROCEDURE Lcong48*( CONST param: ARRAY OF LONGINT );
 		PROCEDURE Lcong48*( CONST param: ARRAY OF LONGINT );
 		BEGIN
 		BEGIN
 			x[0] := param[0] MOD B;  x[1] := param[1] MOD B;  x[2] := param[2] MOD B;
 			x[0] := param[0] MOD B;  x[1] := param[1] MOD B;  x[2] := param[2] MOD B;
 			a[0] := param[3] MOD B;  a[1] := param[4] MOD B;  a[2] := param[5] MOD B;
 			a[0] := param[3] MOD B;  a[1] := param[4] MOD B;  a[2] := param[5] MOD B;
 			c := param[6] MOD B
 			c := param[6] MOD B
 		END Lcong48;
 		END Lcong48;
-		
-		
-		
-		
-		
+
+
+
+
+
 		PROCEDURE Seed( x0, x1, x2: LONGINT );
 		PROCEDURE Seed( x0, x1, x2: LONGINT );
 		BEGIN
 		BEGIN
 			x[0] := x0;  x[1] := x1;  x[2] := x2;
 			x[0] := x0;  x[1] := x1;  x[2] := x2;
 			a[0] := A0;  a[1] := A1;  a[2] := A2
 			a[0] := A0;  a[1] := A1;  a[2] := A2
 		END Seed;
 		END Seed;
-		
-		
+
+
 		PROCEDURE Next;
 		PROCEDURE Next;
 		VAR p, q, r: Pair;  carry: LONGINT;
 		VAR p, q, r: Pair;  carry: LONGINT;
 		BEGIN
 		BEGIN
@@ -157,12 +157,12 @@ TYPE
 			x[1] := (p.h + r.l) MOD B;
 			x[1] := (p.h + r.l) MOD B;
 			x[0] := p.l MOD B
 			x[0] := p.l MOD B
 		END Next;
 		END Next;
-	
+
 	END Generator;
 	END Generator;
 
 
 
 
-	
-	
+
+
 	PROCEDURE Mul( x, y: LONGINT ): Pair;
 	PROCEDURE Mul( x, y: LONGINT ): Pair;
 	VAR z: Pair;  t: LONGINT;
 	VAR z: Pair;  t: LONGINT;
 	BEGIN
 	BEGIN
@@ -170,7 +170,7 @@ TYPE
 		z.l := t MOD B;  z.h := t DIV B MOD B;
 		z.l := t MOD B;  z.h := t DIV B MOD B;
 		RETURN z
 		RETURN z
 	END Mul;
 	END Mul;
-	
+
 	PROCEDURE Addequ( VAR x: LONGINT;  y: LONGINT ): LONGINT;
 	PROCEDURE Addequ( VAR x: LONGINT;  y: LONGINT ): LONGINT;
 	BEGIN
 	BEGIN
 		x := x + y;
 		x := x + y;
@@ -178,8 +178,8 @@ TYPE
 		x := x MOD B;  RETURN 1
 		x := x MOD B;  RETURN 1
 	END Addequ;
 	END Addequ;
 	*)
 	*)
-	
-	
+
+
 END Drand48.
 END Drand48.
 
 
 
 

+ 15 - 15
source/EFI.AMD64.Machine.Mod

@@ -300,7 +300,7 @@ VAR
 
 
 	chs: ARRAY MaxDisks OF RECORD cyls, hds, spt: LONGINT END;
 	chs: ARRAY MaxDisks OF RECORD cyls, hds, spt: LONGINT END;
 	initRegs0, initRegs1: HUGEINT;
 	initRegs0, initRegs1: HUGEINT;
-	fbadr*, fbInfoPtr*: ADDRESS; 
+	fbadr*, fbInfoPtr*: ADDRESS;
 	initRegs: ARRAY 2 OF HUGEINT;	(* kernel parameters *)
 	initRegs: ARRAY 2 OF HUGEINT;	(* kernel parameters *)
 	config: ARRAY 2048 OF CHAR;	(* config strings *)
 	config: ARRAY 2048 OF CHAR;	(* config strings *)
 	bootFlag: ADDRESS;
 	bootFlag: ADDRESS;
@@ -1531,7 +1531,7 @@ BEGIN
 	ASSERT((virtAdr MOD PS = 0) & (size MOD PS = 0));
 	ASSERT((virtAdr MOD PS = 0) & (size MOD PS = 0));
 	TRACE(virtAdr, phys, size);
 	TRACE(virtAdr, phys, size);
 	WHILE size # 0 DO
 	WHILE size # 0 DO
-		
+
 		IF ~ODD(MappedPage(virtAdr)) THEN
 		IF ~ODD(MappedPage(virtAdr)) THEN
 			IF ~MapPage(virtAdr, phys) THEN RETURN FALSE END;
 			IF ~MapPage(virtAdr, phys) THEN RETURN FALSE END;
 		END;
 		END;
@@ -1910,12 +1910,12 @@ heapEndAdr := 0;
 	NewPage(kernelPML4); ASSERT(kernelPML4 # NilAdr);
 	NewPage(kernelPML4); ASSERT(kernelPML4 # NilAdr);
 	Fill32(kernelPML4, TPS, PageNotPresent);
 	Fill32(kernelPML4, TPS, PageNotPresent);
 	IF ~MapDirect(LowAdr, memTop-LowAdr, LowAdr + UserPage) THEN HALT(99) END;	(* map heap direct *)
 	IF ~MapDirect(LowAdr, memTop-LowAdr, LowAdr + UserPage) THEN HALT(99) END;	(* map heap direct *)
-	
+
 (*	IF ~MapDirect(fbadr, PS*1024*1, fbadr + UserPage) THEN  (* map frame buffer  direct *)
 (*	IF ~MapDirect(fbadr, PS*1024*1, fbadr + UserPage) THEN  (* map frame buffer  direct *)
 		Trace.String("map direct failed at fbadr"); Trace.Address(fbadr); Trace.Ln;
 		Trace.String("map direct failed at fbadr"); Trace.Address(fbadr); Trace.Ln;
 	ELSE
 	ELSE
 		Trace.String("fbuffer mapped"); Trace.Address(fbadr); Trace.Ln;
 		Trace.String("fbuffer mapped"); Trace.Address(fbadr); Trace.Ln;
-	END; 
+	END;
 *)
 *)
 END InitPages;
 END InitPages;
 
 
@@ -2599,7 +2599,7 @@ entry:
 
 
 	LEA RBP, [RSP + 136]
 	LEA RBP, [RSP + 136]
 	MOV RBX, [RSP + 128]	; RBX = int number
 	MOV RBX, [RSP + 128]	; RBX = int number
-	
+
 	IMUL RBX, RBX, MaxNumHandlers
 	IMUL RBX, RBX, MaxNumHandlers
 	IMUL RBX, RBX, SizeOfHandlerRec
 	IMUL RBX, RBX, SizeOfHandlerRec
 	; todo: replace LEA by MOV when compiler supports this
 	; todo: replace LEA by MOV when compiler supports this
@@ -2833,7 +2833,7 @@ CODE {SYSTEM.AMD64}
 END CurrentPC;
 END CurrentPC;
 
 
 PROCEDURE -SetRAX(n: SIZE);
 PROCEDURE -SetRAX(n: SIZE);
-CODE{SYSTEM.AMD64}	
+CODE{SYSTEM.AMD64}
 	NOP
 	NOP
 	POP RAX
 	POP RAX
 END SetRAX;
 END SetRAX;
@@ -3788,7 +3788,7 @@ BEGIN
 		MOV bootFlag, RAX
 		MOV bootFlag, RAX
 		MOV initRegs0,RSI
 		MOV initRegs0,RSI
 		MOV initRegs1, RCX
 		MOV initRegs1, RCX
-		
+
 		MOV fbadr, RDI
 		MOV fbadr, RDI
 		MOV fbInfoPtr, RDX
 		MOV fbInfoPtr, RDX
 	END;
 	END;
@@ -3801,29 +3801,29 @@ PROCEDURE {NOPAF, FIXED(0100000H)} FirstAddress;
 CODE{SYSTEM.AMD64}
 CODE{SYSTEM.AMD64}
 	; relocate the bootfile from 0x1000 to target address 0x100000
 	; relocate the bootfile from 0x1000 to target address 0x100000
 
 
-	
-	
+
+
 	PUSH RAX
 	PUSH RAX
 	PUSH RSI
 	PUSH RSI
 	PUSH RDI
 	PUSH RDI
 
 
-	
+
 	MOV RSI,1000H
 	MOV RSI,1000H
 	MOV RDI,100000H
 	MOV RDI,100000H
 	MOV RCX, LastAddress
 	MOV RCX, LastAddress
 	SUB RCX, RDI
 	SUB RCX, RDI
-	
+
 	; CLD
 	; CLD
 	; REP MOVSB
 	; REP MOVSB
-	
+
 	ADD RSI, RCX
 	ADD RSI, RCX
 	ADD RDI, RCX
 	ADD RDI, RCX
 	STD
 	STD
-	REP MOVSB 
-	
+	REP MOVSB
+
 	POP RDI
 	POP RDI
 	POP RSI
 	POP RSI
-	POP RAX	
+	POP RAX
 
 
 
 
 
 

+ 18 - 18
source/EFI.I386.Machine.Mod

@@ -312,7 +312,7 @@ VAR
 	chs: ARRAY MaxDisks OF RECORD cyls, hds, spt: LONGINT END;
 	chs: ARRAY MaxDisks OF RECORD cyls, hds, spt: LONGINT END;
 	initRegs0, initRegs1: LONGINT;
 	initRegs0, initRegs1: LONGINT;
 	initRegs: ARRAY 2 OF LONGINT;	(* kernel parameters *)
 	initRegs: ARRAY 2 OF LONGINT;	(* kernel parameters *)
-	fbadr*, fbInfoPtr*: ADDRESS; 
+	fbadr*, fbInfoPtr*: ADDRESS;
 	config: ARRAY 2048 OF CHAR;	(* config strings *)
 	config: ARRAY 2048 OF CHAR;	(* config strings *)
 	bootFlag: ADDRESS;
 	bootFlag: ADDRESS;
 
 
@@ -574,9 +574,9 @@ CONST
 	SSE2Flag = 26;
 	SSE2Flag = 26;
 	SSE3Flag = 0; (*IN features2 from ECX*) (*PH 04/11*)
 	SSE3Flag = 0; (*IN features2 from ECX*) (*PH 04/11*)
 	SSSE3Flag =9;
 	SSSE3Flag =9;
-	SSE41Flag =19; 
+	SSE41Flag =19;
 	SSE42Flag =20;
 	SSE42Flag =20;
-	SSE5Flag = 11; 
+	SSE5Flag = 11;
 	AVXFlag = 28;
 	AVXFlag = 28;
 BEGIN
 BEGIN
 	SSE2Support := FALSE;
 	SSE2Support := FALSE;
@@ -1847,10 +1847,10 @@ BEGIN
 	NewPage(kernelPD); ASSERT(kernelPD # NilAdr);
 	NewPage(kernelPD); ASSERT(kernelPD # NilAdr);
 	Fill32(kernelPD, PTEs*4, PageNotPresent);
 	Fill32(kernelPD, PTEs*4, PageNotPresent);
 	IF ~MapDirect(LowAdr, mTop-LowAdr, LowAdr + UserPage) THEN HALT(99) END	;(* map heap direct *)
 	IF ~MapDirect(LowAdr, mTop-LowAdr, LowAdr + UserPage) THEN HALT(99) END	;(* map heap direct *)
-	
+
 	IF ~MapDirect(fbadr, PS*1024*10, fbadr + UserPage) THEN  (* map frame buffer  direct *)
 	IF ~MapDirect(fbadr, PS*1024*10, fbadr + UserPage) THEN  (* map frame buffer  direct *)
 		Trace.String("map direct failed at fbadr"); Trace.Address(fbadr); Trace.Ln;
 		Trace.String("map direct failed at fbadr"); Trace.Address(fbadr); Trace.Ln;
-	END; 
+	END;
 
 
 END InitPages;
 END InitPages;
 
 
@@ -2073,7 +2073,7 @@ END InModuleHeap;
 (* returns if an address is a currently allocated heap address *)
 (* returns if an address is a currently allocated heap address *)
 PROCEDURE ValidHeapAddress*(p: ADDRESS): BOOLEAN;
 PROCEDURE ValidHeapAddress*(p: ADDRESS): BOOLEAN;
 BEGIN
 BEGIN
-	RETURN 
+	RETURN
 		(p >= memBlockHead.beginBlockAdr) & (p <= memBlockTail.endBlockAdr)
 		(p >= memBlockHead.beginBlockAdr) & (p <= memBlockTail.endBlockAdr)
 		OR InModuleHeap(p);
 		OR InModuleHeap(p);
 END ValidHeapAddress;
 END ValidHeapAddress;
@@ -3468,8 +3468,8 @@ VAR status: SHORTINT;
 	PROCEDURE Scroll;
 	PROCEDURE Scroll;
 	VAR adr: ADDRESS; off: SIZE; i,j: LONGINT;
 	VAR adr: ADDRESS; off: SIZE; i,j: LONGINT;
 	BEGIN
 	BEGIN
-		IF (traceDelay > 0) & (scrollLines MOD TraceHeight = 0) THEN 
-			FOR i := 0 TO traceDelay-1 DO 
+		IF (traceDelay > 0) & (scrollLines MOD TraceHeight = 0) THEN
+			FOR i := 0 TO traceDelay-1 DO
 				FOR j := 0 TO 1000000 DO END;
 				FOR j := 0 TO 1000000 DO END;
 			END;
 			END;
 		END;
 		END;
@@ -3513,7 +3513,7 @@ PROCEDURE TraceColor (c: SHORTINT);
 BEGIN traceColor := c;
 BEGIN traceColor := c;
 END TraceColor;
 END TraceColor;
 
 
-VAR traceDelay: LONGINT; 
+VAR traceDelay: LONGINT;
 (* Initialise tracing. *)
 (* Initialise tracing. *)
 PROCEDURE InitTrace;
 PROCEDURE InitTrace;
 CONST MaxPorts = 8;
 CONST MaxPorts = 8;
@@ -3532,8 +3532,8 @@ BEGIN
 		Portout8(3D5H, CHR((TraceWidth*TraceHeight) DIV 100H));
 		Portout8(3D5H, CHR((TraceWidth*TraceHeight) DIV 100H));
 		Portout8(3D4H, 0FX);
 		Portout8(3D4H, 0FX);
 		Portout8(3D5H, CHR((TraceWidth*TraceHeight) MOD 100H));
 		Portout8(3D5H, CHR((TraceWidth*TraceHeight) MOD 100H));
-		GetConfig("TraceDelay", s); 
-		p := 0; traceDelay := StrToInt(p, s); 
+		GetConfig("TraceDelay", s);
+		p := 0; traceDelay := StrToInt(p, s);
 
 
 	END;
 	END;
 	IF TraceV24 IN traceMode THEN
 	IF TraceV24 IN traceMode THEN
@@ -3584,7 +3584,7 @@ BEGIN
 		MOV bootFlag, EAX
 		MOV bootFlag, EAX
 		MOV initRegs0,ESI
 		MOV initRegs0,ESI
 		MOV initRegs1, ECX
 		MOV initRegs1, ECX
-		
+
 		MOV fbadr, EDI
 		MOV fbadr, EDI
 		MOV fbInfoPtr, EDX
 		MOV fbInfoPtr, EDX
 	END;
 	END;
@@ -3629,11 +3629,11 @@ BEGIN
 	InitPages;	(* create page tables *)
 	InitPages;	(* create page tables *)
 	InitMemory;	(* switch on segmentation, paging and switch stack *)
 	InitMemory;	(* switch on segmentation, paging and switch stack *)
 	Trace.Green; Trace.StringLn("Ok"); Trace.Default;
 	Trace.Green; Trace.StringLn("Ok"); Trace.Default;
-	
-	
+
+
 	(*FOR i := 0 TO 1024*128 DO SYSTEM.PUT(fbadr+i, 0X)	END;*)
 	(*FOR i := 0 TO 1024*128 DO SYSTEM.PUT(fbadr+i, 0X)	END;*)
-	
-	
+
+
 	(* allocate empty memory block with enough space for at least one free block *)
 	(* allocate empty memory block with enough space for at least one free block *)
 	memBlockHead := SYSTEM.VAL (MemoryBlock, ADDRESSOF (initialMemBlock));
 	memBlockHead := SYSTEM.VAL (MemoryBlock, ADDRESSOF (initialMemBlock));
 	memBlockTail := memBlockHead;
 	memBlockTail := memBlockHead;
@@ -3647,9 +3647,9 @@ BEGIN
 			intHandler[i, j].handler := NIL
 			intHandler[i, j].handler := NIL
 		END
 		END
 	END;
 	END;
-	Trace.String("Machine done."); Trace.Ln; 
+	Trace.String("Machine done."); Trace.Ln;
 	default.valid := FALSE;	(* initialized later *)
 	default.valid := FALSE;	(* initialized later *)
-	
+
 
 
 END Init;
 END Init;
 
 

+ 3 - 3
source/EFI.Mod

@@ -92,13 +92,13 @@ TYPE GUID* = RECORD
 	Data4*: ARRAY 8 OF Int8;
 	Data4*: ARRAY 8 OF Int8;
 END;
 END;
 
 
-TYPE 
+TYPE
 	MemoryDescriptorPointer*= POINTER TO MemoryDescriptor;
 	MemoryDescriptorPointer*= POINTER TO MemoryDescriptor;
 	MemoryDescriptor* = RECORD
 	MemoryDescriptor* = RECORD
 		Type- : Int32;
 		Type- : Int32;
 		pad-: Int32;
 		pad-: Int32;
 		PhysicalStart-: PhysicalAddress;
 		PhysicalStart-: PhysicalAddress;
-		VirtualStart-: VirtualAddress; 
+		VirtualStart-: VirtualAddress;
 	(*	PhysicalStart-: Int64;
 	(*	PhysicalStart-: Int64;
 		VirtualStart-: Int64;	*)
 		VirtualStart-: Int64;	*)
 		NumberOfPages-: Int64;
 		NumberOfPages-: Int64;
@@ -129,7 +129,7 @@ TYPE TableHeader* = RECORD
 END;
 END;
 
 
 (* main EFI tables *)
 (* main EFI tables *)
-TYPE 
+TYPE
 SystemTable* = RECORD
 SystemTable* = RECORD
 	Hdr-: TableHeader;
 	Hdr-: TableHeader;
 	FirmwareVendor-{UNTRACED}: POINTER TO ARRAY OF Char16;
 	FirmwareVendor-{UNTRACED}: POINTER TO ARRAY OF Char16;

+ 4 - 4
source/EFIGraphicalConsole.Mod

@@ -439,13 +439,13 @@ TYPE
 		Trace.String("Graphical Console, depth = "); Trace.Address(depth); Trace.Ln;
 		Trace.String("Graphical Console, depth = "); Trace.Address(depth); Trace.Ln;
 
 
 		FOR i := 0 TO w*h*depth DIV 8-1  DO SYSTEM.PUT(adr+i,0)	END;
 		FOR i := 0 TO w*h*depth DIV 8-1  DO SYSTEM.PUT(adr+i,0)	END;
-		
-		
+
+
 		RenderChar("X"); RenderChar("X");
 		RenderChar("X"); RenderChar("X");
 
 
 		traceChar := Trace.Char;
 		traceChar := Trace.Char;
 		Trace.Char := RenderChar;
 		Trace.Char := RenderChar;
-		
+
 		Trace.String("Graphical Console started"); Trace.Ln;
 		Trace.String("Graphical Console started"); Trace.Ln;
 	END SetupConsole;
 	END SetupConsole;
 
 
@@ -456,7 +456,7 @@ TYPE
 		MakeFont(font);
 		MakeFont(font);
 		Trace.String("Graphical Console Exit"); Trace.Ln;
 		Trace.String("Graphical Console Exit"); Trace.Ln;
 	END Init;
 	END Init;
-	
+
 
 
 (*BEGIN
 (*BEGIN
 	Trace.String("Graphical Console Enter"); Trace.Ln;
 	Trace.String("Graphical Console Enter"); Trace.Ln;

+ 2 - 2
source/EFILib.Mod

@@ -99,7 +99,7 @@ BEGIN
 	memsize := 0;
 	memsize := 0;
 	FOR i := 0 TO numEntries-1 DO
 	FOR i := 0 TO numEntries-1 DO
 		MemMapElement := SYSTEM.VAL(EFI.MemoryDescriptorPointer, ADDRESSOF(MemMap[0])+i*DescriptorSize);
 		MemMapElement := SYSTEM.VAL(EFI.MemoryDescriptorPointer, ADDRESSOF(MemMap[0])+i*DescriptorSize);
-		
+
 (*		IF (MemMapElement.Type #  EFI.MTConventionalMemory *)
 (*		IF (MemMapElement.Type #  EFI.MTConventionalMemory *)
 		IF ( (MemMapElement.Type = EFI.MTRuntimeServicesCode) OR ( MemMapElement.Type = EFI.MTRuntimeServicesData)
 		IF ( (MemMapElement.Type = EFI.MTRuntimeServicesCode) OR ( MemMapElement.Type = EFI.MTRuntimeServicesData)
 			OR (MemMapElement.Type = EFI.MTUnusableMemory) OR (MemMapElement.Type = EFI.MTACPIReclaimMemory)
 			OR (MemMapElement.Type = EFI.MTUnusableMemory) OR (MemMapElement.Type = EFI.MTACPIReclaimMemory)
@@ -119,7 +119,7 @@ BEGIN
 			Trace.Ln;
 			Trace.Ln;
 
 
 
 
-			
+
 			IF (tmp # MemMapElement.PhysicalStart) THEN
 			IF (tmp # MemMapElement.PhysicalStart) THEN
 				SYSTEM.PUT(ADDRESS(adr+(numcritEntries*2+1+1)*8), MemMapElement.PhysicalStart);
 				SYSTEM.PUT(ADDRESS(adr+(numcritEntries*2+1+1)*8), MemMapElement.PhysicalStart);
 				tmp := MemMapElement.PhysicalStart+MemMapElement.NumberOfPages*LONG(EFI.PageSize);
 				tmp := MemMapElement.PhysicalStart+MemMapElement.NumberOfPages*LONG(EFI.PageSize);

+ 0 - 1
source/ExampleTextWriter.Mod

@@ -81,4 +81,3 @@ END ExampleTextWriter.
 
 
 System.Free ExampleTextWriter ~
 System.Free ExampleTextWriter ~
 ExampleTextWriter.Open
 ExampleTextWriter.Open
- 

+ 3 - 3
source/Files.Mod

@@ -220,7 +220,7 @@ TYPE
 			FOR i := ofs TO ofs + len -1 DO
 			FOR i := ofs TO ofs + len -1 DO
 				adr := a[i];
 				adr := a[i];
 				IF (adr = 0 ) THEN (* do nothing -- error should have been handled outside *)
 				IF (adr = 0 ) THEN (* do nothing -- error should have been handled outside *)
-				ELSE 
+				ELSE
 					IF (adr < 1) OR (adr > size) THEN HALT(InvalidAdr) END;
 					IF (adr < 1) OR (adr > size) THEN HALT(InvalidAdr) END;
 					EXCL(map[adr DIV SetSize], adr MOD SetSize);
 					EXCL(map[adr DIV SetSize], adr MOD SetSize);
 					DEC(used);
 					DEC(used);
@@ -235,7 +235,7 @@ TYPE
 			INCL(map[adr DIV SetSize], adr MOD SetSize);
 			INCL(map[adr DIV SetSize], adr MOD SetSize);
 			INC(used)
 			INC(used)
 		END MarkBlock;
 		END MarkBlock;
-		
+
 		PROCEDURE MarkBlocks*(CONST a: ARRAY OF Address; ofs, len: TSize);
 		PROCEDURE MarkBlocks*(CONST a: ARRAY OF Address; ofs, len: TSize);
 		VAR i: SIZE;  adr: Address;
 		VAR i: SIZE;  adr: Address;
 		BEGIN {EXCLUSIVE}
 		BEGIN {EXCLUSIVE}
@@ -243,7 +243,7 @@ TYPE
 			FOR i := ofs TO ofs + len -1 DO
 			FOR i := ofs TO ofs + len -1 DO
 				adr := a[i];
 				adr := a[i];
 				IF (adr = 0 ) THEN (* do nothing -- error should have been handled outside *)
 				IF (adr = 0 ) THEN (* do nothing -- error should have been handled outside *)
-				ELSE 
+				ELSE
 					IF (adr < 1) OR (adr > size) THEN HALT(InvalidAdr) END;
 					IF (adr < 1) OR (adr > size) THEN HALT(InvalidAdr) END;
 					INCL(map[adr DIV SetSize], adr MOD SetSize);
 					INCL(map[adr DIV SetSize], adr MOD SetSize);
 					INC(used);
 					INC(used);

+ 19 - 19
source/FoxAMD64Assembler.Mod

@@ -69,7 +69,7 @@ CONST
 	fpStackOperand= InstructionSet.fpStackOperand; directMemoryOffset= InstructionSet.directMemoryOffset;
 	fpStackOperand= InstructionSet.fpStackOperand; directMemoryOffset= InstructionSet.directMemoryOffset;
 	RXB = InstructionSet.RXB;
 	RXB = InstructionSet.RXB;
 	Src1Prefix = InstructionSet.Src1Prefix;
 	Src1Prefix = InstructionSet.Src1Prefix;
-	
+
 	(* limits *)
 	(* limits *)
 	maxNumberOperands = InstructionSet.maxNumberOperands;
 	maxNumberOperands = InstructionSet.maxNumberOperands;
 
 
@@ -211,7 +211,7 @@ TYPE
 		error-: BOOLEAN;
 		error-: BOOLEAN;
 		diagnostics: Diagnostics.Diagnostics;
 		diagnostics: Diagnostics.Diagnostics;
 		assembly: Assembly; (* for error position *)
 		assembly: Assembly; (* for error position *)
-		
+
 		(* overal state *)
 		(* overal state *)
 		cpuBits: Size; (* supported bit width for this cpu / target *)
 		cpuBits: Size; (* supported bit width for this cpu / target *)
 		cpuOptions: InstructionSet.CPUOptions;
 		cpuOptions: InstructionSet.CPUOptions;
@@ -274,7 +274,7 @@ TYPE
 			s.Get(msg);
 			s.Get(msg);
 			ErrorSS(msg1,msg);
 			ErrorSS(msg1,msg);
 		END ErrorSI;
 		END ErrorSI;
-		
+
 		PROCEDURE AddFixup (mode: SHORTINT; size: SHORTINT; pc: LONGINT; symbol: ObjectFile.Identifier; symbolOffset, displacement: LONGINT);
 		PROCEDURE AddFixup (mode: SHORTINT; size: SHORTINT; pc: LONGINT; symbol: ObjectFile.Identifier; symbolOffset, displacement: LONGINT);
 		VAR fixup: BinaryCode.Fixup; format: BinaryCode.FixupPatterns; id: ObjectFile.Identifier;
 		VAR fixup: BinaryCode.Fixup; format: BinaryCode.FixupPatterns; id: ObjectFile.Identifier;
 		BEGIN
 		BEGIN
@@ -313,7 +313,7 @@ TYPE
 					FOR i := 0 TO maxNumberOperands - 1 DO
 					FOR i := 0 TO maxNumberOperands - 1 DO
 						IF (i>=LEN(operands)) OR (operands[i].type = none) THEN (* no operand -> check if instruction has no operand here *)
 						IF (i>=LEN(operands)) OR (operands[i].type = none) THEN (* no operand -> check if instruction has no operand here *)
 							IF InstructionSet.instructions[instr].operands[i] # none THEN
 							IF InstructionSet.instructions[instr].operands[i] # none THEN
-								RETURN FALSE 
+								RETURN FALSE
 							END;
 							END;
 						ELSIF ~Matches(operands[i],InstructionSet.instructions[instr].operands[i]) THEN (* instruction operand type and this operand do not match *)
 						ELSIF ~Matches(operands[i],InstructionSet.instructions[instr].operands[i]) THEN (* instruction operand type and this operand do not match *)
 							RETURN FALSE
 							RETURN FALSE
@@ -325,8 +325,8 @@ TYPE
 				END MatchesInstruction;
 				END MatchesInstruction;
 			BEGIN
 			BEGIN
 				instr := InstructionSet.mnemonics[mnem].firstInstruction;
 				instr := InstructionSet.mnemonics[mnem].firstInstruction;
-				WHILE (instr <= InstructionSet.mnemonics[mnem].lastInstruction) & (~MatchesInstruction ()) DO 
-					INC (instr); 
+				WHILE (instr <= InstructionSet.mnemonics[mnem].lastInstruction) & (~MatchesInstruction ()) DO
+					INC (instr);
 				END;
 				END;
 
 
 				IF instr > InstructionSet.mnemonics[mnem].lastInstruction THEN
 				IF instr > InstructionSet.mnemonics[mnem].lastInstruction THEN
@@ -403,12 +403,12 @@ TYPE
 			BEGIN
 			BEGIN
 				RETURN {InstructionSet.cpuFPU} * InstructionSet.instructions[instr].cpuOptions # {}
 				RETURN {InstructionSet.cpuFPU} * InstructionSet.instructions[instr].cpuOptions # {}
 			END FPOperation;
 			END FPOperation;
-			
+
 			PROCEDURE IsPreREXPrefix(c1,c2: CHAR): BOOLEAN;
 			PROCEDURE IsPreREXPrefix(c1,c2: CHAR): BOOLEAN;
 			BEGIN
 			BEGIN
 				RETURN (c1 = CHR(opCode)) & ((c2 = 0F2X) OR (c2 = 0F3X) ) ;
 				RETURN (c1 = CHR(opCode)) & ((c2 = 0F2X) OR (c2 = 0F3X) ) ;
 			END IsPreREXPrefix;
 			END IsPreREXPrefix;
-			
+
 
 
 		BEGIN
 		BEGIN
 			IF (dump # NIL) & (lastPass) THEN
 			IF (dump # NIL) & (lastPass) THEN
@@ -512,14 +512,14 @@ TYPE
 							END
 							END
 						END;
 						END;
 						IF (operands[i].sizeInBytes = bits64) & ~(InstructionSet.optD64 IN bitwidthOptions) & ~FPOperation(instr) THEN
 						IF (operands[i].sizeInBytes = bits64) & ~(InstructionSet.optD64 IN bitwidthOptions) & ~FPOperation(instr) THEN
-							IF 
+							IF
 								(InstructionSet.instructions[instr].operands[i] = InstructionSet.regmem64)
 								(InstructionSet.instructions[instr].operands[i] = InstructionSet.regmem64)
 								OR
 								OR
 								(InstructionSet.instructions[instr].operands[i] = InstructionSet.mem)
 								(InstructionSet.instructions[instr].operands[i] = InstructionSet.mem)
-							 THEN 
+							 THEN
 								IF Trace THEN KernelLog.String(" rex prefix bits64 "); KernelLog.Ln; END;
 								IF Trace THEN KernelLog.String(" rex prefix bits64 "); KernelLog.Ln; END;
 								INCL(rexPrefix,rexW);
 								INCL(rexPrefix,rexW);
-							END; 
+							END;
 						END;
 						END;
 						IF InstructionSet.instructions[instr].operands[i] = InstructionSet.moffset64 THEN
 						IF InstructionSet.instructions[instr].operands[i] = InstructionSet.moffset64 THEN
 							IF Trace THEN KernelLog.String(" moffset64 "); KernelLog.Ln; END;
 							IF Trace THEN KernelLog.String(" moffset64 "); KernelLog.Ln; END;
@@ -572,8 +572,8 @@ TYPE
 				ASSERT(cpuBits = bits64);
 				ASSERT(cpuBits = bits64);
 				byte := 40H;
 				byte := 40H;
 				WHILE (oppos < LEN(opcode)-1) & IsPreREXPrefix(opcode[oppos], opcode[oppos+1]) DO
 				WHILE (oppos < LEN(opcode)-1) & IsPreREXPrefix(opcode[oppos], opcode[oppos+1]) DO
-					code.PutByte(ORD(opcode[oppos+1])); 
-					INC(oppos,2); 
+					code.PutByte(ORD(opcode[oppos+1]));
+					INC(oppos,2);
 				END;
 				END;
 				IF rexB IN rexPrefix THEN byte := byte + 1H END;
 				IF rexB IN rexPrefix THEN byte := byte + 1H END;
 				IF rexX IN rexPrefix THEN byte := byte + 2H END;
 				IF rexX IN rexPrefix THEN byte := byte + 2H END;
@@ -988,20 +988,20 @@ TYPE
 						END;
 						END;
 					| mem64Operand, mem128Operand: (* ignored *)
 					| mem64Operand, mem128Operand: (* ignored *)
 						IF Trace THEN KernelLog.String(" mem64/mem128 "); END;
 						IF Trace THEN KernelLog.String(" mem64/mem128 "); END;
-					| RXB: 
+					| RXB:
 						IF val # -1 THEN code.PutByte (val); val := -1 END;
 						IF val # -1 THEN code.PutByte (val); val := -1 END;
 						IF Trace THEN KernelLog.String(" RXB ");  TRACE(rexPrefix) END;
 						IF Trace THEN KernelLog.String(" RXB ");  TRACE(rexPrefix) END;
-						INC(oppos); 
+						INC(oppos);
 						byte := ORD(opcode[oppos]);
 						byte := ORD(opcode[oppos]);
 						IF ~(rexB IN rexPrefix) THEN byte := byte + 80H END;
 						IF ~(rexB IN rexPrefix) THEN byte := byte + 80H END;
 						IF ~(rexX IN rexPrefix) THEN byte := byte + 40H END;
 						IF ~(rexX IN rexPrefix) THEN byte := byte + 40H END;
 						IF ~(rexR IN rexPrefix) THEN byte := byte + 20H END;
 						IF ~(rexR IN rexPrefix) THEN byte := byte + 20H END;
-						code.PutByte(byte); 
+						code.PutByte(byte);
 					| Src1Prefix:
 					| Src1Prefix:
 						IF val # -1 THEN code.PutByte (val); val := -1 END;
 						IF val # -1 THEN code.PutByte (val); val := -1 END;
 						IF Trace THEN KernelLog.String(" Src1Prefix "); END;
 						IF Trace THEN KernelLog.String(" Src1Prefix "); END;
 						INC(oppos);
 						INC(oppos);
-						ASSERT((operands[1].type = xmm) OR (operands[1].type = ymm)); 
+						ASSERT((operands[1].type = xmm) OR (operands[1].type = ymm));
 						code.PutByte(ORD(opcode[oppos])+(0FH -InstructionSet.RegisterIndex(operands[1].register))*0x08);
 						code.PutByte(ORD(opcode[oppos])+(0FH -InstructionSet.RegisterIndex(operands[1].register))*0x08);
 					ELSE HALT(100) (* decoding error *)
 					ELSE HALT(100) (* decoding error *)
 					END;
 					END;
@@ -1513,11 +1513,11 @@ TYPE
 				IF size <= 0 THEN Error("invalid alignment size"); RETURN END;
 				IF size <= 0 THEN Error("invalid alignment size"); RETURN END;
 				pc := emitter.code.pc DIV 8; (* bytes *)
 				pc := emitter.code.pc DIV 8; (* bytes *)
 				WHILE pc MOD size # 0 DO
 				WHILE pc MOD size # 0 DO
-					emitter.code.PutByte(0); 
+					emitter.code.PutByte(0);
 					INC(pc);
 					INC(pc);
 				END;
 				END;
 			END Align;
 			END Align;
-			
+
 
 
 			PROCEDURE PutData (size: Size): BOOLEAN;
 			PROCEDURE PutData (size: Size): BOOLEAN;
 			VAR i: SIZE; x: HUGEINT; type:SHORTINT; ofs: Operand;
 			VAR i: SIZE; x: HUGEINT; type:SHORTINT; ofs: Operand;

+ 127 - 127
source/FoxAMD64InstructionSet.Mod

@@ -130,89 +130,89 @@ CONST
 	*)
 	*)
 	(** operand types, numbers assigned to the types do not have a special meaning **)
 	(** operand types, numbers assigned to the types do not have a special meaning **)
 	(* register classes first *)
 	(* register classes first *)
-	reg8*= 0; 
-	reg16*= 1; 
-	reg32*= 2; 
-	reg64*= 3; 
-	CRn*= 4; 
-	DRn*= 5; 
-	segReg*= 6; 
-	mmx*= 7; 
-	xmm*= 8; 
-	ymm*= 9; 
-	sti*= 10; 
+	reg8*= 0;
+	reg16*= 1;
+	reg32*= 2;
+	reg64*= 3;
+	CRn*= 4;
+	DRn*= 5;
+	segReg*= 6;
+	mmx*= 7;
+	xmm*= 8;
+	ymm*= 9;
+	sti*= 10;
 	(* other classes *)
 	(* other classes *)
-	mem*= 11; 
-	imm*= 12; 
-	ioffset*= 13; 
-	pntr1616*= 14; 
-	pntr1632*= 15; 
+	mem*= 11;
+	imm*= 12;
+	ioffset*= 13;
+	pntr1616*= 14;
+	pntr1632*= 15;
 	(* special registers *)
 	(* special registers *)
-	AL*= 16; 
-	AX*= 17; 
-	CL*= 18; 
-	CR8*= 19; 
-	CS*= 20; 
-	DS*= 21; 
-	DX*= 22; 
-	EAX*= 23; 
-	ECX*= 24; 
-	ES*= 25; 
-	FS*= 26; 
-	GS*= 27; 
-	RAX*= 28; 
-	SS*= 29; 
-	rAX*= 30; 
-	st0*= 31; 
+	AL*= 16;
+	AX*= 17;
+	CL*= 18;
+	CR8*= 19;
+	CS*= 20;
+	DS*= 21;
+	DX*= 22;
+	EAX*= 23;
+	ECX*= 24;
+	ES*= 25;
+	FS*= 26;
+	GS*= 27;
+	RAX*= 28;
+	SS*= 29;
+	rAX*= 30;
+	st0*= 31;
 	(* immediates and memory locations *)
 	(* immediates and memory locations *)
-	imm16*= 32; 
-	imm32*= 33; 
-	imm64*= 34; 
-	imm8*= 35; 
-	uimm16*= 36; 
-	uimm32*= 37; 
-	uimm8*= 38; 
-	simm16*= 39; 
-	simm32*= 40; 
-	simm8*= 41; 
-	mem256*= 42; 
-	mem128*= 43; 
-	mem16*= 44; 
-	mem32*= 45; 
-	mem64*= 46; 
-	mem8*= 47; 
-	moffset16*= 48; 
-	moffset32*= 49; 
-	moffset64*= 50; 
-	moffset8*= 51; 
-	rel16off*= 52; 
-	rel32off*= 53; 
-	rel8off*= 54; 
+	imm16*= 32;
+	imm32*= 33;
+	imm64*= 34;
+	imm8*= 35;
+	uimm16*= 36;
+	uimm32*= 37;
+	uimm8*= 38;
+	simm16*= 39;
+	simm32*= 40;
+	simm8*= 41;
+	mem256*= 42;
+	mem128*= 43;
+	mem16*= 44;
+	mem32*= 45;
+	mem64*= 46;
+	mem8*= 47;
+	moffset16*= 48;
+	moffset32*= 49;
+	moffset64*= 50;
+	moffset8*= 51;
+	rel16off*= 52;
+	rel32off*= 53;
+	rel8off*= 54;
 	(* ambivalent operand types *)
 	(* ambivalent operand types *)
-	reg3264*= 55; 
-	regmem16*= 56; 
-	regmem32*= 57; 
-	regmem64*= 58; 
-	regmem8*= 59; 
-	reg32mem16*= 60; 
-	mmxmem32*= 61; 
-	mmxmem64*= 62; 
-	xmmmem256*= 63; 
-	xmmmem128*= 64; 
-	xmmmem32*= 65; 
-	xmmmem64*= 66; 
-	xmmmem8*= 67; 
-	xmmmem16*= 68; 
-	ymmmem128*= 69; 
-	ymmmem256*= 70; 
+	reg3264*= 55;
+	regmem16*= 56;
+	regmem32*= 57;
+	regmem64*= 58;
+	regmem8*= 59;
+	reg32mem16*= 60;
+	mmxmem32*= 61;
+	mmxmem64*= 62;
+	xmmmem256*= 63;
+	xmmmem128*= 64;
+	xmmmem32*= 65;
+	xmmmem64*= 66;
+	xmmmem8*= 67;
+	xmmmem16*= 68;
+	ymmmem128*= 69;
+	ymmmem256*= 70;
 	(* miscellaneous *)
 	(* miscellaneous *)
-	one*= 71; 
-	three*= 72; 
-	vm32x*= 73; 
-	vm32y*= 74; 
-	vm64x*= 75; 
-	vm64y*= 76; 
-	m2z*= 77; 
+	one*= 71;
+	three*= 72;
+	vm32x*= 73;
+	vm32y*= 74;
+	vm64x*= 75;
+	vm64y*= 76;
+	m2z*= 77;
 
 
 	(** prefixes **)
 	(** prefixes **)
 	prfOP* = 066H;
 	prfOP* = 066H;
@@ -317,20 +317,20 @@ CONST
 	regR8*= 104; regR9*= 105; regR10*= 106; regR11*= 107; regR12*= 108; regR13*= 109; regR14*= 110; regR15*= 111;
 	regR8*= 104; regR9*= 105; regR10*= 106; regR11*= 107; regR12*= 108; regR13*= 109; regR14*= 110; regR15*= 111;
 	regRIP*= 112;
 	regRIP*= 112;
 	(** other registers **)
 	(** other registers **)
-	regES*= 128; regCS*= 129; regSS*= 130; regDS*= 131; regFS*= 132; regGS*= 133; regCR0*= 134; regCR1*= 135; 
-	regCR2*= 136; regCR3*= 137; regCR4*= 138; regCR5*= 139; regCR6*= 140; regCR7*= 141; regCR8*= 142; regCR9*= 143; 
-	regCR10*= 144; regCR11*= 145; regCR12*= 146; regCR13*= 147; regCR14*= 148; regCR15*= 149; regDR0*= 150; regDR1*= 151; 
-	regDR2*= 152; regDR3*= 153; regDR4*= 154; regDR5*= 155; regDR6*= 156; regDR7*= 157; regDR8*= 158; regDR9*= 159; 
-	regDR10*= 160; regDR11*= 161; regDR12*= 162; regDR13*= 163; regDR14*= 164; regDR15*= 165; regST0*= 166; regST1*= 167; 
-	regST2*= 168; regST3*= 169; regST4*= 170; regST5*= 171; regST6*= 172; regST7*= 173; regXMM0*= 174; regXMM1*= 175; 
-	regXMM2*= 176; regXMM3*= 177; regXMM4*= 178; regXMM5*= 179; regXMM6*= 180; regXMM7*= 181; regXMM8*= 182; regXMM9*= 183; 
-	regXMM10*= 184; regXMM11*= 185; regXMM12*= 186; regXMM13*= 187; regXMM14*= 188; regXMM15*= 189; regMMX0*= 190; regMMX1*= 191; 
-	regMMX2*= 192; regMMX3*= 193; regMMX4*= 194; regMMX5*= 195; regMMX6*= 196; regMMX7*= 197; regYMM0*= 198; regYMM1*= 199; 
-	regYMM2*= 200; regYMM3*= 201; regYMM4*= 202; regYMM5*= 203; regYMM6*= 204; regYMM7*= 205; regYMM8*= 206; regYMM9*= 207; 
-	regYMM10*= 208; regYMM11*= 209; regYMM12*= 210; regYMM13*= 211; regYMM14*= 212; regYMM15*= 213; 
-	numberRegisters*= 214; 
+	regES*= 128; regCS*= 129; regSS*= 130; regDS*= 131; regFS*= 132; regGS*= 133; regCR0*= 134; regCR1*= 135;
+	regCR2*= 136; regCR3*= 137; regCR4*= 138; regCR5*= 139; regCR6*= 140; regCR7*= 141; regCR8*= 142; regCR9*= 143;
+	regCR10*= 144; regCR11*= 145; regCR12*= 146; regCR13*= 147; regCR14*= 148; regCR15*= 149; regDR0*= 150; regDR1*= 151;
+	regDR2*= 152; regDR3*= 153; regDR4*= 154; regDR5*= 155; regDR6*= 156; regDR7*= 157; regDR8*= 158; regDR9*= 159;
+	regDR10*= 160; regDR11*= 161; regDR12*= 162; regDR13*= 163; regDR14*= 164; regDR15*= 165; regST0*= 166; regST1*= 167;
+	regST2*= 168; regST3*= 169; regST4*= 170; regST5*= 171; regST6*= 172; regST7*= 173; regXMM0*= 174; regXMM1*= 175;
+	regXMM2*= 176; regXMM3*= 177; regXMM4*= 178; regXMM5*= 179; regXMM6*= 180; regXMM7*= 181; regXMM8*= 182; regXMM9*= 183;
+	regXMM10*= 184; regXMM11*= 185; regXMM12*= 186; regXMM13*= 187; regXMM14*= 188; regXMM15*= 189; regMMX0*= 190; regMMX1*= 191;
+	regMMX2*= 192; regMMX3*= 193; regMMX4*= 194; regMMX5*= 195; regMMX6*= 196; regMMX7*= 197; regYMM0*= 198; regYMM1*= 199;
+	regYMM2*= 200; regYMM3*= 201; regYMM4*= 202; regYMM5*= 203; regYMM6*= 204; regYMM7*= 205; regYMM8*= 206; regYMM9*= 207;
+	regYMM10*= 208; regYMM11*= 209; regYMM12*= 210; regYMM13*= 211; regYMM14*= 212; regYMM15*= 213;
+	numberRegisters*= 214;
 
 
-VAR 
+VAR
 	opAAA*,
 	opAAA*,
 	opAAD*,
 	opAAD*,
 	opAAM*,
 	opAAM*,
@@ -1403,10 +1403,10 @@ VAR
 	(* repository *)
 	(* repository *)
 	mnemonics-: ARRAY maxNumberMnemonics OF Mnemonic;
 	mnemonics-: ARRAY maxNumberMnemonics OF Mnemonic;
 	numberMnemonics: LONGINT;
 	numberMnemonics: LONGINT;
-	
+
 	instructions-: ARRAY maxNumberInstructions OF Instruction;
 	instructions-: ARRAY maxNumberInstructions OF Instruction;
-	numberInstructions: LONGINT; 
-	
+	numberInstructions: LONGINT;
+
 	registers-: ARRAY numberRegisters OF Register;
 	registers-: ARRAY numberRegisters OF Register;
 	registersByClass-: ARRAY sti+1 OF ARRAY 17 OF LONGINT;
 	registersByClass-: ARRAY sti+1 OF ARRAY 17 OF LONGINT;
 
 
@@ -1596,26 +1596,26 @@ VAR
 					ELSIF name = "vm64x" THEN RETURN vm64x
 					ELSIF name = "vm64x" THEN RETURN vm64x
 					ELSIF name = "vm64y" THEN RETURN vm64y
 					ELSIF name = "vm64y" THEN RETURN vm64y
 					ELSIF name = "m2z" THEN RETURN m2z
 					ELSIF name = "m2z" THEN RETURN m2z
-					ELSE HALT(200) 
+					ELSE HALT(200)
 					END;
 					END;
 				END StringToOperand;
 				END StringToOperand;
 
 
 			PROCEDURE ParseOperand(CONST op: ARRAY OF CHAR; VAR at: LONGINT): SHORTINT;
 			PROCEDURE ParseOperand(CONST op: ARRAY OF CHAR; VAR at: LONGINT): SHORTINT;
 			VAR name: ARRAY 32 OF CHAR; i: LONGINT;
 			VAR name: ARRAY 32 OF CHAR; i: LONGINT;
 			BEGIN
 			BEGIN
-				i := 0; 
+				i := 0;
 				WHILE(op[at] # 0X) & (op[at] # ",") DO
 				WHILE(op[at] # 0X) & (op[at] # ",") DO
 					name[i] := op[at];
 					name[i] := op[at];
-					INC(i); INC(at); 
+					INC(i); INC(at);
 				END;
 				END;
 				name[i] := 0X;
 				name[i] := 0X;
 				IF op[at] = "," THEN INC(at) END;
 				IF op[at] = "," THEN INC(at) END;
-				RETURN StringToOperand(name); 
+				RETURN StringToOperand(name);
 			END ParseOperand;
 			END ParseOperand;
 
 
 	(** setup instruction and mnemonic tables **)
 	(** setup instruction and mnemonic tables **)
 	PROCEDURE InitInstructions;
 	PROCEDURE InitInstructions;
-	VAR 
+	VAR
 
 
 		PROCEDURE AddMnemonic(VAR op: LONGINT; CONST name: ARRAY OF CHAR);
 		PROCEDURE AddMnemonic(VAR op: LONGINT; CONST name: ARRAY OF CHAR);
 		BEGIN
 		BEGIN
@@ -1739,13 +1739,13 @@ VAR
 
 
 			all symbols 8 bit wide, numbers also 8 bits wide
 			all symbols 8 bit wide, numbers also 8 bits wide
 		*)
 		*)
-		
+
 			PROCEDURE GetCode(CONST charcode: ARRAY OF CHAR; VAR at: LONGINT; VAR cd: ARRAY OF CHAR): BOOLEAN;
 			PROCEDURE GetCode(CONST charcode: ARRAY OF CHAR; VAR at: LONGINT; VAR cd: ARRAY OF CHAR): BOOLEAN;
 			VAR i: LONGINT;
 			VAR i: LONGINT;
 			BEGIN
 			BEGIN
 				WHILE(charcode[at] = " ") DO INC(at) END;
 				WHILE(charcode[at] = " ") DO INC(at) END;
 				IF charcode[at] = 0X THEN RETURN FALSE END;
 				IF charcode[at] = 0X THEN RETURN FALSE END;
-				i := 0; 
+				i := 0;
 				WHILE (charcode[at] # " ") & (charcode[at] # 0X) DO
 				WHILE (charcode[at] # " ") & (charcode[at] # 0X) DO
 					cd[i] := charcode[at];
 					cd[i] := charcode[at];
 					INC(i); INC(at);
 					INC(i); INC(at);
@@ -1753,7 +1753,7 @@ VAR
 				cd[i] := 0X;
 				cd[i] := 0X;
 				RETURN TRUE;
 				RETURN TRUE;
 			END GetCode;
 			END GetCode;
-		
+
 		VAR i,k,length: SHORTINT; ch1,ch2: CHAR; cdc: ARRAY 32 OF CHAR; at,mul,val: LONGINT;
 		VAR i,k,length: SHORTINT; ch1,ch2: CHAR; cdc: ARRAY 32 OF CHAR; at,mul,val: LONGINT;
 		BEGIN
 		BEGIN
 			i := 0; k := 0; at := 0;
 			i := 0; k := 0; at := 0;
@@ -1769,30 +1769,30 @@ VAR
 						IF (cdc[i] ="0") OR (cdc[i]="X") THEN
 						IF (cdc[i] ="0") OR (cdc[i]="X") THEN
 							mul := mul DIV 2;
 							mul := mul DIV 2;
 						ELSIF cdc[i] = "1" THEN
 						ELSIF cdc[i] = "1" THEN
-							INC(val, mul); 
+							INC(val, mul);
 							mul := mul DIV 2;
 							mul := mul DIV 2;
 						ELSIF cdc[i] = "." (* next *) THEN
 						ELSIF cdc[i] = "." (* next *) THEN
 						ELSIF cdc[i] = "c" THEN
 						ELSIF cdc[i] = "c" THEN
-							INC(i); ASSERT(cdc[i] ="o"); 
+							INC(i); ASSERT(cdc[i] ="o");
 							INC(i); ASSERT(cdc[i] ="u");
 							INC(i); ASSERT(cdc[i] ="u");
 							INC(i); ASSERT(cdc[i] ="n");
 							INC(i); ASSERT(cdc[i] ="n");
 							INC(i); ASSERT(cdc[i] ="t");
 							INC(i); ASSERT(cdc[i] ="t");
 							code[k] := CHR(CountPrefix);
 							code[k] := CHR(CountPrefix);
 							mul := mul DIV 10H;
 							mul := mul DIV 10H;
 						ELSIF cdc[i] = "d" THEN
 						ELSIF cdc[i] = "d" THEN
-							INC(i); ASSERT(cdc[i] ="e"); 
+							INC(i); ASSERT(cdc[i] ="e");
 							INC(i); ASSERT(cdc[i] ="s");
 							INC(i); ASSERT(cdc[i] ="s");
 							INC(i); ASSERT(cdc[i] ="t");
 							INC(i); ASSERT(cdc[i] ="t");
 							code[k] := CHR(DestPrefix);
 							code[k] := CHR(DestPrefix);
 							mul := mul DIV 10H;
 							mul := mul DIV 10H;
 						ELSIF cdc[i] = "s" THEN
 						ELSIF cdc[i] = "s" THEN
-							INC(i); ASSERT(cdc[i] ="r"); 
+							INC(i); ASSERT(cdc[i] ="r");
 							INC(i); ASSERT(cdc[i] ="c");
 							INC(i); ASSERT(cdc[i] ="c");
 							code[k] := CHR(Src1Prefix);
 							code[k] := CHR(Src1Prefix);
-							ASSERT(mul = 64); 
-							IF (cdc[i+1] = "1") THEN 
+							ASSERT(mul = 64);
+							IF (cdc[i+1] = "1") THEN
 								INC(i);
 								INC(i);
-							ELSIF (cdc[i+1] = "2") THEN 
+							ELSIF (cdc[i+1] = "2") THEN
 								code[k] := CHR(Src2Prefix);
 								code[k] := CHR(Src2Prefix);
 								INC(i);
 								INC(i);
 							END;
 							END;
@@ -1804,7 +1804,7 @@ VAR
 					INC(k);
 					INC(k);
 					code[k] := CHR(val); INC(k);
 					code[k] := CHR(val); INC(k);
 				ELSIF (ch1="R") THEN
 				ELSIF (ch1="R") THEN
-					code[k] := CHR(RXB); INC(k); 
+					code[k] := CHR(RXB); INC(k);
 					IF (cdc = "RXB.00001") OR  (cdc ="RXB.01") THEN
 					IF (cdc = "RXB.00001") OR  (cdc ="RXB.01") THEN
 						code[k] := CHR(1);
 						code[k] := CHR(1);
 					ELSIF (cdc ="RXB.00011") OR (cdc = "RXB.03") THEN
 					ELSIF (cdc ="RXB.00011") OR (cdc = "RXB.03") THEN
@@ -1830,12 +1830,12 @@ VAR
 						CASE ch2 OF
 						CASE ch2 OF
 							'r': code[k] := CHR(modRMBoth); INC(k);
 							'r': code[k] := CHR(modRMBoth); INC(k);
 							|'0'..'7': code[k] := CHR(modRMExtension); INC(k); code[k] := CHR(HexOrd(ch2)); INC(k);
 							|'0'..'7': code[k] := CHR(modRMExtension); INC(k); code[k] := CHR(HexOrd(ch2)); INC(k);
-						ELSE 
-							IF cdc = "/imm8" THEN 
+						ELSE
+							IF cdc = "/imm8" THEN
 								(*todo*)
 								(*todo*)
-							ELSIF cdc = "/is4" THEN 
+							ELSIF cdc = "/is4" THEN
 								(*todo*)
 								(*todo*)
-							ELSIF cdc = "/ib" THEN 
+							ELSIF cdc = "/ib" THEN
 								code[k] := CHR(ib); INC(k);
 								code[k] := CHR(ib); INC(k);
 							ELSE
 							ELSE
 								HALT(100)
 								HALT(100)
@@ -1855,7 +1855,7 @@ VAR
 							|'w': code[k] := CHR(iw); INC(k);
 							|'w': code[k] := CHR(iw); INC(k);
 							|'d': code[k] := CHR(id); INC(k);
 							|'d': code[k] := CHR(id); INC(k);
 							|'q': code[k] := CHR(iq); INC(k);
 							|'q': code[k] := CHR(iq); INC(k);
-						ELSE 
+						ELSE
 							IF cdc = "is4" THEN
 							IF cdc = "is4" THEN
 								(*todo*)
 								(*todo*)
 							ELSIF cdc = "is5" THEN
 							ELSIF cdc = "is5" THEN
@@ -1895,7 +1895,7 @@ VAR
 				INC(k);
 				INC(k);
 			END;
 			END;
 		END EncodeV;
 		END EncodeV;
-		
+
 		PROCEDURE AddInstructionV(mnemonic: LONGINT; CONST operands, code: ARRAY OF CHAR);
 		PROCEDURE AddInstructionV(mnemonic: LONGINT; CONST operands, code: ARRAY OF CHAR);
 		VAR i, at: LONGINT; name: ARRAY 32 OF CHAR;
 		VAR i, at: LONGINT; name: ARRAY 32 OF CHAR;
 		BEGIN
 		BEGIN
@@ -1905,9 +1905,9 @@ VAR
 				INC(i);
 				INC(i);
 			END;
 			END;
 			ASSERT(operands[at] = 0X); (* all operands parsed *)
 			ASSERT(operands[at] = 0X); (* all operands parsed *)
-			
+
 			EncodeV(code,instructions[numberInstructions].code);
 			EncodeV(code,instructions[numberInstructions].code);
-			
+
 			COPY(mnemonics[mnemonic].name,name);
 			COPY(mnemonics[mnemonic].name,name);
 			IF mnemonics[mnemonic].firstInstruction = -1 THEN
 			IF mnemonics[mnemonic].firstInstruction = -1 THEN
 				mnemonics[mnemonic].firstInstruction := numberInstructions;
 				mnemonics[mnemonic].firstInstruction := numberInstructions;
@@ -1922,9 +1922,9 @@ VAR
 
 
 		PROCEDURE AddInstruction(mnemonic: LONGINT; CONST op,code: ARRAY OF CHAR; bitwidthOptions, cpuOptions: SET);
 		PROCEDURE AddInstruction(mnemonic: LONGINT; CONST op,code: ARRAY OF CHAR; bitwidthOptions, cpuOptions: SET);
 		VAR i: SHORTINT; at: LONGINT;
 		VAR i: SHORTINT; at: LONGINT;
-		
-		
-			
+
+
+
 		BEGIN
 		BEGIN
 			i := 0; at := 0;
 			i := 0; at := 0;
 			WHILE (i<maxNumberOperands) DO
 			WHILE (i<maxNumberOperands) DO
@@ -1935,7 +1935,7 @@ VAR
 
 
 			instructions[numberInstructions].bitwidthOptions := bitwidthOptions;
 			instructions[numberInstructions].bitwidthOptions := bitwidthOptions;
 			instructions[numberInstructions].cpuOptions := cpuOptions;
 			instructions[numberInstructions].cpuOptions := cpuOptions;
-			
+
 			IF mnemonics[mnemonic].firstInstruction = -1 THEN
 			IF mnemonics[mnemonic].firstInstruction = -1 THEN
 				mnemonics[mnemonic].firstInstruction := numberInstructions;
 				mnemonics[mnemonic].firstInstruction := numberInstructions;
 				mnemonics[mnemonic].lastInstruction := numberInstructions;
 				mnemonics[mnemonic].lastInstruction := numberInstructions;
@@ -1943,7 +1943,7 @@ VAR
 				ASSERT(mnemonics[mnemonic].lastInstruction = numberInstructions-1);
 				ASSERT(mnemonics[mnemonic].lastInstruction = numberInstructions-1);
 				mnemonics[mnemonic].lastInstruction := numberInstructions;
 				mnemonics[mnemonic].lastInstruction := numberInstructions;
 			END;
 			END;
-			
+
 			INC(numberInstructions);
 			INC(numberInstructions);
 		END AddInstruction;
 		END AddInstruction;
 
 
@@ -1956,9 +1956,9 @@ VAR
 
 
 
 
 	BEGIN
 	BEGIN
-		numberMnemonics := 0; 
-		numberInstructions := 0; 
-		
+		numberMnemonics := 0;
+		numberInstructions := 0;
+
 		AddMnemonic(opAAA, "AAA");
 		AddMnemonic(opAAA, "AAA");
 		AddMnemonic(opAAD, "AAD");
 		AddMnemonic(opAAD, "AAD");
 		AddMnemonic(opAAM, "AAM");
 		AddMnemonic(opAAM, "AAM");
@@ -2969,7 +2969,7 @@ VAR
 		AddMnemonic(opXOR, "XOR");
 		AddMnemonic(opXOR, "XOR");
 		AddMnemonic(opXORPD, "XORPD");
 		AddMnemonic(opXORPD, "XORPD");
 		AddMnemonic(opXORPS, "XORPS");
 		AddMnemonic(opXORPS, "XORPS");
-		
+
 
 
 		AddInstruction(opAAA, "", "37", {optNot64}, {cpu8086});
 		AddInstruction(opAAA, "", "37", {optNot64}, {cpu8086});
 		AddInstruction(opAAD, "", "D50A", {optNot64}, {cpu8086});
 		AddInstruction(opAAD, "", "D50A", {optNot64}, {cpu8086});

+ 53 - 53
source/FoxAMDBackend.Mod

@@ -558,7 +558,7 @@ TYPE
 				ASSERT(~error);
 				ASSERT(~error);
 			ELSIF cpuBits=64 THEN
 			ELSIF cpuBits=64 THEN
 				NEW(physicalRegisters64, backend.forceFPU, backend.cooperative); physicalRegisters := physicalRegisters64; error := ~emitter.SetBits(64);
 				NEW(physicalRegisters64, backend.forceFPU, backend.cooperative); physicalRegisters := physicalRegisters64; error := ~emitter.SetBits(64);
-				opBP := opRBP; opSP := opRSP; 
+				opBP := opRBP; opSP := opRSP;
 				opRA := registerOperands[RAX]; opRC := registerOperands[RCX];
 				opRA := registerOperands[RAX]; opRC := registerOperands[RCX];
 				opRB := registerOperands[RBX]; opRD := registerOperands[RDX];
 				opRB := registerOperands[RBX]; opRD := registerOperands[RDX];
 				opRDI := registerOperands[RDI]; opRSI := registerOperands[RSI];
 				opRDI := registerOperands[RDI]; opRSI := registerOperands[RSI];
@@ -606,7 +606,7 @@ TYPE
 			END;
 			END;
 			ASSERT(fpStackPointer = 0);
 			ASSERT(fpStackPointer = 0);
 			CheckEmptySpillStack;
 			CheckEmptySpillStack;
-			IF backend.cooperative THEN 
+			IF backend.cooperative THEN
 				UnmapTicket(ap);
 				UnmapTicket(ap);
 			END;
 			END;
 			error := error OR emitter.error;
 			error := error OR emitter.error;
@@ -855,7 +855,7 @@ TYPE
 		END GetTemporaryRegister;
 		END GetTemporaryRegister;
 
 
 		PROCEDURE GetImmediateMem(CONST vop: IntermediateCode.Operand; part: LONGINT; VAR imm: Assembler.Operand);
 		PROCEDURE GetImmediateMem(CONST vop: IntermediateCode.Operand; part: LONGINT; VAR imm: Assembler.Operand);
-		VAR data: IntermediateCode.Section;pc: LONGINT; source, dest: Assembler.Operand; ticket: Ticket; 
+		VAR data: IntermediateCode.Section;pc: LONGINT; source, dest: Assembler.Operand; ticket: Ticket;
 		BEGIN
 		BEGIN
 			data := GetDataSection();
 			data := GetDataSection();
 			pc := IntermediateBackend.EnterImmediate(data,vop);
 			pc := IntermediateBackend.EnterImmediate(data,vop);
@@ -890,12 +890,12 @@ TYPE
 				value := value DIV 10000H DIV 10000H;
 				value := value DIV 10000H DIV 10000H;
 				RETURN (value = 0) OR (value=-1);
 				RETURN (value = 0) OR (value=-1);
 			END IsImm32;
 			END IsImm32;
-			
+
 			PROCEDURE IsSignedImm32(value: HUGEINT): BOOLEAN;
 			PROCEDURE IsSignedImm32(value: HUGEINT): BOOLEAN;
 			BEGIN
 			BEGIN
 				RETURN (value <= MAX(SIGNED32)) & (value >= MIN(SIGNED32));
 				RETURN (value <= MAX(SIGNED32)) & (value >= MIN(SIGNED32));
 			END IsSignedImm32;
 			END IsSignedImm32;
-			
+
 
 
 		BEGIN
 		BEGIN
 			ASSERT(virtual.mode = IntermediateCode.ModeImmediate);
 			ASSERT(virtual.mode = IntermediateCode.ModeImmediate);
@@ -910,8 +910,8 @@ TYPE
 
 
 				IF virtual.symbol.name # "" THEN size := SHORT(type.sizeInBits DIV 8);
 				IF virtual.symbol.name # "" THEN size := SHORT(type.sizeInBits DIV 8);
 				ELSIF forbidden16Bit & IsImm16(value) & ~(IsImm8(value)) THEN size := Assembler.bits32;
 				ELSIF forbidden16Bit & IsImm16(value) & ~(IsImm8(value)) THEN size := Assembler.bits32;
-				ELSIF (type.sizeInBits = 64) & (type.form = IntermediateCode.UnsignedInteger) & (value > MAX(LONGINT)) THEN 
-					size := 8; (* don't use negative signed 32-bit value  to encode 64-bit unsigned value! *)	
+				ELSIF (type.sizeInBits = 64) & (type.form = IntermediateCode.UnsignedInteger) & (value > MAX(LONGINT)) THEN
+					size := 8; (* don't use negative signed 32-bit value  to encode 64-bit unsigned value! *)
 				ELSE size := 0
 				ELSE size := 0
 				END;
 				END;
 				Assembler.InitImm(physical,size ,value);
 				Assembler.InitImm(physical,size ,value);
@@ -984,7 +984,7 @@ TYPE
 				Assembler.SetSymbol(physical,virtual.symbol.name,virtual.symbol.fingerprint,virtual.symbolOffset,virtual.offset+ (cpuBits DIV 8) *part);
 				Assembler.SetSymbol(physical,virtual.symbol.name,virtual.symbol.fingerprint,virtual.symbolOffset,virtual.offset+ (cpuBits DIV 8) *part);
 			END;
 			END;
 		END GetMemory;
 		END GetMemory;
-		
+
 		PROCEDURE GetRegister(CONST virtual: IntermediateCode.Operand; part:LONGINT; VAR physical: Assembler.Operand; VAR ticket: Ticket);
 		PROCEDURE GetRegister(CONST virtual: IntermediateCode.Operand; part:LONGINT; VAR physical: Assembler.Operand; VAR ticket: Ticket);
 		VAR type: IntermediateCode.Type; virtualRegister, tempReg: LONGINT;
 		VAR type: IntermediateCode.Type; virtualRegister, tempReg: LONGINT;
 			tmp,imm: Assembler.Operand; index: LONGINT;
 			tmp,imm: Assembler.Operand; index: LONGINT;
@@ -1281,13 +1281,13 @@ TYPE
 		PROCEDURE EmitEnter(CONST instruction: IntermediateCode.Instruction);
 		PROCEDURE EmitEnter(CONST instruction: IntermediateCode.Instruction);
 		VAR op1,imm,target: Assembler.Operand; cc,size,numberMachineWords,destPC,firstPC,secondPC,x: LONGINT; body: SyntaxTree.Body; name: Basic.SegmentedName;
 		VAR op1,imm,target: Assembler.Operand; cc,size,numberMachineWords,destPC,firstPC,secondPC,x: LONGINT; body: SyntaxTree.Body; name: Basic.SegmentedName;
 		parametersSize: SIZE;
 		parametersSize: SIZE;
-		CONST initialize=TRUE; FirstOffset = 5; SecondOffset = 11; 
+		CONST initialize=TRUE; FirstOffset = 5; SecondOffset = 11;
 		BEGIN
 		BEGIN
 			stackSize := SHORT(instruction.op2.intValue);
 			stackSize := SHORT(instruction.op2.intValue);
 			size := stackSize;
 			size := stackSize;
 
 
 			INC(traceStackSize, stackSize);
 			INC(traceStackSize, stackSize);
-			
+
 			IF initialize THEN
 			IF initialize THEN
 				(* always including this instruction make trace insertion possible *)
 				(* always including this instruction make trace insertion possible *)
 				IF backend.traceable THEN
 				IF backend.traceable THEN
@@ -1372,7 +1372,7 @@ TYPE
 					emitter.Emit1(InstructionSet.opPOP,opRDI);
 					emitter.Emit1(InstructionSet.opPOP,opRDI);
 					emitter.Emit1(InstructionSet.opPOP,opRB);
 					emitter.Emit1(InstructionSet.opPOP,opRB);
 				END;
 				END;
-				
+
 			END;
 			END;
 		END EmitLeave;
 		END EmitLeave;
 
 
@@ -1433,7 +1433,7 @@ TYPE
 		BEGIN
 		BEGIN
 			sizeInBytes := SHORTINT(vdest.type.sizeInBits DIV 8);
 			sizeInBytes := SHORTINT(vdest.type.sizeInBits DIV 8);
 			stackSize := sizeInBytes;
 			stackSize := sizeInBytes;
-			Basic.Align(stackSize, cpuBits DIV 8); 
+			Basic.Align(stackSize, cpuBits DIV 8);
 			IF vdest.type.form IN IntermediateCode.Integer THEN
 			IF vdest.type.form IN IntermediateCode.Integer THEN
 				(* e.g. in SYSTEM.VAL(LONGINT, r) *)
 				(* e.g. in SYSTEM.VAL(LONGINT, r) *)
 				IF vsrc.mode = IntermediateCode.ModeMemory THEN
 				IF vsrc.mode = IntermediateCode.ModeMemory THEN
@@ -1575,7 +1575,7 @@ TYPE
 		PROCEDURE EmitConvertFloat(CONST instruction: IntermediateCode.Instruction);
 		PROCEDURE EmitConvertFloat(CONST instruction: IntermediateCode.Instruction);
 		VAR destType, srcType, dtype: IntermediateCode.Type; dest,src,espm,imm: Assembler.Operand; sizeInBytes, index: LONGINT;
 		VAR destType, srcType, dtype: IntermediateCode.Type; dest,src,espm,imm: Assembler.Operand; sizeInBytes, index: LONGINT;
 		temp, temp2, temp3, temp4, zero: Assembler.Operand; ticket: Ticket; vdest, vsrc: IntermediateCode.Operand;
 		temp, temp2, temp3, temp4, zero: Assembler.Operand; ticket: Ticket; vdest, vsrc: IntermediateCode.Operand;
-			unsigned: BOOLEAN; 
+			unsigned: BOOLEAN;
 		BEGIN
 		BEGIN
 			vdest := instruction.op1; vsrc := instruction.op2;
 			vdest := instruction.op1; vsrc := instruction.op2;
 			srcType := vsrc.type;
 			srcType := vsrc.type;
@@ -1622,9 +1622,9 @@ TYPE
 						sizeInBytes := 8;
 						sizeInBytes := 8;
 						Assembler.InitImm(zero,0,0);
 						Assembler.InitImm(zero,0,0);
 						emitter.Emit1(InstructionSet.opPUSH,zero);
 						emitter.Emit1(InstructionSet.opPUSH,zero);
-						EmitPush(vsrc,Low);						
+						EmitPush(vsrc,Low);
 					ELSIF unsigned & ( vsrc.type.sizeInBits = IntermediateCode.Bits32) THEN (* UNSIGNED32 on 64-bit *)
 					ELSIF unsigned & ( vsrc.type.sizeInBits = IntermediateCode.Bits32) THEN (* UNSIGNED32 on 64-bit *)
-						MakeRegister(vsrc, Low, src); 
+						MakeRegister(vsrc, Low, src);
 						index := src.register;
 						index := src.register;
 						index := index MOD 32 + RAX;
 						index := index MOD 32 + RAX;
 						src := registerOperands[index];
 						src := registerOperands[index];
@@ -1915,10 +1915,10 @@ TYPE
 
 
 				(* make sure that result registers are not used during emission of Low / High *)
 				(* make sure that result registers are not used during emission of Low / High *)
 				lowReserved := physicalRegisters.Reserved(register);
 				lowReserved := physicalRegisters.Reserved(register);
-				physicalRegisters.SetReserved(register, TRUE); 
+				physicalRegisters.SetReserved(register, TRUE);
 				highReserved := physicalRegisters.Reserved(highRegister);
 				highReserved := physicalRegisters.Reserved(highRegister);
 				physicalRegisters.SetReserved(highRegister,TRUE);
 				physicalRegisters.SetReserved(highRegister,TRUE);
-				
+
 				MakeOperand(instruction.op1,Low,op, NIL);
 				MakeOperand(instruction.op1,Low,op, NIL);
 				IF Assembler.SameOperand(op, resultHigh) THEN
 				IF Assembler.SameOperand(op, resultHigh) THEN
 					emitter.Emit2(InstructionSet.opXCHG, result, resultHigh); (* low register already mapped ok *)
 					emitter.Emit2(InstructionSet.opXCHG, result, resultHigh); (* low register already mapped ok *)
@@ -2290,7 +2290,7 @@ TYPE
 
 
 		BEGIN
 		BEGIN
 			IF IntermediateCode.IsConstantInteger(instruction.op3,value) & IntermediateBackend.PowerOf2(value,exp) THEN
 			IF IntermediateCode.IsConstantInteger(instruction.op3,value) & IntermediateBackend.PowerOf2(value,exp) THEN
-				IF instruction.opcode = IntermediateCode.div THEN					
+				IF instruction.opcode = IntermediateCode.div THEN
 					IntermediateCode.InitImmediate(iop3, IntermediateCode.uint32, exp);
 					IntermediateCode.InitImmediate(iop3, IntermediateCode.uint32, exp);
 					IntermediateCode.InitInstruction(inst, Basic.invalidPosition, IntermediateCode.shr, instruction.op1, instruction.op2, iop3);
 					IntermediateCode.InitInstruction(inst, Basic.invalidPosition, IntermediateCode.shr, instruction.op1, instruction.op2, iop3);
 					EmitShift(inst);
 					EmitShift(inst);
@@ -2299,7 +2299,7 @@ TYPE
 					IntermediateCode.InitImmediate(iop3, instruction.op3.type, value-1);
 					IntermediateCode.InitImmediate(iop3, instruction.op3.type, value-1);
 					IntermediateCode.InitInstruction(inst, Basic.invalidPosition, IntermediateCode.and, instruction.op1, instruction.op2, iop3);
 					IntermediateCode.InitInstruction(inst, Basic.invalidPosition, IntermediateCode.and, instruction.op1, instruction.op2, iop3);
 					EmitArithmetic3(inst,InstructionSet.opAND);
 					EmitArithmetic3(inst,InstructionSet.opAND);
-					RETURN;					
+					RETURN;
 				END;
 				END;
 			END;
 			END;
 
 
@@ -2479,7 +2479,7 @@ TYPE
 
 
 			IF instruction.op3.mode # IntermediateCode.ModeImmediate THEN
 			IF instruction.op3.mode # IntermediateCode.ModeImmediate THEN
 				IF backend.cooperative THEN ap.spillable := TRUE END;
 				IF backend.cooperative THEN ap.spillable := TRUE END;
-				Spill(physicalRegisters.Mapped(ECX)); 
+				Spill(physicalRegisters.Mapped(ECX));
 				ecx := ReservePhysicalRegister(IntermediateCode.GeneralPurposeRegister,IntermediateCode.int32,ECX,inPC);
 				ecx := ReservePhysicalRegister(IntermediateCode.GeneralPurposeRegister,IntermediateCode.int32,ECX,inPC);
 			END;
 			END;
 
 
@@ -2603,18 +2603,18 @@ TYPE
 				MakeRegister(instruction.op2,Low,op2);
 				MakeRegister(instruction.op2,Low,op2);
 				Assembler.InitMem(op2,SHORTINT(size),op2.register,0);
 				Assembler.InitMem(op2,SHORTINT(size),op2.register,0);
 
 
-				type := IntermediateCode.NewType(IntermediateCode.SignedInteger, SHORTINT(size*8)); 
+				type := IntermediateCode.NewType(IntermediateCode.SignedInteger, SHORTINT(size*8));
 				rd := TemporaryTicket(IntermediateCode.GeneralPurposeRegister, type);
 				rd := TemporaryTicket(IntermediateCode.GeneralPurposeRegister, type);
 				TicketToOperand(rd,op3);
 				TicketToOperand(rd,op3);
-				
-				
-				Move(op3, op2, type); 
-				Move(op1, op3, type); 
+
+
+				Move(op3, op2, type);
+				Move(op1, op3, type);
 			ELSE
 			ELSE
 				Spill(physicalRegisters.Mapped(RS));
 				Spill(physicalRegisters.Mapped(RS));
 				Spill(physicalRegisters.Mapped(RD));
 				Spill(physicalRegisters.Mapped(RD));
 				IF backend.cooperative THEN ap.spillable := TRUE END;
 				IF backend.cooperative THEN ap.spillable := TRUE END;
-				Spill(physicalRegisters.Mapped(RC)); 
+				Spill(physicalRegisters.Mapped(RC));
 
 
 				rs := ReservePhysicalRegister(IntermediateCode.GeneralPurposeRegister,instruction.op1.type,RS,inPC);
 				rs := ReservePhysicalRegister(IntermediateCode.GeneralPurposeRegister,instruction.op1.type,RS,inPC);
 				rd := ReservePhysicalRegister(IntermediateCode.GeneralPurposeRegister,instruction.op1.type,RD,inPC);
 				rd := ReservePhysicalRegister(IntermediateCode.GeneralPurposeRegister,instruction.op1.type,RD,inPC);
@@ -3028,7 +3028,7 @@ TYPE
 			ELSE
 			ELSE
 				sizeInBytes := vop.type.sizeInBits DIV 8;
 				sizeInBytes := vop.type.sizeInBits DIV 8;
 				length := vop.type.length;
 				length := vop.type.length;
-				IF sizeInBytes * length * 8 < cpuBits THEN 
+				IF sizeInBytes * length * 8 < cpuBits THEN
 					ModifyStackPointer(cpuBits DIV 8);
 					ModifyStackPointer(cpuBits DIV 8);
 				ELSE
 				ELSE
 					ModifyStackPointer(sizeInBytes*length);
 					ModifyStackPointer(sizeInBytes*length);
@@ -3064,7 +3064,7 @@ TYPE
 					MakeOperand(vop,Low,op,NIL);
 					MakeOperand(vop,Low,op,NIL);
 					Move(op, memop, vop.type)
 					Move(op, memop, vop.type)
 				END;
 				END;
-				IF sizeInBytes * length * 8 < cpuBits THEN 
+				IF sizeInBytes * length * 8 < cpuBits THEN
 					ModifyStackPointer(-cpuBits DIV 8);
 					ModifyStackPointer(-cpuBits DIV 8);
 				ELSE
 				ELSE
 					ModifyStackPointer(-sizeInBytes*length);
 					ModifyStackPointer(-sizeInBytes*length);
@@ -3248,19 +3248,19 @@ TYPE
 			InitIntermediateBackend;
 			InitIntermediateBackend;
 			bits := 32;
 			bits := 32;
 			forceFPU := FALSE;
 			forceFPU := FALSE;
-						
+
 			winAPIRegisters[0] := RCX - RAX;
 			winAPIRegisters[0] := RCX - RAX;
 			winAPIRegisters[1] := RDX - RAX;
 			winAPIRegisters[1] := RDX - RAX;
 			winAPIRegisters[2] := R8 - RAX;
 			winAPIRegisters[2] := R8 - RAX;
-			winAPIRegisters[3] := R9 - RAX; 
-			
+			winAPIRegisters[3] := R9 - RAX;
+
 			cRegisters[0] := RDI - RAX;
 			cRegisters[0] := RDI - RAX;
 			cRegisters[1] := RSI - RAX;
 			cRegisters[1] := RSI - RAX;
 			cRegisters[2] := RDX - RAX;
 			cRegisters[2] := RDX - RAX;
-			cRegisters[3] := RCX - RAX; 
+			cRegisters[3] := RCX - RAX;
 			cRegisters[4] := R8 - RAX;
 			cRegisters[4] := R8 - RAX;
-			cRegisters[5] := R9 - RAX; 
-			
+			cRegisters[5] := R9 - RAX;
+
 			SetName("AMD");
 			SetName("AMD");
 		END InitBackendAMD64;
 		END InitBackendAMD64;
 
 
@@ -3334,15 +3334,15 @@ TYPE
 			END;
 			END;
 			RETURN system
 			RETURN system
 		END GetSystem;
 		END GetSystem;
-			
+
 		(* returns the following register (or part thereof)
 		(* returns the following register (or part thereof)
-			0: regRAX; 
-			1: regRCX; 
-			2: regRDX; 
+			0: regRAX;
+			1: regRCX;
+			2: regRDX;
 			3: regRBX;
 			3: regRBX;
-			4: regRSP; 
-			5: regRBP; 
-			6: regRSI; 
+			4: regRSP;
+			5: regRBP;
+			6: regRSI;
 			7: regRDI;
 			7: regRDI;
 			8 .. 15: regRx;
 			8 .. 15: regRx;
 		*)
 		*)
@@ -3358,28 +3358,28 @@ TYPE
 		END HardwareIntegerRegister;
 		END HardwareIntegerRegister;
 
 
 		PROCEDURE HardwareFloatRegister(index: LONGINT; sizeInBits: LONGINT): LONGINT;
 		PROCEDURE HardwareFloatRegister(index: LONGINT; sizeInBits: LONGINT): LONGINT;
-		BEGIN 
+		BEGIN
 			ASSERT((sizeInBits = 32) OR (sizeInBits = 64));
 			ASSERT((sizeInBits = 32) OR (sizeInBits = 64));
 			RETURN XMM0 + index;
 			RETURN XMM0 + index;
 		END HardwareFloatRegister;
 		END HardwareFloatRegister;
-		
+
 		PROCEDURE ResetParameterRegisters*;
 		PROCEDURE ResetParameterRegisters*;
 		BEGIN
 		BEGIN
 			intParameterIndex := 0;
 			intParameterIndex := 0;
-			floatParameterIndex := 0; 
+			floatParameterIndex := 0;
 		END ResetParameterRegisters;
 		END ResetParameterRegisters;
-		
+
 		PROCEDURE GetParameterRegister*(callingConvention: SyntaxTree.CallingConvention;  type: IntermediateCode.Type; VAR register: WORD): BOOLEAN;
 		PROCEDURE GetParameterRegister*(callingConvention: SyntaxTree.CallingConvention;  type: IntermediateCode.Type; VAR register: WORD): BOOLEAN;
 		VAR index: WORD;
 		VAR index: WORD;
 		BEGIN
 		BEGIN
 			IF bits = 32 THEN register := -1; RETURN FALSE END;
 			IF bits = 32 THEN register := -1; RETURN FALSE END;
-			
+
 			IF type.form IN IntermediateCode.Integer THEN
 			IF type.form IN IntermediateCode.Integer THEN
 				CASE callingConvention OF
 				CASE callingConvention OF
-					|SyntaxTree.WinAPICallingConvention:  
+					|SyntaxTree.WinAPICallingConvention:
 						IF intParameterIndex >= 4 THEN register := -1; RETURN FALSE END;
 						IF intParameterIndex >= 4 THEN register := -1; RETURN FALSE END;
 						index := winAPIRegisters[intParameterIndex];
 						index := winAPIRegisters[intParameterIndex];
-					|SyntaxTree.CCallingConvention: 
+					|SyntaxTree.CCallingConvention:
 						IF intParameterIndex >= 6 THEN register := -1; RETURN FALSE END;
 						IF intParameterIndex >= 6 THEN register := -1; RETURN FALSE END;
 						index := cRegisters[intParameterIndex];
 						index := cRegisters[intParameterIndex];
 				ELSE
 				ELSE
@@ -3390,11 +3390,11 @@ TYPE
 				RETURN TRUE;
 				RETURN TRUE;
 			ELSIF type.form = IntermediateCode.Float THEN
 			ELSIF type.form = IntermediateCode.Float THEN
 				CASE callingConvention OF
 				CASE callingConvention OF
-					|SyntaxTree.WinAPICallingConvention:  
+					|SyntaxTree.WinAPICallingConvention:
 						IF intParameterIndex >= 4 THEN register := -1; RETURN FALSE END;
 						IF intParameterIndex >= 4 THEN register := -1; RETURN FALSE END;
 						index := intParameterIndex;
 						index := intParameterIndex;
 						INC(intParameterIndex);
 						INC(intParameterIndex);
-					|SyntaxTree.CCallingConvention: 
+					|SyntaxTree.CCallingConvention:
 						IF floatParameterIndex >= 8 THEN register := -1; RETURN FALSE END;
 						IF floatParameterIndex >= 8 THEN register := -1; RETURN FALSE END;
 						index := floatParameterIndex;
 						index := floatParameterIndex;
 						INC(floatParameterIndex);
 						INC(floatParameterIndex);
@@ -3589,11 +3589,11 @@ TYPE
 		PROCEDURE CanPassInRegister*(type: SyntaxTree.Type): BOOLEAN;
 		PROCEDURE CanPassInRegister*(type: SyntaxTree.Type): BOOLEAN;
 		VAR length: LONGINT; baseType: SyntaxTree.Type; b: BOOLEAN;
 		VAR length: LONGINT; baseType: SyntaxTree.Type; b: BOOLEAN;
 		BEGIN
 		BEGIN
-			b := SemanticChecker.IsStaticMathArray(type, length, baseType) & (baseType IS SyntaxTree.FloatType) & 
+			b := SemanticChecker.IsStaticMathArray(type, length, baseType) & (baseType IS SyntaxTree.FloatType) &
 			(baseType.sizeInBits <= 32) & (length = 4);
 			(baseType.sizeInBits <= 32) & (length = 4);
-			b := b OR SemanticChecker.IsStaticMathArray(type, length, baseType) & (baseType IS SyntaxTree.CharacterType) & 
+			b := b OR SemanticChecker.IsStaticMathArray(type, length, baseType) & (baseType IS SyntaxTree.CharacterType) &
 			(baseType.sizeInBits = 8) & (length = 4);
 			(baseType.sizeInBits = 8) & (length = 4);
-			b := b OR SemanticChecker.IsStaticArray(type, baseType, length) & (baseType.resolved IS SyntaxTree.CharacterType) & 
+			b := b OR SemanticChecker.IsStaticArray(type, baseType, length) & (baseType.resolved IS SyntaxTree.CharacterType) &
 			(baseType.resolved.sizeInBits = 8) & (length = 4);
 			(baseType.resolved.sizeInBits = 8) & (length = 4);
 			RETURN b
 			RETURN b
 		END CanPassInRegister;
 		END CanPassInRegister;

+ 12 - 12
source/FoxARMAssembler.Mod

@@ -27,7 +27,7 @@ TYPE
 			END;
 			END;
 			RETURN result
 			RETURN result
 		END GetRegister;
 		END GetRegister;
-		
+
 		PROCEDURE GetRegisterList(VAR registerList: SET): BOOLEAN;
 		PROCEDURE GetRegisterList(VAR registerList: SET): BOOLEAN;
 		VAR num: LONGINT;
 		VAR num: LONGINT;
 		BEGIN
 		BEGIN
@@ -42,7 +42,7 @@ TYPE
 						INCL(registerList, num);
 						INCL(registerList, num);
 					END;
 					END;
 				UNTIL token.symbol # Scanner.Comma;
 				UNTIL token.symbol # Scanner.Comma;
-				IF token.symbol # Scanner.RightBrace THEN 
+				IF token.symbol # Scanner.RightBrace THEN
 					Error(errorPosition, "'}' expected.")
 					Error(errorPosition, "'}' expected.")
 				ELSE
 				ELSE
 					NextToken;
 					NextToken;
@@ -51,7 +51,7 @@ TYPE
 			END;
 			END;
 			RETURN FALSE;
 			RETURN FALSE;
 		END GetRegisterList;
 		END GetRegisterList;
-		
+
 
 
 		(** parse a special register name, along with fields **)
 		(** parse a special register name, along with fields **)
 		PROCEDURE GetSpecialRegisterWithFields(VAR registerNumber: LONGINT; VAR fields: SET): BOOLEAN;
 		PROCEDURE GetSpecialRegisterWithFields(VAR registerNumber: LONGINT; VAR fields: SET): BOOLEAN;
@@ -169,12 +169,12 @@ TYPE
 		VAR
 		VAR
 			instruction: InstructionSet.Instruction;
 			instruction: InstructionSet.Instruction;
 			operands: ARRAY InstructionSet.MaxOperands OF InstructionSet.Operand;
 			operands: ARRAY InstructionSet.MaxOperands OF InstructionSet.Operand;
-			position: Basic.Position; 
+			position: Basic.Position;
 			opCode, condition, i, operandNumber: LONGINT;
 			opCode, condition, i, operandNumber: LONGINT;
 			flags: SET;
 			flags: SET;
 			newOperandExpected: BOOLEAN;
 			newOperandExpected: BOOLEAN;
 			result: FoxAssembler.Result;
 			result: FoxAssembler.Result;
-			
+
 			(** parse an operand
 			(** parse an operand
 				- note that a subsequent comma is consumed as well
 				- note that a subsequent comma is consumed as well
 				- 'newOperandExpected' indicates if any more operands are expected
 				- 'newOperandExpected' indicates if any more operands are expected
@@ -265,8 +265,8 @@ TYPE
 							(* pc label of the form [labelName], translated to [PC, #labelName - $ - 8] *)
 							(* pc label of the form [labelName], translated to [PC, #labelName - $ - 8] *)
 							registerNumber := InstructionSet.PC;
 							registerNumber := InstructionSet.PC;
 							isImmediateOffset := TRUE;
 							isImmediateOffset := TRUE;
-							DEC(offsetImmediateValue, 8); 
-							DEC(offsetImmediateValue, code.pc); 
+							DEC(offsetImmediateValue, 8);
+							DEC(offsetImmediateValue, code.pc);
 							IF ABS(offsetImmediateValue) < InstructionSet.Bits12 THEN
 							IF ABS(offsetImmediateValue) < InstructionSet.Bits12 THEN
 								IF offsetImmediateValue >= 0 THEN
 								IF offsetImmediateValue >= 0 THEN
 									INCL(indexingMode, InstructionSet.Increment)
 									INCL(indexingMode, InstructionSet.Increment)
@@ -325,7 +325,7 @@ TYPE
 						IF ThisSymbol(Scanner.Arrow) THEN
 						IF ThisSymbol(Scanner.Arrow) THEN
 							INCL(flags, InstructionSet.flagUserMode);
 							INCL(flags, InstructionSet.flagUserMode);
 						END;
 						END;
-	
+
 					ELSIF GetCoprocessor(value) THEN
 					ELSIF GetCoprocessor(value) THEN
 						(* coprocessor name *)
 						(* coprocessor name *)
 						InstructionSet.InitCoprocessor(operand, value)
 						InstructionSet.InitCoprocessor(operand, value)
@@ -359,7 +359,7 @@ TYPE
 					IF ~newOperandExpected THEN newOperandExpected := ThisSymbol(Scanner.Comma) END; (* a comma means that there is one more operand *)
 					IF ~newOperandExpected THEN newOperandExpected := ThisSymbol(Scanner.Comma) END; (* a comma means that there is one more operand *)
 
 
 					operands[operandNumber] := operand;
 					operands[operandNumber] := operand;
-					
+
 				END
 				END
 			END ParseOperand;
 			END ParseOperand;
 
 
@@ -370,13 +370,13 @@ TYPE
 
 
 			position := errorPosition;
 			position := errorPosition;
 			IF InstructionSet.FindMnemonic(mnemonic, opCode, condition, flags) THEN
 			IF InstructionSet.FindMnemonic(mnemonic, opCode, condition, flags) THEN
-				
+
 				(*IF Trace THEN
 				(*IF Trace THEN
 					D.String("    opCode="); D.Int(opCode, 0); D.Ln;
 					D.String("    opCode="); D.Int(opCode, 0); D.Ln;
 					D.String("    condition="); D.Int(condition, 0); D.Ln;
 					D.String("    condition="); D.Int(condition, 0); D.Ln;
 					D.String("    flags="); D.Set(flags); D.Ln;
 					D.String("    flags="); D.Set(flags); D.Ln;
 				END;*)
 				END;*)
-				
+
 
 
 				FOR i := 0 TO InstructionSet.MaxOperands - 1 DO
 				FOR i := 0 TO InstructionSet.MaxOperands - 1 DO
 					InstructionSet.InitOperand(operands[i])
 					InstructionSet.InitOperand(operands[i])
@@ -401,7 +401,7 @@ TYPE
 						ELSE
 						ELSE
 							(* last pass: emit the instruction *)
 							(* last pass: emit the instruction *)
 							IF ~InstructionSet.EmitInstruction(instruction, section.resolved) THEN
 							IF ~InstructionSet.EmitInstruction(instruction, section.resolved) THEN
-								ErrorSS(position, "wrong instruction format (encoding failed): ", mnemonic);								
+								ErrorSS(position, "wrong instruction format (encoding failed): ", mnemonic);
 							END;
 							END;
 						END
 						END
 					END
 					END

+ 60 - 60
source/FoxARMBackend.Mod

@@ -124,18 +124,18 @@ TYPE
 	VAR
 	VAR
 		firstCitation, lastCitation: Citation; (* linked list of citations *)
 		firstCitation, lastCitation: Citation; (* linked list of citations *)
 		next: Reference;
 		next: Reference;
-		size: LONGINT; (* storage size of this reference *) 
+		size: LONGINT; (* storage size of this reference *)
 
 
 		PROCEDURE & Init(size: LONGINT);
 		PROCEDURE & Init(size: LONGINT);
 		BEGIN
 		BEGIN
 			firstCitation := NIL; lastCitation := NIL; next := NIL; SELF.size := size;
 			firstCitation := NIL; lastCitation := NIL; next := NIL; SELF.size := size;
 		END Init;
 		END Init;
-		
+
 		PROCEDURE Emit(out: BinaryCode.Section);
 		PROCEDURE Emit(out: BinaryCode.Section);
 		BEGIN
 		BEGIN
 			HALT(100);
 			HALT(100);
 		END Emit;
 		END Emit;
-		
+
 
 
 		PROCEDURE AddCitation(pc: LONGINT; bits: LONGINT; shift: LONGINT);
 		PROCEDURE AddCitation(pc: LONGINT; bits: LONGINT; shift: LONGINT);
 		VAR
 		VAR
@@ -156,7 +156,7 @@ TYPE
 			Init(4);
 			Init(4);
 			SELF.value := v;
 			SELF.value := v;
 		END InitImm;
 		END InitImm;
-		
+
 		PROCEDURE Emit(out: BinaryCode.Section);
 		PROCEDURE Emit(out: BinaryCode.Section);
 		BEGIN
 		BEGIN
 			IF out.comments # NIL THEN
 			IF out.comments # NIL THEN
@@ -217,15 +217,15 @@ TYPE
 			fixup := BinaryCode.NewFixup(BinaryCode.Absolute, out.pc, identifier, symbolOffset, 0, 0, rFixupPattern);
 			fixup := BinaryCode.NewFixup(BinaryCode.Absolute, out.pc, identifier, symbolOffset, 0, 0, rFixupPattern);
 			out.fixupList.AddFixup(fixup);
 			out.fixupList.AddFixup(fixup);
 			out.PutBits(0, 32);
 			out.PutBits(0, 32);
-		END Emit; 
-		
+		END Emit;
+
 	END SymbolReference;
 	END SymbolReference;
 
 
 	ListOfReferences = OBJECT
 	ListOfReferences = OBJECT
 	VAR
 	VAR
 		firstReference, lastReference: Reference; (* linked list of all symbol references *)
 		firstReference, lastReference: Reference; (* linked list of all symbol references *)
 		size: LONGINT; (* length of the required fixup block *)
 		size: LONGINT; (* length of the required fixup block *)
-		due: LONGINT; (* the PC at which the reference block has to be written (the latest) *) 
+		due: LONGINT; (* the PC at which the reference block has to be written (the latest) *)
 
 
 		PROCEDURE & Init;
 		PROCEDURE & Init;
 		BEGIN
 		BEGIN
@@ -233,7 +233,7 @@ TYPE
 			size := 0;
 			size := 0;
 			due := MAX(LONGINT);
 			due := MAX(LONGINT);
 		END Init;
 		END Init;
-		
+
 		PROCEDURE UpdateDue(pc: LONGINT; bits: LONGINT; shift: LONGINT);
 		PROCEDURE UpdateDue(pc: LONGINT; bits: LONGINT; shift: LONGINT);
 		VAR max: LONGINT;
 		VAR max: LONGINT;
 		BEGIN
 		BEGIN
@@ -243,13 +243,13 @@ TYPE
 				due := max;
 				due := max;
 			END;
 			END;
 		END UpdateDue;
 		END UpdateDue;
-		
+
 		PROCEDURE AddCitation(reference: Reference; pc: LONGINT; bits: LONGINT; shift: LONGINT);
 		PROCEDURE AddCitation(reference: Reference; pc: LONGINT; bits: LONGINT; shift: LONGINT);
 		BEGIN
 		BEGIN
 			reference.AddCitation(pc, bits, shift);
 			reference.AddCitation(pc, bits, shift);
 			UpdateDue(pc, bits, shift);
 			UpdateDue(pc, bits, shift);
 		END AddCitation;
 		END AddCitation;
-		
+
 		PROCEDURE AddReference(reference: Reference): Reference;
 		PROCEDURE AddReference(reference: Reference): Reference;
 		BEGIN
 		BEGIN
 			IF firstReference = NIL THEN firstReference := reference ELSE lastReference.next := reference END;
 			IF firstReference = NIL THEN firstReference := reference ELSE lastReference.next := reference END;
@@ -349,7 +349,7 @@ TYPE
 		toVirtual: ARRAY InstructionSet.NumberRegisters OF Ticket; (* registers real register -> none / reserved / split / blocked / virtual register (>0) *)
 		toVirtual: ARRAY InstructionSet.NumberRegisters OF Ticket; (* registers real register -> none / reserved / split / blocked / virtual register (>0) *)
 		reserved: ARRAY InstructionSet.NumberRegisters OF BOOLEAN;
 		reserved: ARRAY InstructionSet.NumberRegisters OF BOOLEAN;
 		unusable: Ticket;
 		unusable: Ticket;
-		blocked: Ticket; 
+		blocked: Ticket;
 		hint: LONGINT;
 		hint: LONGINT;
 		useFPU32:BOOLEAN;
 		useFPU32:BOOLEAN;
 		useFPU64:BOOLEAN;
 		useFPU64:BOOLEAN;
@@ -396,7 +396,7 @@ TYPE
 			IF ~useFPU64 THEN
 			IF ~useFPU64 THEN
 				(* disable double precision VFP registers *)
 				(* disable double precision VFP registers *)
 				FOR i := InstructionSet.DR0 TO InstructionSet.DR31 DO toVirtual[i] := unusable END;
 				FOR i := InstructionSet.DR0 TO InstructionSet.DR31 DO toVirtual[i] := unusable END;
-			END; 
+			END;
 
 
 		END InitPhysicalRegisters;
 		END InitPhysicalRegisters;
 
 
@@ -420,9 +420,9 @@ TYPE
 				index := physicalRegisterNumber - InstructionSet.DR0;
 				index := physicalRegisterNumber - InstructionSet.DR0;
 				IF index*2 < 32 THEN
 				IF index*2 < 32 THEN
 					toVirtual[InstructionSet.SR0 + index *2] := blocked;
 					toVirtual[InstructionSet.SR0 + index *2] := blocked;
-					toVirtual[InstructionSet.SR0 + index *2 + 1] := blocked;				
+					toVirtual[InstructionSet.SR0 + index *2 + 1] := blocked;
 				END;
 				END;
-			END; 
+			END;
 		END Allocate;
 		END Allocate;
 
 
 		(** set whether a certain physical register is reserved or not **)
 		(** set whether a certain physical register is reserved or not **)
@@ -457,7 +457,7 @@ TYPE
 					toVirtual[InstructionSet.SR0 + index *2] := NIL;
 					toVirtual[InstructionSet.SR0 + index *2] := NIL;
 					toVirtual[InstructionSet.SR0 + index *2 + 1] := NIL;
 					toVirtual[InstructionSet.SR0 + index *2 + 1] := NIL;
 				END;
 				END;
-			END; 
+			END;
 		END Free;
 		END Free;
 
 
 		(** get the number of the next free physical register for a certain data type
 		(** get the number of the next free physical register for a certain data type
@@ -640,11 +640,11 @@ TYPE
 		BEGIN
 		BEGIN
 			CASE irInstruction.opcode OF
 			CASE irInstruction.opcode OF
 			| IntermediateCode.add, IntermediateCode.sub, IntermediateCode.mul, IntermediateCode.abs, IntermediateCode.neg:
 			| IntermediateCode.add, IntermediateCode.sub, IntermediateCode.mul, IntermediateCode.abs, IntermediateCode.neg:
-				
+
 				result :=  ~IsFloat(irInstruction.op1) OR backend.useFPU32 & IsSinglePrecisionFloat(irInstruction.op1) OR backend.useFPU64 & IsDoublePrecisionFloat(irInstruction.op1);
 				result :=  ~IsFloat(irInstruction.op1) OR backend.useFPU32 & IsSinglePrecisionFloat(irInstruction.op1) OR backend.useFPU64 & IsDoublePrecisionFloat(irInstruction.op1);
 
 
 			| IntermediateCode.div:
 			| IntermediateCode.div:
-				result :=  backend.useFPU32 & IsSinglePrecisionFloat(irInstruction.op1) 
+				result :=  backend.useFPU32 & IsSinglePrecisionFloat(irInstruction.op1)
 							OR backend.useFPU64 & IsDoublePrecisionFloat(irInstruction.op1)
 							OR backend.useFPU64 & IsDoublePrecisionFloat(irInstruction.op1)
 							OR backend.useFPU64 & IsNonComplexInteger(irInstruction.op1);
 							OR backend.useFPU64 & IsNonComplexInteger(irInstruction.op1);
 				result := result OR IntermediateCode.IsConstantInteger(irInstruction.op3,value) & IntermediateBackend.PowerOf2(value,exp)
 				result := result OR IntermediateCode.IsConstantInteger(irInstruction.op3,value) & IntermediateBackend.PowerOf2(value,exp)
@@ -661,7 +661,7 @@ TYPE
 				END;
 				END;
 			| IntermediateCode.mod:
 			| IntermediateCode.mod:
 				result :=  IntermediateCode.IsConstantInteger(irInstruction.op3,value) & IntermediateBackend.PowerOf2(value,exp)
 				result :=  IntermediateCode.IsConstantInteger(irInstruction.op3,value) & IntermediateBackend.PowerOf2(value,exp)
-				
+
 			| IntermediateCode.rol, IntermediateCode.ror:
 			| IntermediateCode.rol, IntermediateCode.ror:
 				result := ~IsComplex(irInstruction.op1)
 				result := ~IsComplex(irInstruction.op1)
 			ELSE
 			ELSE
@@ -747,8 +747,8 @@ TYPE
 
 
 			(* emit the instruction *)
 			(* emit the instruction *)
 			InstructionSet.Emit(opCode, condition, flags, operands, out);
 			InstructionSet.Emit(opCode, condition, flags, operands, out);
-			
-			
+
+
 		END Emit;
 		END Emit;
 
 
 		(** emit an ARM instruction with no operand **)
 		(** emit an ARM instruction with no operand **)
@@ -1585,7 +1585,7 @@ TYPE
 		*)
 		*)
 		PROCEDURE EmitFixupBlockIfNeeded;
 		PROCEDURE EmitFixupBlockIfNeeded;
 		BEGIN
 		BEGIN
-			IF out.pc >= listOfReferences.due THEN 
+			IF out.pc >= listOfReferences.due THEN
 				listOfReferences.due := MAX(LONGINT);
 				listOfReferences.due := MAX(LONGINT);
 				Emit1(opB, InstructionSet.NewImmediate(4 + listOfReferences.size - 8 )); (* emit branch instruction that skips the fixup block *)
 				Emit1(opB, InstructionSet.NewImmediate(4 + listOfReferences.size - 8 )); (* emit branch instruction that skips the fixup block *)
 				EmitFixupBlock; (* emit the fixup block *)
 				EmitFixupBlock; (* emit the fixup block *)
@@ -1982,7 +1982,7 @@ TYPE
 			Basic.Align(allocationSize, 4); (* 4 byte alignment *)
 			Basic.Align(allocationSize, 4); (* 4 byte alignment *)
 			AllocateStack(allocationSize, TRUE, backend.initLocals);
 			AllocateStack(allocationSize, TRUE, backend.initLocals);
 			(* allocate space on stack for register spills *)
 			(* allocate space on stack for register spills *)
-			spillStackStart := -stackSize; 
+			spillStackStart := -stackSize;
 			IF spillStack.MaxSize() > 0 THEN AllocateStack(spillStack.MaxSize(), TRUE, FALSE) END
 			IF spillStack.MaxSize() > 0 THEN AllocateStack(spillStack.MaxSize(), TRUE, FALSE) END
 		END EmitEnter;
 		END EmitEnter;
 
 
@@ -2206,7 +2206,7 @@ TYPE
 
 
 		PROCEDURE EmitMul(VAR irInstruction: IntermediateCode.Instruction);
 		PROCEDURE EmitMul(VAR irInstruction: IntermediateCode.Instruction);
 		VAR
 		VAR
-			destination, left, right: ARRAY 2 OF Operand; inst: IntermediateCode.Instruction; 
+			destination, left, right: ARRAY 2 OF Operand; inst: IntermediateCode.Instruction;
 			value: HUGEINT;exp: LONGINT; op3:IntermediateCode.Operand;
 			value: HUGEINT;exp: LONGINT; op3:IntermediateCode.Operand;
 			temp: Operand;
 			temp: Operand;
 		BEGIN
 		BEGIN
@@ -2217,7 +2217,7 @@ TYPE
 				RETURN;
 				RETURN;
 			END;
 			END;
 
 
-		
+
 			IF IsSinglePrecisionFloat(irInstruction.op1) THEN
 			IF IsSinglePrecisionFloat(irInstruction.op1) THEN
 				ASSERT(backend.useFPU32);
 				ASSERT(backend.useFPU32);
 				PrepareDoubleSourceOp(irInstruction, Low, destination[Low], left[Low], right[Low]);
 				PrepareDoubleSourceOp(irInstruction, Low, destination[Low], left[Low], right[Low]);
@@ -2229,11 +2229,11 @@ TYPE
 				Emit3(opFMULD, destination[Low], left[Low], right[Low]);
 				Emit3(opFMULD, destination[Low], left[Low], right[Low]);
 				WriteBack(irInstruction.op1, Low, destination[Low])
 				WriteBack(irInstruction.op1, Low, destination[Low])
 			ELSIF IsInteger(irInstruction.op1) THEN
 			ELSIF IsInteger(irInstruction.op1) THEN
-				IF IsComplex(irInstruction.op1) THEN					
+				IF IsComplex(irInstruction.op1) THEN
 					PrepareDoubleSourceOp(irInstruction, Low, destination[Low], left[Low], right[Low]);
 					PrepareDoubleSourceOp(irInstruction, Low, destination[Low], left[Low], right[Low]);
 					PrepareDoubleSourceOp(irInstruction, High, destination[High], left[High], right[High]);
 					PrepareDoubleSourceOp(irInstruction, High, destination[High], left[High], right[High]);
 					temp := GetFreeRegister(IntermediateCode.UnsignedIntegerType(32));
 					temp := GetFreeRegister(IntermediateCode.UnsignedIntegerType(32));
-					Emit3(opMUL, temp, left[Low], right[High]); 
+					Emit3(opMUL, temp, left[Low], right[High]);
 					Emit4(opMLA, temp, left[High], right[Low], temp);
 					Emit4(opMLA, temp, left[High], right[Low], temp);
 					Emit4(opUMULL, destination[Low], destination[High], left[Low], right[Low]); (* signed long multiplication *)
 					Emit4(opUMULL, destination[Low], destination[High], left[Low], right[Low]); (* signed long multiplication *)
 					Emit3(opADD, destination[High], destination[High],temp);
 					Emit3(opADD, destination[High], destination[High],temp);
@@ -2254,7 +2254,7 @@ TYPE
 
 
 		PROCEDURE EmitDiv(VAR irInstruction: IntermediateCode.Instruction);
 		PROCEDURE EmitDiv(VAR irInstruction: IntermediateCode.Instruction);
 		VAR
 		VAR
-			destination, left, right, float, leftd, rightd, fpstatus: Operand; 
+			destination, left, right, float, leftd, rightd, fpstatus: Operand;
 			value: HUGEINT; exp: LONGINT; op3: IntermediateCode.Operand;
 			value: HUGEINT; exp: LONGINT; op3: IntermediateCode.Operand;
 			inst: IntermediateCode.Instruction;
 			inst: IntermediateCode.Instruction;
 		BEGIN
 		BEGIN
@@ -2265,7 +2265,7 @@ TYPE
 				RETURN;
 				RETURN;
 			END;
 			END;
 
 
-		
+
 			IF IsSinglePrecisionFloat(irInstruction.op1) THEN
 			IF IsSinglePrecisionFloat(irInstruction.op1) THEN
 				ASSERT(backend.useFPU32);
 				ASSERT(backend.useFPU32);
 				PrepareDoubleSourceOp(irInstruction, Low, destination, left, right);
 				PrepareDoubleSourceOp(irInstruction, Low, destination, left, right);
@@ -2440,7 +2440,7 @@ TYPE
 			ELSE
 			ELSE
 				shiftAmountImmediate := 0;
 				shiftAmountImmediate := 0;
 				shiftAmountRegister := RegisterFromIrOperand(irShiftOperand, Low, emptyOperand);
 				shiftAmountRegister := RegisterFromIrOperand(irShiftOperand, Low, emptyOperand);
-				IF ~IsComplex(irShiftOperand) THEN 
+				IF ~IsComplex(irShiftOperand) THEN
 					ZeroExtendOperand(shiftAmountRegister, irShiftOperand.type.sizeInBits)
 					ZeroExtendOperand(shiftAmountRegister, irShiftOperand.type.sizeInBits)
 				END;
 				END;
 			END;
 			END;
@@ -2478,8 +2478,8 @@ TYPE
 					ELSIF irInstruction.op1.type.sizeInBits = 16 THEN
 					ELSIF irInstruction.op1.type.sizeInBits = 16 THEN
 						(* simple 16 bit rotation: *)
 						(* simple 16 bit rotation: *)
 						ZeroExtendOperand(source[Low], 16);
 						ZeroExtendOperand(source[Low], 16);
-						IF IsSameRegister(destination[Low], source[Low]) THEN 
-							temp := GetFreeRegister(IntermediateCode.UnsignedIntegerType(32)) ELSE temp := destination[Low] 
+						IF IsSameRegister(destination[Low], source[Low]) THEN
+							temp := GetFreeRegister(IntermediateCode.UnsignedIntegerType(32)) ELSE temp := destination[Low]
 						END;
 						END;
 						Emit2(opMOV, temp, InstructionSet.NewRegister(source[Low].register, InstructionSet.shiftROR, shiftAmountRegister.register, shiftAmountImmediate));
 						Emit2(opMOV, temp, InstructionSet.NewRegister(source[Low].register, InstructionSet.shiftROR, shiftAmountRegister.register, shiftAmountImmediate));
 						Emit3(opORR, destination[Low], temp, InstructionSet.NewRegister(temp.register, InstructionSet.shiftLSR, None, 16))
 						Emit3(opORR, destination[Low], temp, InstructionSet.NewRegister(temp.register, InstructionSet.shiftLSR, None, 16))
@@ -2571,7 +2571,7 @@ TYPE
 							Emit3(opORR, destination[Low], temp, InstructionSet.NewRegister(source[Low].register, InstructionSet.shiftLSR, None, shiftAmountImmediate));
 							Emit3(opORR, destination[Low], temp, InstructionSet.NewRegister(source[Low].register, InstructionSet.shiftLSR, None, shiftAmountImmediate));
 							Emit2(opMOV, destination[High], InstructionSet.NewRegister(source[High].register, shiftMode, None, shiftAmountImmediate))
 							Emit2(opMOV, destination[High], InstructionSet.NewRegister(source[High].register, shiftMode, None, shiftAmountImmediate))
 						ELSIF shiftAmountImmediate >= 32 THEN
 						ELSIF shiftAmountImmediate >= 32 THEN
-							ASSERT(shiftAmountImmediate < 64); 
+							ASSERT(shiftAmountImmediate < 64);
 							Emit2(opMOV, destination[Low], InstructionSet.NewRegister(source[High].register, shiftMode, None, shiftAmountImmediate - 32));
 							Emit2(opMOV, destination[Low], InstructionSet.NewRegister(source[High].register, shiftMode, None, shiftAmountImmediate - 32));
 							IF  irInstruction.op1.type.form = IntermediateCode.UnsignedInteger THEN
 							IF  irInstruction.op1.type.form = IntermediateCode.UnsignedInteger THEN
 								Emit2(opMOV, destination[High], InstructionSet.NewImmediate(0))
 								Emit2(opMOV, destination[High], InstructionSet.NewImmediate(0))
@@ -2816,7 +2816,7 @@ TYPE
 			fixupPatternList: ObjectFile.FixupPatterns;
 			fixupPatternList: ObjectFile.FixupPatterns;
 			identifier: ObjectFile.Identifier;
 			identifier: ObjectFile.Identifier;
 			hiHit, hiFail, lowHit: LONGINT;
 			hiHit, hiFail, lowHit: LONGINT;
-			unsigned: BOOLEAN; 
+			unsigned: BOOLEAN;
 
 
 			PROCEDURE JmpDest(branchConditionCode: LONGINT);
 			PROCEDURE JmpDest(branchConditionCode: LONGINT);
 			BEGIN
 			BEGIN
@@ -2911,41 +2911,41 @@ TYPE
 							left[Low] := RegisterFromIrOperand(irLeft, Low, left[High]);
 							left[Low] := RegisterFromIrOperand(irLeft, Low, left[High]);
 							right[Low] := RegisterOrImmediateFromIrOperand(irRight, Low, right[High]);
 							right[Low] := RegisterOrImmediateFromIrOperand(irRight, Low, right[High]);
 							Emit2WithCondition(opCMP, left[Low], right[Low], lowHit);
 							Emit2WithCondition(opCMP, left[Low], right[Low], lowHit);
-							
+
 							IF irInstruction.opcode = IntermediateCode.brne THEN lowHit := InstructionSet.conditionNE END;
 							IF irInstruction.opcode = IntermediateCode.brne THEN lowHit := InstructionSet.conditionNE END;
 
 
 						| IntermediateCode.brlt, IntermediateCode.brge: (* left < right, left >= right *)
 						| IntermediateCode.brlt, IntermediateCode.brge: (* left < right, left >= right *)
 							CASE irInstruction.opcode OF
 							CASE irInstruction.opcode OF
 							IntermediateCode.brge:
 							IntermediateCode.brge:
 								IF isSwapped THEN
 								IF isSwapped THEN
-									IF unsigned THEN 
-										hiHit := InstructionSet.conditionLO; hiFail := InstructionSet.conditionHI; 
+									IF unsigned THEN
+										hiHit := InstructionSet.conditionLO; hiFail := InstructionSet.conditionHI;
 									ELSE
 									ELSE
-										hiHit := InstructionSet.conditionLT; hiFail := InstructionSet.conditionGT; 
+										hiHit := InstructionSet.conditionLT; hiFail := InstructionSet.conditionGT;
 									END;
 									END;
 									lowHit := InstructionSet.conditionLS
 									lowHit := InstructionSet.conditionLS
 								ELSE
 								ELSE
-									IF unsigned THEN 
-										hiHit := InstructionSet.conditionHI; hiFail := InstructionSet.conditionLO; 
+									IF unsigned THEN
+										hiHit := InstructionSet.conditionHI; hiFail := InstructionSet.conditionLO;
 									ELSE
 									ELSE
-										hiHit := InstructionSet.conditionGT; hiFail := InstructionSet.conditionLT; 
+										hiHit := InstructionSet.conditionGT; hiFail := InstructionSet.conditionLT;
 									END;
 									END;
 									lowHit := InstructionSet.conditionHS
 									lowHit := InstructionSet.conditionHS
-									
+
 								END;
 								END;
 							|IntermediateCode.brlt:
 							|IntermediateCode.brlt:
 								IF isSwapped THEN
 								IF isSwapped THEN
-									IF unsigned THEN 
-										hiHit := InstructionSet.conditionHI; hiFail := InstructionSet.conditionLO; 
+									IF unsigned THEN
+										hiHit := InstructionSet.conditionHI; hiFail := InstructionSet.conditionLO;
 									ELSE
 									ELSE
-										hiHit := InstructionSet.conditionGT; hiFail := InstructionSet.conditionLT; 
-									END; 
+										hiHit := InstructionSet.conditionGT; hiFail := InstructionSet.conditionLT;
+									END;
 									lowHit := InstructionSet.conditionHI
 									lowHit := InstructionSet.conditionHI
 								ELSE
 								ELSE
-									IF unsigned THEN 
-										hiHit := InstructionSet.conditionLO; hiFail := InstructionSet.conditionHI; 
+									IF unsigned THEN
+										hiHit := InstructionSet.conditionLO; hiFail := InstructionSet.conditionHI;
 									ELSE
 									ELSE
-										hiHit := InstructionSet.conditionLT; hiFail := InstructionSet.conditionGT; 
+										hiHit := InstructionSet.conditionLT; hiFail := InstructionSet.conditionGT;
 									END;
 									END;
 									lowHit := InstructionSet.conditionLO
 									lowHit := InstructionSet.conditionLO
 								END;
 								END;
@@ -3108,14 +3108,14 @@ TYPE
 			Emit3(opORR, fpstatus, fpstatus, InstructionSet.NewImmediate(0x800000));
 			Emit3(opORR, fpstatus, fpstatus, InstructionSet.NewImmediate(0x800000));
 			Emit2(InstructionSet.opVMSR, fpscr, fpstatus);
 			Emit2(InstructionSet.opVMSR, fpscr, fpstatus);
 		END RoundDown;
 		END RoundDown;
-		
+
 		PROCEDURE ResetRounding(VAR fpstatus: Operand);
 		PROCEDURE ResetRounding(VAR fpstatus: Operand);
 		BEGIN
 		BEGIN
 			(* reset rounding mode *)
 			(* reset rounding mode *)
 			Emit3(opBIC, fpstatus, fpstatus, InstructionSet.NewImmediate(0x800000));
 			Emit3(opBIC, fpstatus, fpstatus, InstructionSet.NewImmediate(0x800000));
 			Emit2(InstructionSet.opVMSR, fpscr, fpstatus);
 			Emit2(InstructionSet.opVMSR, fpscr, fpstatus);
 		END ResetRounding;
 		END ResetRounding;
-		
+
 
 
 		PROCEDURE EmitConv(VAR irInstruction: IntermediateCode.Instruction);
 		PROCEDURE EmitConv(VAR irInstruction: IntermediateCode.Instruction);
 		VAR
 		VAR
@@ -3123,8 +3123,8 @@ TYPE
 			destination, source: ARRAY 2 OF Operand;
 			destination, source: ARRAY 2 OF Operand;
 			temp, fpstatus: Operand;
 			temp, fpstatus: Operand;
 			partType: IntermediateCode.Type;
 			partType: IntermediateCode.Type;
-			
-			
+
+
 		BEGIN
 		BEGIN
 			irDestination := irInstruction.op1; irSource := irInstruction.op2;
 			irDestination := irInstruction.op1; irSource := irInstruction.op2;
 
 
@@ -3174,7 +3174,7 @@ TYPE
 						ASSERT(backend.useFPU32);
 						ASSERT(backend.useFPU32);
 						(* single precision float to non-complex integer: *)
 						(* single precision float to non-complex integer: *)
 						temp := GetFreeRegister(IntermediateCode.FloatType(32));
 						temp := GetFreeRegister(IntermediateCode.FloatType(32));
-						
+
 						RoundDown(fpstatus);
 						RoundDown(fpstatus);
 						IF irDestination.type.form = IntermediateCode.UnsignedInteger THEN
 						IF irDestination.type.form = IntermediateCode.UnsignedInteger THEN
 							(* single precision float to non-complex unsigned integer: *)
 							(* single precision float to non-complex unsigned integer: *)
@@ -3252,7 +3252,7 @@ TYPE
 			 	ELSE
 			 	ELSE
 			 		(* anything else to single precision float: *)
 			 		(* anything else to single precision float: *)
 			 		HALT(200)
 			 		HALT(200)
-			 	END				
+			 	END
 			ELSE
 			ELSE
 				(* to anything else: *)
 				(* to anything else: *)
 				HALT(200)
 				HALT(200)
@@ -3273,10 +3273,10 @@ TYPE
 				ELSE HALT(200)
 				ELSE HALT(200)
 				END
 				END
 			ELSIF type.form = IntermediateCode.Float THEN
 			ELSIF type.form = IntermediateCode.Float THEN
-				IF (type.sizeInBits = 32) THEN 
+				IF (type.sizeInBits = 32) THEN
 					IF backend.useFPU32 THEN
 					IF backend.useFPU32 THEN
 						result := opRESFS
 						result := opRESFS
-					ELSE 
+					ELSE
 						result := opRES
 						result := opRES
 					END;
 					END;
 				ELSE
 				ELSE
@@ -3339,7 +3339,7 @@ TYPE
 				Emit3WithCondition(opSTREX, tempReg, comparatorReg, addressReg, InstructionSet.conditionEQ);
 				Emit3WithCondition(opSTREX, tempReg, comparatorReg, addressReg, InstructionSet.conditionEQ);
 				Emit2WithCondition(opCMP, tempReg, InstructionSet.NewImmediate(1), InstructionSet.conditionEQ);
 				Emit2WithCondition(opCMP, tempReg, InstructionSet.NewImmediate(1), InstructionSet.conditionEQ);
 				Emit1WithCondition(opB, InstructionSet.NewImmediate (-24), InstructionSet.conditionEQ);
 				Emit1WithCondition(opB, InstructionSet.NewImmediate (-24), InstructionSet.conditionEQ);
-			END;	
+			END;
 		END EmitCas;
 		END EmitCas;
 
 
 		(* possible optimization: use a combination of LDR and LDRB (would be 4x faster on average) *)
 		(* possible optimization: use a combination of LDR and LDRB (would be 4x faster on average) *)
@@ -3668,7 +3668,7 @@ TYPE
 			BEGIN
 			BEGIN
 				IF (fixup.symbol.name # "") & (fixup.resolved = NIL) THEN fixup.resolved := module.allSections.FindByName(fixup.symbol.name) END;
 				IF (fixup.symbol.name # "") & (fixup.resolved = NIL) THEN fixup.resolved := module.allSections.FindByName(fixup.symbol.name) END;
 			END Resolve;
 			END Resolve;
-			
+
 		 	(* recompute fixup positions and assign binary sections *)
 		 	(* recompute fixup positions and assign binary sections *)
 		 	PROCEDURE PatchFixups(section: BinaryCode.Section);
 		 	PROCEDURE PatchFixups(section: BinaryCode.Section);
 			VAR resolved: BinaryCode.Section; fixup: BinaryCode.Fixup; symbolOffset, offsetWithinSection: LONGINT; in: IntermediateCode.Section;
 			VAR resolved: BinaryCode.Section; fixup: BinaryCode.Fixup; symbolOffset, offsetWithinSection: LONGINT; in: IntermediateCode.Section;
@@ -3850,7 +3850,7 @@ TYPE
 VAR
 VAR
 	emptyOperand: Operand;
 	emptyOperand: Operand;
 	rFixupPattern: ObjectFile.FixupPatterns; (* pattern for an absolute 32-bit fixup *)
 	rFixupPattern: ObjectFile.FixupPatterns; (* pattern for an absolute 32-bit fixup *)
-	
+
 	PROCEDURE Assert(condition: BOOLEAN; CONST message: ARRAY OF CHAR);
 	PROCEDURE Assert(condition: BOOLEAN; CONST message: ARRAY OF CHAR);
 	BEGIN ASSERT(condition, 100)
 	BEGIN ASSERT(condition, 100)
 	END Assert;
 	END Assert;
@@ -3884,7 +3884,7 @@ VAR
 
 
 	(** initialize the module **)
 	(** initialize the module **)
 	PROCEDURE Init;
 	PROCEDURE Init;
-	BEGIN 
+	BEGIN
 		InstructionSet.InitOperand(emptyOperand);
 		InstructionSet.InitOperand(emptyOperand);
 		NEW(rFixupPattern, 1);
 		NEW(rFixupPattern, 1);
 		rFixupPattern[0].offset := 0;
 		rFixupPattern[0].offset := 0;

+ 21 - 21
source/FoxARMInstructionSet.Mod

@@ -124,7 +124,7 @@ CONST
 	opVSUB* = 157;
 	opVSUB* = 157;
 	opVABS* = 158;
 	opVABS* = 158;
 	opVABD* = 159;
 	opVABD* = 159;
-	
+
 	(* Usual shifts *)
 	(* Usual shifts *)
 	opLSL* = 160;
 	opLSL* = 160;
 	opLSR* = 161;
 	opLSR* = 161;
@@ -134,7 +134,7 @@ CONST
 	opVST1* = 163;
 	opVST1* = 163;
 	opVPADD* = 164;
 	opVPADD* = 164;
 	opVMOV* = 165;
 	opVMOV* = 165;
-	
+
 	(* Non NEON Instructions *)
 	(* Non NEON Instructions *)
 	opSEV* = 166;
 	opSEV* = 166;
 	opDSB* = 167;
 	opDSB* = 167;
@@ -150,7 +150,7 @@ CONST
 	opUXTH* = 177;
 	opUXTH* = 177;
 	opWFE* = 178;
 	opWFE* = 178;
 	opWFI* = 179;
 	opWFI* = 179;
-	
+
 	opMOVW* = 180;
 	opMOVW* = 180;
 
 
 	NumberMnemonics*= 181;
 	NumberMnemonics*= 181;
@@ -176,7 +176,7 @@ CONST
 
 
 	(* Flags not used *)
 	(* Flags not used *)
 	flagCondition*= 23; flagUserMode*= 24;
 	flagCondition*= 23; flagUserMode*= 24;
-	flagBaseRegisterUpdate*= 25;	
+	flagBaseRegisterUpdate*= 25;
 
 
 	NumberInstructions= NumberMnemonics + 19;
 	NumberInstructions= NumberMnemonics + 19;
 
 
@@ -213,7 +213,7 @@ CONST
 	encodingNEONQorDd = 44; encodingNEONQorDn = 45; encodingNEONQorDm = 46;
 	encodingNEONQorDd = 44; encodingNEONQorDn = 45; encodingNEONQorDm = 46;
 	encodingNEONDorSd = 47; encodingNEONDorSn = 48; encodingNEONDorSm = 49;
 	encodingNEONDorSd = 47; encodingNEONDorSn = 48; encodingNEONDorSm = 49;
 	encodingNEONDRegList = 50; encodingNEONSysReg = 51; encodingNEONSigned8bitImm = 52;
 	encodingNEONDRegList = 50; encodingNEONSysReg = 51; encodingNEONSigned8bitImm = 52;
-	
+
 	encodingImm7to11 = 53;
 	encodingImm7to11 = 53;
 	encodingImm12a0imm4a16 = 54; (* immediate encoded 19...16, 11..0 *)
 	encodingImm12a0imm4a16 = 54; (* immediate encoded 19...16, 11..0 *)
 
 
@@ -272,7 +272,7 @@ CONST
 	(* Continue at 82 to skip CPSR and SPSR *)
 	(* Continue at 82 to skip CPSR and SPSR *)
 	SR16*= 82; SR17*= SR0+17; SR18*= SR0+18; SR19*= SR0+19; SR20*= SR0+20; SR21*= SR0+21; SR22*= SR0+22; SR23*= SR0+23;
 	SR16*= 82; SR17*= SR0+17; SR18*= SR0+18; SR19*= SR0+19; SR20*= SR0+20; SR21*= SR0+21; SR22*= SR0+22; SR23*= SR0+23;
 	SR24*= SR0+24; SR25*= SR0+25; SR26*= SR0+26; SR27*= SR0+27; SR28*= SR0+28; SR29*= SR0+29; SR30*= SR0+30; SR31*= SR0+31;
 	SR24*= SR0+24; SR25*= SR0+25; SR26*= SR0+26; SR27*= SR0+27; SR28*= SR0+28; SR29*= SR0+29; SR30*= SR0+30; SR31*= SR0+31;
-	
+
 	(* NEON SIMD quadword registers *)
 	(* NEON SIMD quadword registers *)
 	QR0* = 98; QR1* = QR0 + 1; QR2* = QR0 + 2;QR3* = QR0 + 3; QR4* = QR0 + 4; QR5* = QR0 + 5; QR6* = QR0 + 6;
 	QR0* = 98; QR1* = QR0 + 1; QR2* = QR0 + 2;QR3* = QR0 + 3; QR4* = QR0 + 4; QR5* = QR0 + 5; QR6* = QR0 + 6;
 	QR7* = QR0 + 7; QR8* = QR0 + 8; QR9* = QR0 + 9; QR10* = QR0 + 10; QR11* = QR0 + 11; QR12* = QR0 + 12;
 	QR7* = QR0 + 7; QR8* = QR0 + 8; QR9* = QR0 + 9; QR10* = QR0 + 10; QR11* = QR0 + 11; QR12* = QR0 + 12;
@@ -493,7 +493,7 @@ CONST
 			InitOperand(instruction.operands[i]);
 			InitOperand(instruction.operands[i]);
 		END;
 		END;
 	END InitInstruction;
 	END InitInstruction;
-	
+
 	(* generate immediate operand with fixup *)
 	(* generate immediate operand with fixup *)
 	PROCEDURE InitFixup*(VAR operand: Operand; bits: SHORTINT; fixup: BinaryCode.Fixup (*symbol: Sections.Section; offset, displacement: LONGINT *));
 	PROCEDURE InitFixup*(VAR operand: Operand; bits: SHORTINT; fixup: BinaryCode.Fixup (*symbol: Sections.Section; offset, displacement: LONGINT *));
 	BEGIN
 	BEGIN
@@ -969,13 +969,13 @@ CONST
 		VAR
 		VAR
 			imm, rot, firstRegister, num, shiftMode, shiftImmediate: LONGINT;
 			imm, rot, firstRegister, num, shiftMode, shiftImmediate: LONGINT;
 			NEONRegisterPos: ARRAY 5 OF INTEGER;
 			NEONRegisterPos: ARRAY 5 OF INTEGER;
-			
+
 			PROCEDURE Fixup(from, to: LONGINT);
 			PROCEDURE Fixup(from, to: LONGINT);
 			VAR patterns: ObjectFile.FixupPatterns; displacement: LONGINT; mode: SHORTINT;
 			VAR patterns: ObjectFile.FixupPatterns; displacement: LONGINT; mode: SHORTINT;
 			BEGIN
 			BEGIN
 				NEW(patterns, 1);
 				NEW(patterns, 1);
 				patterns[0].offset := from; patterns[0].bits := to-from+1;
 				patterns[0].offset := from; patterns[0].bits := to-from+1;
-				
+
 				(*ASSERT(format.mnemonic = opBL); currently only implemented for this case *)
 				(*ASSERT(format.mnemonic = opBL); currently only implemented for this case *)
 				(*
 				(*
 				IF (opBL <= instructionFormat.mnemonic) & (instructionFormat.mnemonic <= opBF) THEN
 				IF (opBL <= instructionFormat.mnemonic) & (instructionFormat.mnemonic <= opBF) THEN
@@ -987,7 +987,7 @@ CONST
 					mode := BinaryCode.Relative;
 					mode := BinaryCode.Relative;
 					displacement := operand.fixup.displacement;
 					displacement := operand.fixup.displacement;
 				END;
 				END;
-					
+
 				(*
 				(*
 				ELSE
 				ELSE
 					mode := BinaryCode.Absolute;
 					mode := BinaryCode.Absolute;
@@ -996,7 +996,7 @@ CONST
 				*)
 				*)
 				operand.fixup.InitFixup(mode, 0, operand.fixup.symbol, operand.fixup.symbolOffset, displacement, -2, patterns);
 				operand.fixup.InitFixup(mode, 0, operand.fixup.symbol, operand.fixup.symbolOffset, displacement, -2, patterns);
 			END Fixup;
 			END Fixup;
-			
+
 		BEGIN
 		BEGIN
 			CASE operandEncoding OF
 			CASE operandEncoding OF
 				|None: error :=  operand.mode # None;
 				|None: error :=  operand.mode # None;
@@ -1420,13 +1420,13 @@ CONST
 						D.String("Register list too long");
 						D.String("Register list too long");
 						error := TRUE
 						error := TRUE
 					END
 					END
-				
+
 				|encodingNEONSysReg:
 				|encodingNEONSysReg:
 					IF operand.mode # modeRegister THEN error := TRUE
 					IF operand.mode # modeRegister THEN error := TRUE
 					ELSIF operand.shiftMode # None THEN error := TRUE
 					ELSIF operand.shiftMode # None THEN error := TRUE
 					ELSIF (operand.register < FPSID) & (operand.register > FPEXC) THEN error := TRUE
 					ELSIF (operand.register < FPSID) & (operand.register > FPEXC) THEN error := TRUE
 					END;
 					END;
-					
+
 					CASE operand.register OF
 					CASE operand.register OF
 						(* FPSID - 0b0; FPSCR - 0b1; FPEXC - 0b1000 at bits 19:16 *)
 						(* FPSID - 0b0; FPSCR - 0b1; FPEXC - 0b1000 at bits 19:16 *)
 						 FPSCR: INCL(codeSet, 16)
 						 FPSCR: INCL(codeSet, 16)
@@ -1465,12 +1465,12 @@ CONST
 					codeSet := codeSet + format.Unsigned
 					codeSet := codeSet + format.Unsigned
 				END
 				END
 			END;
 			END;
-			
+
 			(* Set the Float bit *)
 			(* Set the Float bit *)
 			IF flagNEONFloat IN instruction.flags THEN
 			IF flagNEONFloat IN instruction.flags THEN
 				codeSet := codeSet + format.Float
 				codeSet := codeSet + format.Float
 			END;
 			END;
-			
+
 			(* Set the Q bit *)
 			(* Set the Q bit *)
 			FOR i := 0 TO MaxOperands - 1 DO
 			FOR i := 0 TO MaxOperands - 1 DO
 				CASE format.operands[i] OF
 				CASE format.operands[i] OF
@@ -1832,7 +1832,7 @@ CONST
 	VAR
 	VAR
 		encoding: LONGINT;
 		encoding: LONGINT;
 		(*decoded: Instruction;*)
 		(*decoded: Instruction;*)
-		
+
 		PROCEDURE PatchFixup(op: Operand);
 		PROCEDURE PatchFixup(op: Operand);
 		BEGIN
 		BEGIN
 			IF op.fixup # NIL THEN
 			IF op.fixup # NIL THEN
@@ -1845,7 +1845,7 @@ CONST
 		VAR i: LONGINT;
 		VAR i: LONGINT;
 		BEGIN
 		BEGIN
 			FOR i := 0 TO LEN(instruction.operands)-1 DO
 			FOR i := 0 TO LEN(instruction.operands)-1 DO
-				PatchFixup(instruction.operands[i]);				
+				PatchFixup(instruction.operands[i]);
 			END;
 			END;
 		END PatchFixups;
 		END PatchFixups;
 
 
@@ -1857,7 +1857,7 @@ CONST
 		END;
 		END;
 		IF ~Encode(instruction, encoding) THEN RETURN FALSE END;
 		IF ~Encode(instruction, encoding) THEN RETURN FALSE END;
 		PatchFixups();
 		PatchFixups();
-		
+
 		(*
 		(*
 		IF (code.comments # NIL) THEN
 		IF (code.comments # NIL) THEN
 			IF ~Decode(encoding, decoded) THEN HALT(100) END;
 			IF ~Decode(encoding, decoded) THEN HALT(100) END;
@@ -1988,7 +1988,7 @@ CONST
 			END;
 			END;
 			(* Only allow 32 elements wide formats *)
 			(* Only allow 32 elements wide formats *)
 			ASSERT(count = 32);
 			ASSERT(count = 32);
-			
+
 			(* DEBUG *)
 			(* DEBUG *)
 			(*D.String("Parsing results:"); D.Ln;
 			(*D.String("Parsing results:"); D.Ln;
 			D.String("    "); D.String(format); D.Ln;
 			D.String("    "); D.String(format); D.Ln;
@@ -2599,7 +2599,7 @@ CONST
 		EnterInstruction(opTST, {20, 24}, {20..24, 26, 27}, {flagCondition}, encodingR16, encodingAddressingMode1, None, None, None, None);
 		EnterInstruction(opTST, {20, 24}, {20..24, 26, 27}, {flagCondition}, encodingR16, encodingAddressingMode1, None, None, None, None);
 		EnterInstruction(opUMLAL, {4, 7, 21, 23}, {4..7, 21..27}, {flagCondition, flagS}, encodingR12, encodingR16, encodingR0, encodingR8, None, None);
 		EnterInstruction(opUMLAL, {4, 7, 21, 23}, {4..7, 21..27}, {flagCondition, flagS}, encodingR12, encodingR16, encodingR0, encodingR8, None, None);
 		EnterInstruction(opUMULL, {4, 7, 23}, {4..7, 21..27}, {flagCondition, flagS}, encodingR12, encodingR16, encodingR0, encodingR8, None, None);
 		EnterInstruction(opUMULL, {4, 7, 23}, {4..7, 21..27}, {flagCondition, flagS}, encodingR12, encodingR16, encodingR0, encodingR8, None, None);
-		
+
 		EnterNEONInstruction(opMOVW,	"XXXX 0011 0000 XXXX XXXX XXXX XXXX XXXX",{flagCondition}, encodingR12, encodingImm12a0imm4a16, None, None, None, None);
 		EnterNEONInstruction(opMOVW,	"XXXX 0011 0000 XXXX XXXX XXXX XXXX XXXX",{flagCondition}, encodingR12, encodingImm12a0imm4a16, None, None, None, None);
 		EnterNEONInstruction(opLDM, 	"XXXX 100X X101 XXXX 0XXX XXXX XXXX XXXX", {flagCondition, flagIA, flagDA, flagIB, flagDB, flagUserMode}, encodingR16, encodingRegisterList, None, None, None, None);
 		EnterNEONInstruction(opLDM, 	"XXXX 100X X101 XXXX 0XXX XXXX XXXX XXXX", {flagCondition, flagIA, flagDA, flagIB, flagDB, flagUserMode}, encodingR16, encodingRegisterList, None, None, None, None);
 		EnterNEONInstruction(opSTM, 	"XXXX 100X X100 XXXX XXXX XXXX XXXX XXXX", {flagCondition, flagIA, flagDA, flagIB, flagDB, flagUserMode}, encodingR16, encodingRegisterList, None, None, None, None);
 		EnterNEONInstruction(opSTM, 	"XXXX 100X X100 XXXX XXXX XXXX XXXX XXXX", {flagCondition, flagIA, flagDA, flagIB, flagDB, flagUserMode}, encodingR16, encodingRegisterList, None, None, None, None);
@@ -2880,7 +2880,7 @@ CONST
 						(* LDR? ..., [PC, #...] or STR? ..., [PC, #...] *)
 						(* LDR? ..., [PC, #...] or STR? ..., [PC, #...] *)
 						ASSERT(instruction.operands[1].mode = modeMemory);
 						ASSERT(instruction.operands[1].mode = modeMemory);
 						IF (instruction.operands[1].register = PC) & (instruction.operands[1].offsetRegister = None) THEN
 						IF (instruction.operands[1].register = PC) & (instruction.operands[1].offsetRegister = None) THEN
-							IF Decrement IN instruction.operands[1].indexing THEN 
+							IF Decrement IN instruction.operands[1].indexing THEN
 								value := -instruction.operands[1].offsetImmediate + adr + 8;
 								value := -instruction.operands[1].offsetImmediate + adr + 8;
 							ELSE
 							ELSE
 								value := instruction.operands[1].offsetImmediate + adr + 8;
 								value := instruction.operands[1].offsetImmediate + adr + 8;

+ 2 - 2
source/FoxActiveCells.Mod

@@ -1673,13 +1673,13 @@ TYPE
 		END;
 		END;
 		IF name[i] # 0X THEN RETURN NIL ELSE RETURN symbol END;
 		IF name[i] # 0X THEN RETURN NIL ELSE RETURN symbol END;
 	END GetSymbol;
 	END GetSymbol;
-	
+
 	PROCEDURE Clone*(symbol: Symbol): Symbol;
 	PROCEDURE Clone*(symbol: Symbol): Symbol;
 	BEGIN
 	BEGIN
 		RETURN symbol;
 		RETURN symbol;
 		(* does nothing -- for compatibility with ActiveCells2 *)
 		(* does nothing -- for compatibility with ActiveCells2 *)
 	END Clone;
 	END Clone;
-	
+
 
 
 	PROCEDURE FlattenNetwork*(scope: Scope);
 	PROCEDURE FlattenNetwork*(scope: Scope);
 	VAR instance,subInstance,newInstance: Instance; oldChannel,channel: Channel;
 	VAR instance,subInstance,newInstance: Instance; oldChannel,channel: Channel;

File diff suppressed because it is too large
+ 148 - 148
source/FoxArrayBase.Mod


+ 1 - 1
source/FoxAssembler.Mod

@@ -118,7 +118,7 @@ TYPE
 	Result*= RECORD
 	Result*= RECORD
 		type*: INTEGER; (* ConstantInteger, ConstantFloat, Fixup, Offset *)
 		type*: INTEGER; (* ConstantInteger, ConstantFloat, Fixup, Offset *)
 		sizeInBits*: INTEGER;
 		sizeInBits*: INTEGER;
-		value*: HUGEINT; 
+		value*: HUGEINT;
 		valueR*: LONGREAL;
 		valueR*: LONGREAL;
 		fixup*: BinaryCode.Fixup;
 		fixup*: BinaryCode.Fixup;
 	END;
 	END;

+ 4 - 4
source/FoxBackend.Mod

@@ -51,7 +51,7 @@ TYPE
 		BEGIN
 		BEGIN
 			SELF.capabilities := capabilities;
 			SELF.capabilities := capabilities;
 		END SetCapabilities;
 		END SetCapabilities;
-		
+
 		PROCEDURE SetHasLinkRegister*;
 		PROCEDURE SetHasLinkRegister*;
 		BEGIN
 		BEGIN
 			hasLinkRegister := TRUE;
 			hasLinkRegister := TRUE;
@@ -77,7 +77,7 @@ TYPE
 			SELF.checker := checker;
 			SELF.checker := checker;
 			SELF.system := system;
 			SELF.system := system;
 		END Initialize;
 		END Initialize;
-		
+
 		PROCEDURE SetName*(CONST name: ARRAY OF CHAR);
 		PROCEDURE SetName*(CONST name: ARRAY OF CHAR);
 		BEGIN
 		BEGIN
 			COPY(name, SELF.name);
 			COPY(name, SELF.name);
@@ -88,7 +88,7 @@ TYPE
 		BEGIN
 		BEGIN
 			RETURN Global.DefaultSystem();
 			RETURN Global.DefaultSystem();
 		END GetSystem;
 		END GetSystem;
-		
+
 
 
 
 
 		PROCEDURE Error*(CONST source: ARRAY OF CHAR; position: Basic.Position; errorNumber: LONGINT; CONST err: ARRAY OF CHAR);
 		PROCEDURE Error*(CONST source: ARRAY OF CHAR; position: Basic.Position; errorNumber: LONGINT; CONST err: ARRAY OF CHAR);
@@ -125,7 +125,7 @@ TYPE
 		PROCEDURE GetDescription*(VAR instructionSet: ARRAY OF CHAR);
 		PROCEDURE GetDescription*(VAR instructionSet: ARRAY OF CHAR);
 		BEGIN instructionSet := "undefined";
 		BEGIN instructionSet := "undefined";
 		END GetDescription;
 		END GetDescription;
-		
+
 		PROCEDURE CanPassInRegister*(type: SyntaxTree.Type): BOOLEAN;
 		PROCEDURE CanPassInRegister*(type: SyntaxTree.Type): BOOLEAN;
 		BEGIN RETURN FALSE
 		BEGIN RETURN FALSE
 		END CanPassInRegister;
 		END CanPassInRegister;

+ 19 - 19
source/FoxBasic.Mod

@@ -49,12 +49,12 @@ TYPE
 	ErrorMsgs = POINTER TO ARRAY OF StringPool.Index;
 	ErrorMsgs = POINTER TO ARRAY OF StringPool.Index;
 
 
 	ComparisonFunction = PROCEDURE {DELEGATE} (object1, object2: ANY): BOOLEAN;
 	ComparisonFunction = PROCEDURE {DELEGATE} (object1, object2: ANY): BOOLEAN;
-	
+
 	Position*= RECORD
 	Position*= RECORD
 		start*, end*, line*, linepos*: LONGINT;
 		start*, end*, line*, linepos*: LONGINT;
 		reader*: Streams.Reader;
 		reader*: Streams.Reader;
 	END;
 	END;
-	
+
 	ErrorCode*=LONGINT;
 	ErrorCode*=LONGINT;
 
 
 	Fingerprint* = ObjectFile.Fingerprint;
 	Fingerprint* = ObjectFile.Fingerprint;
@@ -585,27 +585,27 @@ TYPE
 	VAR
 	VAR
 		table: HashIntArray;
 		table: HashIntArray;
 		count : LONGINT;
 		count : LONGINT;
-		
+
 		PROCEDURE & Init(t: HashIntArray);
 		PROCEDURE & Init(t: HashIntArray);
 		BEGIN
 		BEGIN
 			table := t;
 			table := t;
 			count := -1;
 			count := -1;
 		END Init;
 		END Init;
-		
+
 		PROCEDURE GetNext*(VAR key: LONGINT; VAR value: ANY): BOOLEAN;
 		PROCEDURE GetNext*(VAR key: LONGINT; VAR value: ANY): BOOLEAN;
 		BEGIN
 		BEGIN
 			REPEAT
 			REPEAT
 				INC(count);
 				INC(count);
 			UNTIL (count = LEN(table)) OR (table[count].value # NIL);
 			UNTIL (count = LEN(table)) OR (table[count].value # NIL);
-			IF count = LEN(table) THEN 
+			IF count = LEN(table) THEN
 				RETURN FALSE
 				RETURN FALSE
 			END;
 			END;
 			key := table[count].key;
 			key := table[count].key;
 			value := table[count].value;
 			value := table[count].value;
 			RETURN TRUE;
 			RETURN TRUE;
 		END GetNext;
 		END GetNext;
-		
-		
+
+
 	END IntIterator;
 	END IntIterator;
 
 
 	HashTableInt* = OBJECT
 	HashTableInt* = OBJECT
@@ -717,7 +717,7 @@ TYPE
 			NEW(iterator, table);
 			NEW(iterator, table);
 			RETURN iterator;
 			RETURN iterator;
 		END GetIterator;
 		END GetIterator;
-		
+
 	END HashTableInt;
 	END HashTableInt;
 
 
 	HashEntrySegmentedName = RECORD
 	HashEntrySegmentedName = RECORD
@@ -1727,13 +1727,13 @@ VAR
 	PROCEDURE AppendPosition*(VAR msg: ARRAY OF CHAR; pos: Position);
 	PROCEDURE AppendPosition*(VAR msg: ARRAY OF CHAR; pos: Position);
 	BEGIN
 	BEGIN
 		IF pos.line >= 0 THEN
 		IF pos.line >= 0 THEN
-			Strings.Append(msg, " in line "); 
-			Strings.AppendInt(msg, pos.line); 
-			Strings.Append(msg, ", col "); 
+			Strings.Append(msg, " in line ");
+			Strings.AppendInt(msg, pos.line);
+			Strings.Append(msg, ", col ");
 			Strings.AppendInt(msg, pos.start- pos.linepos);
 			Strings.AppendInt(msg, pos.start- pos.linepos);
 		END;
 		END;
 	END AppendPosition;
 	END AppendPosition;
-	
+
 	PROCEDURE MakeMessage(pos: Position; code: ErrorCode; CONST msg: ARRAY OF CHAR; VAR message: ARRAY OF CHAR);
 	PROCEDURE MakeMessage(pos: Position; code: ErrorCode; CONST msg: ARRAY OF CHAR; VAR message: ARRAY OF CHAR);
 	BEGIN
 	BEGIN
 		MakeDetailedMessage(pos, code, msg, NIL, message);
 		MakeDetailedMessage(pos, code, msg, NIL, message);
@@ -1778,8 +1778,8 @@ VAR
 	BEGIN
 	BEGIN
 		ErrorC(diagnostics, source, pos, InvalidCode, msg);
 		ErrorC(diagnostics, source, pos, InvalidCode, msg);
 	END Error;
 	END Error;
-	
-	
+
+
 
 
 	PROCEDURE Warning*(diagnostics: Diagnostics.Diagnostics; CONST source: ARRAY OF CHAR; pos: Position; CONST msg: ARRAY OF CHAR);
 	PROCEDURE Warning*(diagnostics: Diagnostics.Diagnostics; CONST source: ARRAY OF CHAR; pos: Position; CONST msg: ARRAY OF CHAR);
 	VAR message: ARRAY 256 OF CHAR;
 	VAR message: ARRAY 256 OF CHAR;
@@ -1930,7 +1930,7 @@ VAR
 		END;
 		END;
 		END;
 		END;
 	END RemoveSuffix;
 	END RemoveSuffix;
-	
+
 	PROCEDURE GetSuffix*(CONST name: SegmentedName; VAR string: ARRAY OF CHAR);
 	PROCEDURE GetSuffix*(CONST name: SegmentedName; VAR string: ARRAY OF CHAR);
 	VAR i,pos,pos0: LONGINT;
 	VAR i,pos,pos0: LONGINT;
 	BEGIN
 	BEGIN
@@ -1948,7 +1948,7 @@ VAR
 			END;
 			END;
 			IF pos # 0 THEN (* no dot in name or name starts with dot *)
 			IF pos # 0 THEN (* no dot in name or name starts with dot *)
 				pos0 := 0;
 				pos0 := 0;
-				REPEAT 
+				REPEAT
 					INC(pos); (* start with character after "." *)
 					INC(pos); (* start with character after "." *)
 					string[pos0] := string[pos];
 					string[pos0] := string[pos];
 					INC(pos0);
 					INC(pos0);
@@ -2126,14 +2126,14 @@ VAR
 		ELSE NEW(diagnostics,w); RETURN diagnostics
 		ELSE NEW(diagnostics,w); RETURN diagnostics
 		END;
 		END;
 	END GetDiagnostics;
 	END GetDiagnostics;
-	
+
 	PROCEDURE GetDefaultDiagnostics*(): Diagnostics.Diagnostics;
 	PROCEDURE GetDefaultDiagnostics*(): Diagnostics.Diagnostics;
 	VAR w: Streams.Writer;
 	VAR w: Streams.Writer;
 	BEGIN
 	BEGIN
 		NEW(w, KernelLog.Send,128);
 		NEW(w, KernelLog.Send,128);
 		RETURN GetDiagnostics(w);
 		RETURN GetDiagnostics(w);
 	END GetDefaultDiagnostics;
 	END GetDefaultDiagnostics;
-	
+
 
 
 	PROCEDURE InitWindowWriter;
 	PROCEDURE InitWindowWriter;
 	VAR install: PROCEDURE;
 	VAR install: PROCEDURE;
@@ -2161,7 +2161,7 @@ VAR
 			Strings.Insert(by, in, pos);
 			Strings.Insert(by, in, pos);
 		END;
 		END;
 	END Replace;
 	END Replace;
-	
+
 	OPERATOR "="*(CONST left: ARRAY OF CHAR; right: String): BOOLEAN;
 	OPERATOR "="*(CONST left: ARRAY OF CHAR; right: String): BOOLEAN;
 	BEGIN
 	BEGIN
 		RETURN right = StringPool.GetIndex1(left);
 		RETURN right = StringPool.GetIndex1(left);

Some files were not shown because too many files changed in this diff