tree checksum vpatch file split hunks

all signers: asciilifeform bvt diana_coman

antecedents: ffa_ch2_logicals.kv ffa_ch1_genesis.kv ffa_ch4_ffacalc.kv

press order:

ffa_ch1_genesis.kvasciilifeform bvt diana_coman
ffa_ch2_logicals.kvasciilifeform bvt diana_coman
ffa_ch3_shifts.kvasciilifeform bvt diana_coman
ffa_ch4_ffacalc.kvasciilifeform bvt diana_coman
ffa_ch5_egypt.kvasciilifeform bvt diana_coman

patch:

- 4775DCD387FD903F856A9EC5AD9A1A526C4DEE9C146B5393A958608E2ABDE97C75A92F32891804B3058C4316AA0399FCA0713F17C78319E836D76CC93BAADDF4
+ B9B8701B08B296B3B28D8D4300D28DB362AA620804FBBBDBC47E5A96AF9ECFC4AE164B17F38739091985CC0C0D8006A9D128A00B544013D15F2E5E3630703EC0
ffa/ffacalc/ffa_calc.adb
(32 . 6)(32 . 8)
5 with FZ_Pred; use FZ_Pred;
6 with FZ_BitOp; use FZ_BitOp;
7 with FZ_Shift; use FZ_Shift;
8 with FZ_Divis; use FZ_Divis;
9 with FZ_Mul; use FZ_Mul;
10
11 -- For Output
12 with FFA_IO; use FFA_IO;
(147 . 6)(149 . 15)
14 end Want;
15
16
17 -- Ensure that a divisor is not zero
18 procedure MustNotZero(D : in FZ) is
19 begin
20 if FZ_ZeroP(D) = 1 then
21 E("Division by Zero!");
22 end if;
23 end MustNotZero;
24
25
26 -- Slide a new hex digit into the FZ on top of stack
27 procedure Ins_Hex_Digit(N : in out FZ;
28 D : in Nibble) is
(316 . 6)(327 . 43)
30 Flag := W_NZeroP(F);
31 Drop;
32
33 -- Divide and give Quotient and Remainder
34 when '\' =>
35 Want(2);
36 MustNotZero(Stack(SP));
37 FZ_IDiv(Dividend => Stack(SP - 1),
38 Divisor => Stack(SP),
39 Quotient => Stack(SP - 1),
40 Remainder => Stack(SP));
41
42 -- Divide and give Quotient only
43 when '/' =>
44 Want(2);
45 MustNotZero(Stack(SP));
46 FZ_Div(Dividend => Stack(SP - 1),
47 Divisor => Stack(SP),
48 Quotient => Stack(SP - 1));
49 Drop;
50
51 -- Divide and give Remainder only
52 when '%' =>
53 Want(2);
54 MustNotZero(Stack(SP));
55 FZ_Mod(Dividend => Stack(SP - 1),
56 Divisor => Stack(SP),
57 Remainder => Stack(SP - 1));
58 Drop;
59
60 -- Multiply, give bottom and top halves
61 when '*' =>
62 Want(2);
63 MustNotZero(Stack(SP));
64 -- Ch5: slow and simple 'Egyptological' method:
65 FZ_Mul_Egyptian(X => Stack(SP - 1),
66 Y => Stack(SP),
67 XY_Lo => Stack(SP - 1),
68 XY_Hi => Stack(SP));
69
70 -----------------
71 -- Bitwise Ops --
72 -----------------
- EE90484DC801B605DDC2DB7B3DCE4C95A6B99F59577253D40E437F94EA6E89534137102A68DAB20B46D0EA1F8C7BA625258E7073102859AD764020989B95FA7C
+ 27A59F78F058FCD385EC1B2E7EDEF7D2A8936EE3BF81338A64C786BC5B208BEFA8FB424EABD630F4042E4B32FFC5D6222778837BD04EAD9BFF096BA12BC32EA1
ffa/libffa/fz_arith.adb
(44 . 6)(44 . 44)
77 pragma Inline_Always(FZ_Add);
78
79
80 -- Gate = 1: Sum := X + Y; Overflow := Carry
81 -- Gate = 0: Sum := X; Overflow := 0
82 procedure FZ_Add_Gated_O(X : in FZ;
83 Y : in FZ;
84 Gate : in WBool;
85 Sum : out FZ;
86 Overflow : out WBool) is
87 Carry : WBool := 0;
88 Mask : constant Word := 0 - Gate;
89 begin
90 for i in 0 .. Word_Index(X'Length - 1) loop
91 declare
92 A : constant Word := X(X'First + i);
93 B : constant Word := Y(Y'First + i) and Mask;
94 S : constant Word := A + B + Carry;
95 begin
96 Sum(Sum'First + i) := S;
97 Carry := W_Carry(A, B, S);
98 end;
99 end loop;
100 Overflow := Carry;
101 end FZ_Add_Gated_O;
102 pragma Inline_Always(FZ_Add_Gated_O);
103
104
105 -- Same as FZ_Add_Gated_O, but without Overflow output
106 procedure FZ_Add_Gated(X : in FZ;
107 Y : in FZ;
108 Gate : in WBool;
109 Sum : out FZ) is
110 Overflow : Word;
111 pragma Unreferenced(Overflow);
112 begin
113 FZ_Add_Gated_O(X, Y, Gate, Sum, Overflow);
114 end FZ_Add_Gated;
115 pragma Inline_Always(FZ_Add_Gated);
116
117
118 -- Difference := X - Y; Underflow := Borrow
119 procedure FZ_Sub(X : in FZ;
120 Y : in FZ;
- 614AD5186CB1FE04E3019AF0E9EC9AE3F70B82EEE7F2D7436BE2C23A256677C76E2EDC91F6DF9E50A443EF03AEAA78FF86A2B83C8F0BF5326427AF3C9BA2E9B5
+ 384FBD4D5207234D75ACFD11E7C62891ECFCB1C1CBD0205FF71E1B24846E43126538DBE6CDF63A3B78FD660BBE1671FA598C359703680E3AECB5144895893C31
ffa/libffa/fz_arith.ads
(32 . 6)(32 . 22)
125 Overflow : out WBool);
126 pragma Precondition(X'Length = Y'Length and X'Length = Sum'Length);
127
128 -- Gate = 1: Sum := X + Y; Overflow := Carry
129 -- Gate = 0: Sum := X; Overflow := 0
130 procedure FZ_Add_Gated_O(X : in FZ;
131 Y : in FZ;
132 Gate : in WBool;
133 Sum : out FZ;
134 Overflow : out WBool);
135 pragma Precondition(X'Length = Y'Length and X'Length = Sum'Length);
136
137 -- Same as FZ_Add_Gated_O, but without Overflow output
138 procedure FZ_Add_Gated(X : in FZ;
139 Y : in FZ;
140 Gate : in WBool;
141 Sum : out FZ);
142 pragma Precondition(X'Length = Y'Length and X'Length = Sum'Length);
143
144 -- Difference := X - Y; Underflow := Borrow
145 procedure FZ_Sub(X : in FZ;
146 Y : in FZ;
- 6460958067C44F2C661E4A19590A65D33615BAD5CBF436F155499A11E8015E81CEF9B4F036A41BF280FC2CB1DBDB885BB56EDD7D4A79F9276B93DD0470C91659
+ 868D35F9327D08B5CBEC9F573FBFD453BD3639E2B1CB93BA0C8264591C396E920883132037716798AB607A3CB0AC6A95AD819D8B39180693BD2B768B666AC6EE
ffa/libffa/fz_basic.adb
(26 . 6)(26 . 14)
151 -- Fundamental Operations on FZ (finite integers)
152 ---------------------------------------------------------------------------
153
154 -- Determine the Bitness of N
155 function FZ_Bitness(N : in FZ) return Bit_Count is
156 begin
157 return N'Length * Words.Bitness;
158 end FZ_Bitness;
159 pragma Inline_Always(FZ_Bitness);
160
161
162 -- N := 0
163 procedure FZ_Clear(N : out FZ) is
164 begin
- 9C1F0228B71059605C53D22A88C44E14705F5C82EB3877131228E30C62549E83187278B5370697C858F10AA8373D666FBC42B8831D39C1923FC544847B75A31C
+ C03435B8B09D144BE64C1E1FFF0AA4626693D28AE15D30EF59293F215A8B135A24B28030E22835599775D117FB181E44FA9178423AACF1F641EFAC0392DC6AB1
ffa/libffa/fz_basic.ads
(25 . 6)(25 . 9)
169
170 pragma Pure;
171
172 -- Determine the Bitness of N
173 function FZ_Bitness(N : in FZ) return Bit_Count;
174
175 -- N := 0
176 procedure FZ_Clear(N : out FZ);
177
-
+ 449D20BE8CE3646757DCD06D68BAF7FC83A5B32C085B5D617D30500C7EB4377CAA2E74B3679C2751F5277660B5E9C8C2955608C696B3268C7D294CAFFA99E442
ffa/libffa/fz_divis.adb
(0 . 0)(1 . 96)
182 ------------------------------------------------------------------------------
183 ------------------------------------------------------------------------------
184 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
185 -- --
186 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
187 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
188 -- --
189 -- You do not have, nor can you ever acquire the right to use, copy or --
190 -- distribute this software ; Should you use this software for any purpose, --
191 -- or copy and distribute it to anyone or in any manner, you are breaking --
192 -- the laws of whatever soi-disant jurisdiction, and you promise to --
193 -- continue doing so for the indefinite future. In any case, please --
194 -- always : read and understand any software ; verify any PGP signatures --
195 -- that you use - for any purpose. --
196 -- --
197 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
198 ------------------------------------------------------------------------------
199 ------------------------------------------------------------------------------
200
201 with Words; use Words;
202 with W_Pred; use W_Pred;
203 with FZ_Basic; use FZ_Basic;
204 with FZ_Arith; use FZ_Arith;
205 with FZ_BitOp; use FZ_BitOp;
206 with FZ_Shift; use FZ_Shift;
207
208
209 package body FZ_Divis is
210
211 -- Dividend is divided by Divisor, producing Quotient and Remainder.
212 -- WARNING: NO div0 test here! Caller must test.
213 procedure FZ_IDiv(Dividend : in FZ;
214 Divisor : in FZ;
215 Quotient : out FZ;
216 Remainder : out FZ) is
217
218 -- The working register
219 QR : FZ(1 .. Dividend'Length + Divisor'Length);
220
221 -- Bottom seg of Z will end up containing the Quotient; top - remainder
222 Q : FZ renames QR(1 .. Dividend'Length); -- Quotient
223 R : FZ renames QR(Dividend'Length + 1 .. QR'Last); -- Remainder
224
225 C : WBool := 0; -- Borrow, from comparator
226 begin
227 Q := Dividend; -- Q begins with the Dividend
228 FZ_Clear(R); -- R begins empty
229
230 -- For each bit of Dividend:
231 for i in 1 .. FZ_Bitness(Dividend) loop
232
233 -- Advance QR by 1 bit:
234 FZ_ShiftLeft(QR, QR, 1);
235
236 -- Subtract Divisor from R; Underflow goes into C
237 FZ_Sub(X => R, Y => Divisor, Difference => R, Underflow => C);
238
239 -- If C=1, subtraction underflowed, and then Divisor gets added back:
240 FZ_Add_Gated(X => R, Y => Divisor, Gate => C, Sum => R);
241
242 -- Current result-bit is equal to Not-C, i.e. 1 if Divisor 'went in'
243 FZ_Or_W(Q, W_Not(C));
244
245 end loop;
246
247 Quotient := Q; -- Output the Quotient.
248 Remainder := R; -- Output the Remainder.
249
250 end FZ_IDiv;
251 pragma Inline_Always(FZ_IDiv);
252
253
254 -- Exactly same thing as IDiv, but keep only the Quotient
255 procedure FZ_Div(Dividend : in FZ;
256 Divisor : in FZ;
257 Quotient : out FZ) is
258 Remainder : FZ(Divisor'Range);
259 pragma Unreferenced(Remainder);
260 begin
261 FZ_IDiv(Dividend, Divisor, Quotient, Remainder);
262 end FZ_Div;
263 pragma Inline_Always(FZ_Div);
264
265
266 -- Exactly same thing as IDiv, but keep only the Remainder
267 procedure FZ_Mod(Dividend : in FZ;
268 Divisor : in FZ;
269 Remainder : out FZ) is
270 Quotient : FZ(Dividend'Range);
271 pragma Unreferenced(Quotient);
272 begin
273 FZ_IDiv(Dividend, Divisor, Quotient, Remainder);
274 end FZ_Mod;
275 pragma Inline_Always(FZ_Mod);
276
277 end FZ_Divis;
-
+ CF9E5BBCD7DD4DF94DD9A95F52B631CB5C9D29EB6EC7EEEC1ED40E06B7A80019F55206D3C3C0E210BC5A056E12203360C9F51EC2FE060542805A1BE2E68949A9
ffa/libffa/fz_divis.ads
(0 . 0)(1 . 51)
282 ------------------------------------------------------------------------------
283 ------------------------------------------------------------------------------
284 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
285 -- --
286 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
287 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
288 -- --
289 -- You do not have, nor can you ever acquire the right to use, copy or --
290 -- distribute this software ; Should you use this software for any purpose, --
291 -- or copy and distribute it to anyone or in any manner, you are breaking --
292 -- the laws of whatever soi-disant jurisdiction, and you promise to --
293 -- continue doing so for the indefinite future. In any case, please --
294 -- always : read and understand any software ; verify any PGP signatures --
295 -- that you use - for any purpose. --
296 -- --
297 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
298 ------------------------------------------------------------------------------
299 ------------------------------------------------------------------------------
300
301 with FZ_Type; use FZ_Type;
302
303
304 package FZ_Divis is
305
306 pragma Pure;
307
308 -- Dividend is divided by Divisor, producing Quotient and Remainder.
309 -- WARNING: NO div0 test here! Caller must test.
310 procedure FZ_IDiv(Dividend : in FZ;
311 Divisor : in FZ;
312 Quotient : out FZ;
313 Remainder : out FZ);
314 pragma Precondition(Dividend'Length = Divisor'Length and
315 Quotient'Length = Remainder'Length and
316 Dividend'Length = Quotient'Length);
317
318 -- Exactly same thing as IDiv, but keep only the Quotient
319 procedure FZ_Div(Dividend : in FZ;
320 Divisor : in FZ;
321 Quotient : out FZ);
322 pragma Precondition(Dividend'Length = Divisor'Length and
323 Dividend'Length = Quotient'Length);
324
325 -- Exactly same thing as IDiv, but keep only the Remainder
326 procedure FZ_Mod(Dividend : in FZ;
327 Divisor : in FZ;
328 Remainder : out FZ);
329 pragma Precondition(Dividend'Length = Divisor'Length and
330 Dividend'Length = Remainder'Length);
331
332 end FZ_Divis;
- F6117D2B425E46E65421ABDAB29FDB3EE664B657B36930A8249EC3E4983BE09258CA4BD6B24C0B81050623C39F58BF6B2EEABDA579A2066176F439D664CD2053
+ 2CC9761900E19AFBC04B07151108755D4AE49643A1D94DB021D400DE09B21B689FED635B5865ED0E0571BDDD8D3BC90D5447EAEB40A39171DDEAAEBB42BCE929
ffa/libffa/fz_lim.adb
(28 . 9)(28 . 7)
337 -- Supposing we meet the minimal bitness:
338 if B >= FZ_Minimal_Bitness then
339 while T > 0 loop
340 if T mod 2 = 1 then
341 PopCount := PopCount + 1;
342 end if;
343 PopCount := PopCount + T mod 2;
344 T := T / 2;
345 end loop;
346
-
+ 81335CBF5970684E89C61B7A37BFF32F747027A72251D88F2980D21E52D41B88D05503613E11404D55BE9C5DEA3170A7A069CDD32FC4DF64500164BCEE844AF9
ffa/libffa/fz_mul.adb
(0 . 0)(1 . 74)
351 ------------------------------------------------------------------------------
352 ------------------------------------------------------------------------------
353 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
354 -- --
355 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
356 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
357 -- --
358 -- You do not have, nor can you ever acquire the right to use, copy or --
359 -- distribute this software ; Should you use this software for any purpose, --
360 -- or copy and distribute it to anyone or in any manner, you are breaking --
361 -- the laws of whatever soi-disant jurisdiction, and you promise to --
362 -- continue doing so for the indefinite future. In any case, please --
363 -- always : read and understand any software ; verify any PGP signatures --
364 -- that you use - for any purpose. --
365 -- --
366 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
367 ------------------------------------------------------------------------------
368 ------------------------------------------------------------------------------
369
370 with Words; use Words;
371 with FZ_Basic; use FZ_Basic;
372 with FZ_Pred; use FZ_Pred;
373 with FZ_Arith; use FZ_Arith;
374 with FZ_Shift; use FZ_Shift;
375
376
377 package body FZ_Mul is
378
379 -- 'Egyptological' multiplier. XY_Lo and XY_Hi hold result of X*Y.
380 procedure FZ_Mul_Egyptian(X : in FZ;
381 Y : in FZ;
382 XY_Lo : out FZ;
383 XY_Hi : out FZ) is
384
385 -- Register holding running product
386 XY : FZ(1 .. X'Length + Y'Length);
387
388 -- X-Slide
389 XS : FZ(1 .. X'Length + Y'Length);
390
391 -- Y-Slide
392 YS : FZ(Y'Range) := Y;
393
394 begin
395 -- Product register begins empty
396 FZ_Clear(XY);
397
398 -- X-Slide initially equals X:
399 XS(1 .. X'Length) := X;
400 XS(X'Length + 1 .. XS'Last) := (others => 0);
401
402 -- For each bit of Y:
403 for i in 1 .. FZ_Bitness(Y) loop
404
405 -- If lowest bit of Y-Slide is 1, X-Slide is added into XY
406 FZ_Add_Gated(X => XY, Y => XS, Sum => XY,
407 Gate => FZ_OddP(YS));
408
409 -- X-Slide := X-Slide * 2
410 FZ_ShiftLeft(XS, XS, 1);
411
412 -- Y-Slide := Y-Slide / 2
413 FZ_ShiftRight(YS, YS, 1);
414
415 end loop;
416
417 -- Write out the Product's lower and upper FZs:
418 XY_Lo := XY(1 .. XY_Lo'Length);
419 XY_Hi := XY(XY_Lo'Length + 1 .. XY'Last);
420
421 end FZ_Mul_Egyptian;
422 pragma Inline_Always(FZ_Mul_Egyptian);
423
424 end FZ_Mul;
-
+ 13FEAFDFAFEB27C76E393CE5A2A7FAC89360DCCDFDADE355CB248D66FE7B6BE202F71311136A09E729271D468D2DFDA6C2D4445C70C03A584E26FE53C458EAF0
ffa/libffa/fz_mul.ads
(0 . 0)(1 . 36)
429 ------------------------------------------------------------------------------
430 ------------------------------------------------------------------------------
431 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
432 -- --
433 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
434 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
435 -- --
436 -- You do not have, nor can you ever acquire the right to use, copy or --
437 -- distribute this software ; Should you use this software for any purpose, --
438 -- or copy and distribute it to anyone or in any manner, you are breaking --
439 -- the laws of whatever soi-disant jurisdiction, and you promise to --
440 -- continue doing so for the indefinite future. In any case, please --
441 -- always : read and understand any software ; verify any PGP signatures --
442 -- that you use - for any purpose. --
443 -- --
444 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
445 ------------------------------------------------------------------------------
446 ------------------------------------------------------------------------------
447
448 with FZ_Type; use FZ_Type;
449
450
451 package FZ_Mul is
452
453 pragma Pure;
454
455 -- 'Egyptological' multiplier. XY_Lo and XY_Hi hold result of X*Y.
456 procedure FZ_Mul_Egyptian(X : in FZ;
457 Y : in FZ;
458 XY_Lo : out FZ;
459 XY_Hi : out FZ);
460 pragma Precondition(X'Length = Y'Length and
461 XY_Lo'Length = XY_Hi'Length and
462 XY_Lo'Length = ((X'Length + Y'Length) / 2));
463
464 end FZ_Mul;
- C53D7E85E48B1C7BA062AEC40E7D95C2230EE1D09F70DC19681B7759EE1F07F2AA599764AE2742FD3AF4FB6CBDD599EAC0E0C4E1F4F07C11B0F843EFB73B02E5
+ D2817DFD3E193EC26A5466791E7A55E7B781272FAA088EC051D96F622DCFFFD369AE0F2F7717C8F803A3B4AD0A278B27EE79841751B5C4F9A16A0DEC5FB7A907
ffa/libffa/fz_type.ads
(41 . 6)(41 . 9)
469 -- A count of Words in an FZ (cannot be 0):
470 subtype Word_Count is Indices range 1 .. Indices'Last;
471
472 -- A count of Bits, anywhere (cannot be 0):
473 subtype Bit_Count is Positive;
474
475 -- An index of a particular ~bit~ in an FZ:
476 subtype FZBit_Index is Indices;
477
- 5D4D9AA640F4415DCF8E18DFAF299FCE4FA2C5DEDA3B22C851D67F54423814F035CCF4AE9184D4933BB90E0EA35E70F71A19B12DA905584A374986618026E1A8
+ 793FD672FABC06AC1F852BFC681A23F845B8C7560A8601F1F1239ED07065A94E70B1E9402664D16D87449A5FF5C81420F7D5E0EEBC95D84C3373576DF66A7C0A
ffa/libffa/w_pred.adb
(38 . 6)(38 . 14)
482 pragma Inline_Always(W_NZeroP);
483
484
485 -- Return WBool-complement of N.
486 function W_Not(N : in WBool) return WBool is
487 begin
488 return 1 xor N;
489 end W_Not;
490 pragma Inline_Always(W_Not);
491
492
493 -- Return 1 if N is odd; otherwise return 0.
494 function W_OddP(N : in Word) return WBool is
495 begin
- A8B74FCF54F88EE08E1F4760729EA54088C2D21DB24083E695FD1C7BF0B17EEC9A4D614045BB337FD0F5C7F8BF30D7BD80063F7DFE7FE28E2E49078BA52E8250
+ F367B121A5FD6FBA68F6046A9329AC6EC98272A2728F38DDD75C52F348834AD811F20D88AEAC38B24D07B1CE9C042A736554A6C7FB1F6AD7A264B2A09126F7EA
ffa/libffa/w_pred.ads
(30 . 6)(30 . 9)
500 -- Return 1 if N is unequal to 0; otherwise return 0.
501 function W_NZeroP(N : in Word) return WBool;
502
503 -- Return WBool-complement of N.
504 function W_Not(N : in WBool) return WBool;
505
506 -- Return 1 if N is odd; otherwise return 0.
507 function W_OddP(N : in Word) return WBool;
508