tree checksum vpatch file split hunks

all signers: diana_coman asciilifeform ben_vulpes peterl spyked

antecedents: ffa_ch1_genesis ffa_ch3_shifts

press order:

ffa_ch1_genesisasciilifeform ben_vulpes diana_coman peterl spyked
ffa_ch2_logicalsasciilifeform ben_vulpes diana_coman peterl spyked
ffa_ch3_shiftsasciilifeform ben_vulpes diana_coman peterl spyked
ffa_ch4_ffacalcasciilifeform ben_vulpes peterl spyked

patch:

-
+ 86525F2C7086039D79E5BF92869D02934A44716812433CA3A90E18A8D03745785C5CA54FE8C39E681B3B13C00C33A5128884A28C8CBACCBC65D0B401D901EC2E
ffa/ffacalc/bin/README
(0 . 0)(1 . 1)
5 Placeholder.
-
+ 82F47018119089B93F11F57B1D6D74C8FF001EED2D9D197DA374C5F2A4DE5BE0527271F8AD86E23DAC2824C3E0A920000AE488BEA30F8444AF650BC87649E690
ffa/ffacalc/cmdline.adb
(0 . 0)(1 . 60)
10 ------------------------------------------------------------------------------
11 ------------------------------------------------------------------------------
12 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
13 -- --
14 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
15 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
16 -- --
17 -- You do not have, nor can you ever acquire the right to use, copy or --
18 -- distribute this software ; Should you use this software for any purpose, --
19 -- or copy and distribute it to anyone or in any manner, you are breaking --
20 -- the laws of whatever soi-disant jurisdiction, and you promise to --
21 -- continue doing so for the indefinite future. In any case, please --
22 -- always : read and understand any software ; verify any PGP signatures --
23 -- that you use - for any purpose. --
24 -- --
25 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
26 ------------------------------------------------------------------------------
27 ------------------------------------------------------------------------------
28
29 with System; use System;
30
31 package body CmdLine is
32
33 -- Test if GNAT's cmdline mechanism is available
34 function Initialized return Boolean is
35 gnat_argv : System.Address;
36 pragma Import (C, gnat_argv, "gnat_argv");
37
38 begin
39 return gnat_argv /= System.Null_Address;
40 end Initialized;
41
42
43 -- Fill the provided string with the text of Number-th cmdline arg
44 procedure Get_Argument(Number : in Natural;
45 Result : out String) is
46 begin
47 if Number >= Arg_Count or (not Initialized) then
48 raise Constraint_Error;
49 end if;
50
51 declare
52 L : constant Integer := Len_Arg(Number);
53 Arg : aliased String(1 .. L);
54 begin
55 -- Will it fit into the available space?
56 if L > Result'Length then
57 raise Constraint_Error;
58 end if;
59
60 -- Get this arg string from where GNAT stowed it
61 Fill_Arg(Arg'Address, Number);
62
63 -- Copy it to Result:
64 Result := (others => ' ');
65 Result(Arg'Range) := Arg;
66 end;
67 end Get_Argument;
68
69 end CmdLine;
-
+ 26B51D3E6AFCA55540D015309958F470CEA6B57222B3BA4ACC9E215DE737AD1747C817E417414888DE872839A7531F4E0F4835B706930320AF3CE10DB40F248D
ffa/ffacalc/cmdline.ads
(0 . 0)(1 . 45)
74 ------------------------------------------------------------------------------
75 ------------------------------------------------------------------------------
76 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
77 -- --
78 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
79 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
80 -- --
81 -- You do not have, nor can you ever acquire the right to use, copy or --
82 -- distribute this software ; Should you use this software for any purpose, --
83 -- or copy and distribute it to anyone or in any manner, you are breaking --
84 -- the laws of whatever soi-disant jurisdiction, and you promise to --
85 -- continue doing so for the indefinite future. In any case, please --
86 -- always : read and understand any software ; verify any PGP signatures --
87 -- that you use - for any purpose. --
88 -- --
89 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
90 ------------------------------------------------------------------------------
91 ------------------------------------------------------------------------------
92
93 with System;
94
95 package CmdLine is
96
97 -- IMHO this is reasonable.
98 CmdLineArg_Length : constant Positive := 256;
99
100 subtype CmdLineArg is String(1 .. CmdLineArg_Length);
101
102 function Initialized return Boolean;
103
104 function Arg_Count return Natural;
105 pragma Import(C, Arg_Count, "__gnat_arg_count");
106
107 procedure Get_Argument(Number : in Natural;
108 Result : out String);
109
110 private
111
112 procedure Fill_Arg (A : System.Address; Arg_Num : Integer);
113 pragma Import(C, Fill_Arg, "__gnat_fill_arg");
114
115 function Len_Arg (Arg_Num : Integer) return Integer;
116 pragma Import(C, Len_Arg, "__gnat_len_arg");
117
118 end CmdLine;
-
+ A94FDA8F8E4C698ACDD894F5F7B10D927A4050ABA96096CCB0893B668EA1BA789389B00B62CD997E2617399FA6E2EA969F6ADB4E7BF31C10CC34B74F2E3978DE
ffa/ffacalc/ffa_calc.adb
(0 . 0)(1 . 479)
123 ------------------------------------------------------------------------------
124 ------------------------------------------------------------------------------
125 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
126 -- --
127 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
128 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
129 -- --
130 -- You do not have, nor can you ever acquire the right to use, copy or --
131 -- distribute this software ; Should you use this software for any purpose, --
132 -- or copy and distribute it to anyone or in any manner, you are breaking --
133 -- the laws of whatever soi-disant jurisdiction, and you promise to --
134 -- continue doing so for the indefinite future. In any case, please --
135 -- always : read and understand any software ; verify any PGP signatures --
136 -- that you use - for any purpose. --
137 -- --
138 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
139 ------------------------------------------------------------------------------
140 ------------------------------------------------------------------------------
141
142 -- Basics
143 with OS; use OS;
144 with CmdLine; use CmdLine;
145
146 -- FFA
147 with FZ_Lim; use FZ_Lim;
148 with Words; use Words;
149 with W_Pred; use W_Pred;
150 with FZ_Type; use FZ_Type;
151 with FZ_Basic; use FZ_Basic;
152 with FZ_Arith; use FZ_Arith;
153 with FZ_Cmp; use FZ_Cmp;
154 with FZ_Pred; use FZ_Pred;
155 with FZ_BitOp; use FZ_BitOp;
156 with FZ_Shift; use FZ_Shift;
157
158 -- For Output
159 with FFA_IO; use FFA_IO;
160
161
162 procedure FFA_Calc is
163
164 Width : Positive; -- Desired FFA Width
165 Height : Positive; -- Desired Height of Stack
166
167 begin
168 if Arg_Count /= 3 then
169 Eggog("Usage: ./ffa_calc WIDTH HEIGHT");
170 end if;
171
172 declare
173 Arg1 : CmdLineArg;
174 Arg2 : CmdLineArg;
175 begin
176 -- Get commandline args:
177 Get_Argument(1, Arg1); -- First arg
178 Get_Argument(2, Arg2); -- Second arg
179
180 -- Parse into Positives:
181 Width := Positive'Value(Arg1);
182 Height := Positive'Value(Arg2);
183 exception
184 when others =>
185 Eggog("Invalid arguments!");
186 end;
187
188 -- Test if proposed Width is permissible:
189 if not FZ_Valid_Bitness_P(Width) then
190 Eggog("Invalid Width: " & FZ_Validity_Rule_Doc);
191 end if;
192
193 -- The Calculator itself:
194 declare
195
196 -- The number of Words required to make a FZ of the given Bitness.
197 Wordness : Indices := Indices(Width / Bitness);
198
199 --------------------------------------------------------
200 -- State --
201 --------------------------------------------------------
202 -- The Stack:
203 subtype Stack_Positions is Natural range 0 .. Height;
204 type Stacks is array(Stack_Positions range <>) of FZ(1 .. Wordness);
205 Stack : Stacks(Stack_Positions'Range);
206
207 -- Stack Pointer:
208 SP : Stack_Positions := Stack_Positions'First;
209
210 -- Carry/Borrow Flag:
211 Flag : WBool := 0;
212
213 -- Odometer:
214 Pos : Natural := 0;
215
216 -- The current levels of the three types of nestedness:
217 QuoteLevel : Natural := 0;
218 CommLevel : Natural := 0;
219 CondLevel : Natural := 0;
220 --------------------------------------------------------
221
222
223 -- Clear the stack and set SP to bottom.
224 procedure Zap is
225 begin
226 -- Clear the stack
227 for i in Stack'Range loop
228 FZ_Clear(Stack(i));
229 end loop;
230 -- Set SP to bottom
231 SP := Stack_Positions'First;
232 -- Clear Overflow flag
233 Flag := 0;
234 end Zap;
235
236
237 -- Report a fatal error condition at the current symbol
238 procedure E(S : in String) is
239 begin
240 Eggog("Pos:" & Natural'Image(Pos) & ": " & S);
241 end E;
242
243
244 -- Move SP up
245 procedure Push is
246 begin
247 if SP = Stack_Positions'Last then
248 E("Stack Overflow!");
249 else
250 SP := SP + 1;
251 end if;
252 end Push;
253
254
255 -- Discard the top of the stack
256 procedure Drop is
257 begin
258 FZ_Clear(Stack(SP));
259 SP := SP - 1;
260 end Drop;
261
262
263 -- Check if stack has the necessary N items
264 procedure Want(N : in Positive) is
265 begin
266 if SP < N then
267 E("Stack Underflow!");
268 end if;
269 end Want;
270
271
272 -- Slide a new hex digit into the FZ on top of stack
273 procedure Ins_Hex_Digit(N : in out FZ;
274 D : in Nibble) is
275 Overflow : Word := 0;
276 begin
277 -- Make room in this FZ for one additional hex digit
278 FZ_ShiftLeft_O(N => N,
279 ShiftedN => N,
280 Count => 4,
281 Overflow => Overflow);
282
283 -- Constants which exceed the Width are forbidden:
284 if W_NZeroP(Overflow) = 1 then
285 E("Constant Exceeds Bitness!");
286 end if;
287
288 -- Set the new digit
289 FZ_Or_W(N, D);
290 end;
291
292
293 -- Execute a Normal Op
294 procedure Op_Normal(C : in Character) is
295
296 -- Over/underflow output from certain ops
297 F : Word;
298
299 begin
300
301 case C is
302
303 --------------
304 -- Stickies --
305 --------------
306 -- Enter Commented
307 when '(' =>
308 CommLevel := 1;
309
310 -- Exit Commented (but we aren't in it!)
311 when ')' =>
312 E("Mismatched close-comment parenthesis !");
313
314 -- Enter Quoted
315 when '[' =>
316 QuoteLevel := 1;
317
318 -- Exit Quoted (but we aren't in it!)
319 when ']' =>
320 E("Mismatched close-quote bracket !");
321
322 -- Enter a ~taken~ Conditional branch:
323 when '{' =>
324 Want(1);
325 if FZ_ZeroP(Stack(SP)) = 1 then
326 CondLevel := 1;
327 end if;
328 Drop;
329
330 -- Exit from a ~non-taken~ Conditional branch:
331 -- ... we push a 0, to suppress the 'else' clause
332 when '}' =>
333 Push;
334 WBool_To_FZ(0, Stack(SP));
335
336 ----------------
337 -- Immediates --
338 ----------------
339
340 -- These operate on the FZ ~currently~ at top of the stack;
341 -- and this means that the stack may NOT be empty.
342
343 when '0' .. '9' =>
344 Want(1);
345 Ins_Hex_Digit(Stack(SP),
346 Character'Pos(C) - Character'Pos('0'));
347
348 when 'A' .. 'F' =>
349 Want(1);
350 Ins_Hex_Digit(Stack(SP),
351 10 + Character'Pos(C) - Character'Pos('A'));
352
353 when 'a' .. 'f' =>
354 Want(1);
355 Ins_Hex_Digit(Stack(SP),
356 10 + Character'Pos(C) - Character'Pos('a'));
357
358 ------------------
359 -- Stack Motion --
360 ------------------
361
362 -- Push a 0 onto the stack
363 when '.' =>
364 Push;
365 FZ_Clear(Stack(SP));
366
367 -- Dup
368 when '"' =>
369 Want(1);
370 Push;
371 Stack(SP) := Stack(SP - 1);
372
373 -- Drop
374 when '_' =>
375 Want(1);
376 Drop;
377
378 -- Swap
379 when ''' =>
380 Want(2);
381 FZ_Swap(Stack(SP), Stack(SP - 1));
382
383 -- Over
384 when '`' =>
385 Want(2);
386 Push;
387 Stack(SP) := Stack(SP - 2);
388
389 ----------------
390 -- Predicates --
391 ----------------
392
393 -- Equality
394 when '=' =>
395 Want(2);
396 WBool_To_FZ(FZ_Eqp(X => Stack(SP),
397 Y => Stack(SP - 1)),
398 Stack(SP - 1));
399 Drop;
400
401 -- Less-Than
402 when '<' =>
403 Want(2);
404 WBool_To_FZ(FZ_LessThanP(X => Stack(SP - 1),
405 Y => Stack(SP)),
406 Stack(SP - 1));
407 Drop;
408
409 -- Greater-Than
410 when '>' =>
411 Want(2);
412 WBool_To_FZ(FZ_GreaterThanP(X => Stack(SP - 1),
413 Y => Stack(SP)),
414 Stack(SP - 1));
415 Drop;
416
417 ----------------
418 -- Arithmetic --
419 ----------------
420
421 -- Subtract
422 when '-' =>
423 Want(2);
424 FZ_Sub(X => Stack(SP - 1),
425 Y => Stack(SP),
426 Difference => Stack(SP - 1),
427 Underflow => F);
428 Flag := W_NZeroP(F);
429 Drop;
430
431 -- Add
432 when '+' =>
433 Want(2);
434 FZ_Add(X => Stack(SP - 1),
435 Y => Stack(SP),
436 Sum => Stack(SP - 1),
437 Overflow => F);
438 Flag := W_NZeroP(F);
439 Drop;
440
441 -----------------
442 -- Bitwise Ops --
443 -----------------
444
445 -- Bitwise-And
446 when '&' =>
447 Want(2);
448 FZ_And(X => Stack(SP - 1),
449 Y => Stack(SP),
450 Result => Stack(SP - 1));
451 Drop;
452
453 -- Bitwise-Or
454 when '|' =>
455 Want(2);
456 FZ_Or(X => Stack(SP - 1),
457 Y => Stack(SP),
458 Result => Stack(SP - 1));
459 Drop;
460
461 -- Bitwise-Xor
462 when '^' =>
463 Want(2);
464 FZ_Xor(X => Stack(SP - 1),
465 Y => Stack(SP),
466 Result => Stack(SP - 1));
467 Drop;
468
469 -- Bitwise-Not (1s-Complement)
470 when '~' =>
471 Want(1);
472 FZ_Not(Stack(SP), Stack(SP));
473
474 -----------
475 -- Other --
476 -----------
477
478 -- mUx
479 when 'U' =>
480 Want(3);
481 FZ_Mux(X => Stack(SP - 2),
482 Y => Stack(SP - 1),
483 Result => Stack(SP - 2),
484 Sel => FZ_NZeroP(Stack(SP)));
485 Drop;
486 Drop;
487
488 -- Put the Overflow flag on the stack
489 when 'O' =>
490 Push;
491 WBool_To_FZ(Flag, Stack(SP));
492
493 -- Print the FZ on the top of the stack
494 when '#' =>
495 Want(1);
496 Dump(Stack(SP));
497 Drop;
498
499 -- Zap (reset)
500 when 'Z' =>
501 Zap;
502
503 -- Quit with Stack Trace
504 when 'Q' =>
505 for I in reverse Stack'First + 1 .. SP loop
506 Dump(Stack(I));
507 end loop;
508 Quit(0);
509
510 ----------
511 -- NOPs --
512 ----------
513
514 -- Ops we have not yet spoken of -- do nothing
515 when others =>
516 null;
517
518 end case;
519
520 end Op_Normal;
521
522
523 -- Process a Symbol
524 procedure Op(C : in Character) is
525 begin
526 -- First, see whether we are in a state of nestedness:
527
528 -- ... in a Comment block:
529 if CommLevel > 0 then
530 case C is
531 when ')' => -- Drop a nesting level:
532 CommLevel := CommLevel - 1;
533 when '(' => -- Add a nesting level:
534 CommLevel := CommLevel + 1;
535 when others =>
536 null; -- Other symbols have no effect at all
537 end case;
538
539 -- ... in a Quote block:
540 elsif QuoteLevel > 0 then
541 case C is
542 when ']' => -- Drop a nesting level:
543 QuoteLevel := QuoteLevel - 1;
544 when '[' => -- Add a nesting level:
545 QuoteLevel := QuoteLevel + 1;
546 when others =>
547 null; -- Other symbols have no effect on the level
548 end case;
549
550 -- If we aren't the mode-exiting ']', print current symbol:
551 if QuoteLevel > 0 then
552 Write_Char(C);
553 end if;
554
555 --- ... in a ~taken~ Conditional branch:
556 elsif CondLevel > 0 then
557 case C is
558 when '}' => -- Drop a nesting level:
559 CondLevel := CondLevel - 1;
560
561 -- If we exited the Conditional as a result,
562 -- we push a 1 to trigger the possible 'else' clause:
563 if CondLevel = 0 then
564 Push;
565 WBool_To_FZ(1, Stack(SP));
566 end if;
567
568 when '{' => -- Add a nesting level:
569 CondLevel := CondLevel + 1;
570 when others =>
571 null; -- Other symbols have no effect on the level
572 end case;
573 else
574 -- This is a Normal Op, so proceed with the normal rules.
575 Op_Normal(C);
576 end if;
577
578 end Op;
579
580
581 -- Current Character
582 C : Character;
583
584 begin
585 -- Reset the Calculator
586 Zap;
587 -- Process characters until EOF:
588 loop
589 if Read_Char(C) then
590 -- Execute Op:
591 Op(C);
592 -- Advance Odometer
593 Pos := Pos + 1;
594 else
595 Zap;
596 Quit(0); -- if EOF, we're done
597 end if;
598 end loop;
599 end;
600
601 end FFA_Calc;
-
+ 1A50E571D07CED69B5D174589A26E4F33C4CE08DC74B87D1F299B71FA6F1C93C515D4195AE84692A4BF9EB1243EFA762FF7390223AD7E07B63A7B227B3A6DFE9
ffa/ffacalc/ffa_calc.gpr
(0 . 0)(1 . 69)
606 ------------------------------------------------------------------------------
607 ------------------------------------------------------------------------------
608 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
609 -- --
610 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
611 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
612 -- --
613 -- You do not have, nor can you ever acquire the right to use, copy or --
614 -- distribute this software ; Should you use this software for any purpose, --
615 -- or copy and distribute it to anyone or in any manner, you are breaking --
616 -- the laws of whatever soi-disant jurisdiction, and you promise to --
617 -- continue doing so for the indefinite future. In any case, please --
618 -- always : read and understand any software ; verify any PGP signatures --
619 -- that you use - for any purpose. --
620 -- --
621 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
622 ------------------------------------------------------------------------------
623 ------------------------------------------------------------------------------
624
625 with "../libffa/ffa.gpr";
626
627 project FFA_Calc is
628
629 for Object_Dir use "obj";
630
631 type Mode_Type is ("debug", "release");
632 Mode : Mode_Type := external ("mode", "release");
633
634 for Languages use ("Ada");
635 for Source_Dirs use (".");
636 for Exec_Dir use "bin";
637 for Main use ("ffa_calc.adb");
638
639 package Compiler is
640 case Mode is
641 when "debug" =>
642 for Switches ("Ada")
643 use ("-g");
644 when "release" =>
645 for Switches ("Ada")
646 use ("-O2", "-fdump-scos", "-gnata", "-fstack-check",
647 "-fdata-sections", "-ffunction-sections");
648 end case;
649 end Compiler;
650
651 package Binder is
652 case Mode is
653 when "debug" =>
654 for Switches ("Ada")
655 use ();
656 when "release" =>
657 for Switches ("Ada")
658 use ("-static");
659 end case;
660 end Binder;
661
662 package Linker is
663 case Mode is
664 when "debug" =>
665 for Switches ("Ada")
666 use ();
667 when "release" =>
668 for Switches ("Ada")
669 use ("-Wl,--gc-sections",
670 "-static");
671 end case;
672 end Linker;
673
674 end FFA_Calc;
-
+ F8B730F0F0F5BDEE5CED5B25FD938779208ACCB2F5629CB7DE2C265BF1FE17FA989A4D800268F40F54DAB184AA15DCDC7B990F5FDF08F309773F453A8A8F586F
ffa/ffacalc/ffa_io.adb
(0 . 0)(1 . 65)
679 ------------------------------------------------------------------------------
680 ------------------------------------------------------------------------------
681 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
682 -- --
683 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
684 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
685 -- --
686 -- You do not have, nor can you ever acquire the right to use, copy or --
687 -- distribute this software ; Should you use this software for any purpose, --
688 -- or copy and distribute it to anyone or in any manner, you are breaking --
689 -- the laws of whatever soi-disant jurisdiction, and you promise to --
690 -- continue doing so for the indefinite future. In any case, please --
691 -- always : read and understand any software ; verify any PGP signatures --
692 -- that you use - for any purpose. --
693 -- --
694 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
695 ------------------------------------------------------------------------------
696 ------------------------------------------------------------------------------
697
698 with OS; use OS;
699
700
701 with Words; use Words;
702 with W_Shifts; use W_Shifts;
703 with FZ_Type; use FZ_Type;
704
705
706 package body FFA_IO is
707
708 -- Obtain the WChars corresponding to the given Word
709 function W_To_WChars(N : Word) return WChars is
710 H : constant array(0 .. 15) of Character := "0123456789ABCDEF";
711 W : Word := N;
712 Result : WChars;
713 begin
714 for b in WChars'Range loop -- From bottom to top:
715 Result(B) := H(Natural(W and 16#F#)); -- Get current nibble.
716 W := Shift_Right(W, 4); -- Get the next nibble.
717 end loop;
718 return Result;
719 end W_To_WChars;
720
721
722 -- Display a hex representation of W to stdout
723 procedure Dump(W : in Word) is
724 T : WChars := W_To_WChars(W);
725 begin
726 for i in reverse T'Range loop
727 Write_Char(T(i));
728 end loop;
729 end Dump;
730
731
732 -- Display a hex representation of N to stdout
733 procedure Dump(N : in FZ) is
734 begin
735 for i in reverse N'Range loop
736 Dump(N(i));
737 end loop;
738
739 -- Newline, for clarity.
740 Write_Newline;
741 end Dump;
742
743 end FFA_IO;
-
+ 163540113624286EEC3AF83B9B930EA3B01E2E17117A1AD5E07B09E4EB32D00DA4F622C89DFF731C011A947A206FDC8C9F10361F8893BD5F186B2898D3CB567C
ffa/ffacalc/ffa_io.ads
(0 . 0)(1 . 37)
748 ------------------------------------------------------------------------------
749 ------------------------------------------------------------------------------
750 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
751 -- --
752 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
753 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
754 -- --
755 -- You do not have, nor can you ever acquire the right to use, copy or --
756 -- distribute this software ; Should you use this software for any purpose, --
757 -- or copy and distribute it to anyone or in any manner, you are breaking --
758 -- the laws of whatever soi-disant jurisdiction, and you promise to --
759 -- continue doing so for the indefinite future. In any case, please --
760 -- always : read and understand any software ; verify any PGP signatures --
761 -- that you use - for any purpose. --
762 -- --
763 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
764 ------------------------------------------------------------------------------
765 ------------------------------------------------------------------------------
766
767 with Words; use Words;
768 with FZ_Type; use FZ_Type;
769
770 package FFA_IO is
771
772 -- Character representation of a Word
773 type WChars is array(1 .. 2 * Byteness) of Character;
774
775 -- Obtain the WChars corresponding to the given Word
776 function W_To_WChars(N : Word) return WChars;
777
778 -- Display a hex representation of W to stdout
779 procedure Dump(W : in Word);
780
781 -- Display a hex representation of N to stdout
782 procedure Dump(N : in FZ);
783
784 end FFA_IO;
-
+ 86525F2C7086039D79E5BF92869D02934A44716812433CA3A90E18A8D03745785C5CA54FE8C39E681B3B13C00C33A5128884A28C8CBACCBC65D0B401D901EC2E
ffa/ffacalc/obj/README
(0 . 0)(1 . 1)
789 Placeholder.
-
+ E50784EA94D68F3C2E8AA239DED6849430A72AF5459267A61A06DD1074FDC5E8C12897BB67A42F843BB2AEF83CD00DA3E2A22D44B3D063FBCE04CE2AEA7EFD3E
ffa/ffacalc/os.adb
(0 . 0)(1 . 66)
794 ------------------------------------------------------------------------------
795 ------------------------------------------------------------------------------
796 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
797 -- --
798 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
799 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
800 -- --
801 -- You do not have, nor can you ever acquire the right to use, copy or --
802 -- distribute this software ; Should you use this software for any purpose, --
803 -- or copy and distribute it to anyone or in any manner, you are breaking --
804 -- the laws of whatever soi-disant jurisdiction, and you promise to --
805 -- continue doing so for the indefinite future. In any case, please --
806 -- always : read and understand any software ; verify any PGP signatures --
807 -- that you use - for any purpose. --
808 -- --
809 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
810 ------------------------------------------------------------------------------
811 ------------------------------------------------------------------------------
812
813 package body OS is
814
815 -- Receive a character from the TTY, and True if success (False if EOF)
816 function Read_Char(C : out Character) return Boolean is
817 i : int;
818 Result : Boolean := False;
819 begin
820 i := GetChar;
821 if i /= EOF then
822 C := Character'Val(i);
823 Result := True;
824 end if;
825 return Result;
826 end Read_Char;
827
828
829 -- Send a character to the TTY.
830 procedure Write_Char(C : in Character) is
831 R : int;
832 pragma Unreferenced(R);
833 begin
834 R := PutChar(int(Character'Pos(C)));
835 end Write_Char;
836
837
838 -- Send a Newline to the TTY.
839 procedure Write_Newline is
840 begin
841 Write_Char(Character'Val(16#A#));
842 end Write_Newline;
843
844
845 -- Exit with an error condition report.
846 procedure Eggog(M : String) is
847 begin
848 for i in 1 .. M'Length loop
849 To_Stderr(M(I));
850 end loop;
851
852 -- Emit LF
853 To_Stderr(Character'Val(16#A#));
854
855 -- Exit
856 Quit(Sadness_Code);
857 end;
858
859 end OS;
-
+ 648E34F36D3D04C1E53E6CE3D6D9891F7A4A6C1CE8A05B09A47914D2889FD02A2224183528EE3D4E8FB6BD3853C56C97E1B98F96BCD87CEAAF4A35BECFA334D0
ffa/ffacalc/os.ads
(0 . 0)(1 . 61)
864 ------------------------------------------------------------------------------
865 ------------------------------------------------------------------------------
866 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
867 -- --
868 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
869 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
870 -- --
871 -- You do not have, nor can you ever acquire the right to use, copy or --
872 -- distribute this software ; Should you use this software for any purpose, --
873 -- or copy and distribute it to anyone or in any manner, you are breaking --
874 -- the laws of whatever soi-disant jurisdiction, and you promise to --
875 -- continue doing so for the indefinite future. In any case, please --
876 -- always : read and understand any software ; verify any PGP signatures --
877 -- that you use - for any purpose. --
878 -- --
879 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
880 ------------------------------------------------------------------------------
881 ------------------------------------------------------------------------------
882
883 with Interfaces; use Interfaces;
884 with Interfaces.C; use Interfaces.C;
885
886
887 package OS is
888
889 -- Receive a character from the TTY, and True if success (False if EOF)
890 function Read_Char(C : out Character) return Boolean;
891
892 -- Send a character to the TTY.
893 procedure Write_Char(C : in Character);
894
895 -- Send a Newline to the TTY.
896 procedure Write_Newline;
897
898 -- Exit with an error condition report.
899 procedure Eggog(M : String);
900
901 procedure Quit(Return_Code : Integer);
902 pragma Import
903 (Convention => C,
904 Entity => Quit,
905 External_Name => "exit");
906
907 private
908
909 -- POSIX stdio:
910 EOF : constant int := -1;
911
912 function GetChar return int;
913 pragma Import(C, getchar);
914
915 function PutChar(item: int) return int;
916 pragma Import(C, putchar);
917
918 -- GNATistic
919 procedure To_Stderr(C : Character);
920 pragma Import(Ada, To_Stderr, "__gnat_to_stderr_char");
921
922 Sadness_Code : constant Integer := -1;
923
924 end OS;
-
+ E04966A3CFFDD6AB688AD6784DCE66A7F77F3690689E908FF0F1E53155ED84F06DBBC9CA8A479FCA742FA09EFFB1F4970403B0B6B31C7C1667CDCCB92EA98F17
ffa/ffacalc/README
(0 . 0)(1 . 36)
929 ------------------------------------------------------------------------------
930 ------------------------------------------------------------------------------
931 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
932 -- --
933 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
934 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
935 -- --
936 -- You do not have, nor can you ever acquire the right to use, copy or --
937 -- distribute this software ; Should you use this software for any purpose, --
938 -- or copy and distribute it to anyone or in any manner, you are breaking --
939 -- the laws of whatever soi-disant jurisdiction, and you promise to --
940 -- continue doing so for the indefinite future. In any case, please --
941 -- always : read and understand any software ; verify any PGP signatures --
942 -- that you use - for any purpose. --
943 -- --
944 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
945 ------------------------------------------------------------------------------
946 ------------------------------------------------------------------------------
947
948 to clean:
949 gprclean
950
951 to build:
952 gprbuild
953
954 to build debug, or on crapple:
955 gprbuild -Xmode=debug
956
957
958 'libffa' will build recursively.
959
960 to run:
961 ./bin/ffa_calc WIDTH HEIGHT
962
963 WIDTH must be a... see libffa/fz_lim.ads.
964 HEIGHT must be equal to or great than 1.
- 1F5F631FEFFDD32E99E7EB336743EEE48A3FC5DAAA108A1483523F9DF5B6C43A16953E1A89A6CB3E6DCF5ECC52D0CF1F76C2C59A6A9B600131DD73DA5CC227E6
+ 9F84B8BAA6EBD696CD3E4C924E7C23404FEA9B5F2B950139B9B133DBB5698B6E3304F0C64E9B4FF639BE287852C88E293074931423CA16259D3C5060F6DA7927
ffa/libffa/fz_basic.adb
(34 . 6)(34 . 15)
969 pragma Inline_Always(FZ_Clear);
970
971
972 -- Set given FZ to a given truth value
973 procedure WBool_To_FZ(V : in WBool; N : out FZ) is
974 begin
975 FZ_Clear(N);
976 FZ_Set_Head(N, V);
977 end WBool_To_FZ;
978 pragma Inline_Always(WBool_To_FZ);
979
980
981 -- First word of N := Source
982 procedure FZ_Set_Head(N : out FZ; Source : in Word) is
983 begin
- 1EF553C0F5784AD6F312801E27967DDE8B578910A28AE522BE53778E1C1886732BC720E5F1DD4F3E77F8C47A31841D33D12FB1E132C4CCE25A5B68C085B11ADD
+ 8AD840A435CBA8610C3E1EEBC5DB1C4C4E59F849B2C7B970A433C21976813C2B854E5D1E056F13CD1066FAF38985BD0FBA1C49AAB873722222AD46942992CB90
ffa/libffa/fz_basic.ads
(28 . 6)(28 . 9)
988 -- N := 0
989 procedure FZ_Clear(N : out FZ);
990
991 -- Set given FZ to a given truth value
992 procedure WBool_To_FZ(V : in WBool; N : out FZ);
993
994 -- First word of N := Source
995 procedure FZ_Set_Head(N : out FZ; Source : in Word);
996
-
+ CFC75DB07FA645DA2FD4C42CD9923C6EA760D4D0F8182624A91E1B88B2CAB4B7CCB227B371F5F02D46382A9CFF92402A6885F74B0DCB7008196A8A29CD27FA4B
ffa/libffa/fz_lim.adb
(0 . 0)(1 . 46)
1001 ------------------------------------------------------------------------------
1002 ------------------------------------------------------------------------------
1003 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
1004 -- --
1005 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
1006 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
1007 -- --
1008 -- You do not have, nor can you ever acquire the right to use, copy or --
1009 -- distribute this software ; Should you use this software for any purpose, --
1010 -- or copy and distribute it to anyone or in any manner, you are breaking --
1011 -- the laws of whatever soi-disant jurisdiction, and you promise to --
1012 -- continue doing so for the indefinite future. In any case, please --
1013 -- always : read and understand any software ; verify any PGP signatures --
1014 -- that you use - for any purpose. --
1015 -- --
1016 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
1017 ------------------------------------------------------------------------------
1018 ------------------------------------------------------------------------------
1019
1020 package body FZ_Lim is
1021
1022 -- Determine if a proposed FFA Bitness is valid.
1023 function FZ_Valid_Bitness_P(B : in Positive) return Boolean is
1024 Result : Boolean := False;
1025 T : Natural := B;
1026 PopCount : Natural := 0;
1027 begin
1028 -- Supposing we meet the minimal bitness:
1029 if B >= FZ_Minimal_Bitness then
1030 while T > 0 loop
1031 if T mod 2 = 1 then
1032 PopCount := PopCount + 1;
1033 end if;
1034 T := T / 2;
1035 end loop;
1036
1037 -- Is B a power of 2?
1038 if PopCount = 1 then
1039 Result := True;
1040 end if;
1041 end if;
1042
1043 return Result;
1044 end FZ_Valid_Bitness_P;
1045
1046 end FZ_Lim;
-
+ 1DDCCA1BDB3601CD9020EDBB202719DEBCA75B27AEF7E401426EC9229EEB6E8C19D66ABEA3EE7DB8CD070769F9DB1528FF93A64F9B3FC6AA58A5800F1F3FB66E
ffa/libffa/fz_lim.ads
(0 . 0)(1 . 32)
1051 ------------------------------------------------------------------------------
1052 ------------------------------------------------------------------------------
1053 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
1054 -- --
1055 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
1056 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
1057 -- --
1058 -- You do not have, nor can you ever acquire the right to use, copy or --
1059 -- distribute this software ; Should you use this software for any purpose, --
1060 -- or copy and distribute it to anyone or in any manner, you are breaking --
1061 -- the laws of whatever soi-disant jurisdiction, and you promise to --
1062 -- continue doing so for the indefinite future. In any case, please --
1063 -- always : read and understand any software ; verify any PGP signatures --
1064 -- that you use - for any purpose. --
1065 -- --
1066 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
1067 ------------------------------------------------------------------------------
1068 ------------------------------------------------------------------------------
1069
1070 package FZ_Lim is
1071
1072 pragma Pure;
1073
1074 FZ_Minimal_Bitness : constant Positive := 256;
1075
1076 FZ_Validity_Rule_Doc : constant String
1077 := "Must be greater than or equal to 256, and a power of 2.";
1078
1079 -- Determine if a proposed FFA Bitness is valid.
1080 function FZ_Valid_Bitness_P(B : in Positive) return Boolean;
1081
1082 end FZ_Lim;
- 6AC9DF03BF2513373793174E3B5360DC7098A0AFA7EC4D2B6E54118DF35E2EF8530CB60020994CB48DB4E1952D857A6BD6E776F89FEEF9595AEF3C60995CCE06
+ 8386A39C26B52224916D0AF94334BBFCA448D0CE20BB6A57906B9CB32B794B14CB175E3A4B6A4EDC367BD00F9243B5ADE9F1DB61A681ECD6EC2AD82AECDF1F0E
ffa/libffa/fz_pred.adb
(38 . 6)(38 . 14)
1087 pragma Inline_Always(FZ_ZeroP);
1088
1089
1090 -- 1 iff N != 0 (branch-free); else 0
1091 function FZ_NZeroP(N : in FZ) return WBool is
1092 begin
1093 return 1 xor FZ_ZeroP(N);
1094 end FZ_NZeroP;
1095 pragma Inline_Always(FZ_NZeroP);
1096
1097
1098 -- 1 iff N is odd
1099 function FZ_OddP(N : in FZ) return WBool is
1100 begin
- 2ACF58DC575287BF62F94275D86F7C25ACF44BCCEE875E9F649F072302D9BEA559FB2B973B920DA732A5DF861D2CA2289D1185557FF48F0E79AF2D02565191CF
+ 1191361EFCB8739A60361F2261AEF742EA8BC808FE6B3F17A8F30038201B66CCCFB23148C738BCFC2498BE95785367F702DBEFEEF088E5611DCA2D6034284DF3
ffa/libffa/fz_pred.ads
(32 . 6)(32 . 9)
1105 -- 1 iff N == 0 (branch-free); else 0
1106 function FZ_ZeroP(N : in FZ) return WBool;
1107
1108 -- 1 iff N != 0 (branch-free); else 0
1109 function FZ_NZeroP(N : in FZ) return WBool;
1110
1111 -- 1 iff N is odd
1112 function FZ_OddP(N : in FZ) return WBool;
1113
- C7AAA6FDFE19A3D3398D793E14264B1B3C2A3FE165D388243BE34E378CDA3162110F9F0AAE70692505A3E162C0491DF1532BC90D0F2D109655FD67441C418C24
+ 74D31B831CAE79432681272E130880F85E83F67E4BB832F91AD948474E03D10A968BAEAEC1D378639FFBB7D66DBE9402DA30977AAB5FCCA8D57EB56C1C1CD8F9
ffa/libffa/words.ads
(40 . 6)(40 . 9)
1118 -- The very same Word, but its only legal values are 0 and 1.
1119 subtype WBool is Word range 0 .. 1;
1120
1121 -- Word, restricted to Nibble range.
1122 subtype Nibble is Word range 0 .. 16#F#;
1123
1124 -- When we must refer to individual bit positions of a machine word:
1125 subtype WBit_Index is Natural range 0 .. Bitness - 1;
1126