-
+ D2AEC7DB4CEF68A2CA7DDF2AAE62E393F228C429D60DD1AC7CBF0C7E5519B30CA053CC9C78A78438FF1108541C9F47240DA5500345C97854EFAA853A4A930C9Dffa/ffademo/demo_ch3.adb(0 . 0)(1 . 110)
19 ------------------------------------------------------------------------------
20 ------------------------------------------------------------------------------
21 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
22 -- --
23 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
24 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
25 -- --
26 -- You do not have, nor can you ever acquire the right to use, copy or --
27 -- distribute this software ; Should you use this software for any purpose, --
28 -- or copy and distribute it to anyone or in any manner, you are breaking --
29 -- the laws of whatever soi-disant jurisdiction, and you promise to --
30 -- continue doing so for the indefinite future. In any case, please --
31 -- always : read and understand any software ; verify any PGP signatures --
32 -- that you use - for any purpose. --
33 -- --
34 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
35 ------------------------------------------------------------------------------
36 ------------------------------------------------------------------------------
37
38 -- From Ada:
39 with Ada.Text_IO; use Ada.Text_IO;
40
41 -- From FFA:
42 with Words; use Words;
43 with FZ_Type; use FZ_Type;
44
45 -- FFA Ch. 3
46 with FZ_Shift; use FZ_Shift;
47
48 -- From the Demo:
49 with FFA_IO; use FFA_IO;
50
51
52 package body Demo_Ch3 is
53
54 procedure Demo_Shifts is
55
56 X : FZ(1 .. 4) := ( 16#083e16f27091f65f#, 16#74c01a9c3ce54f80#,
57 16#9fd0913737c3fcbe#, 16#fa55f3f5459a9e79# );
58
59 Z : FZ(1 .. 4) := ( 0, 0, 0, 0 );
60
61 -- Overflow
62 O : Word := 0;
63
64 begin
65
66 Put_Line("~~~ Ch. 3 : Shifts ~~~");
67 New_Line;
68
69 Put_Line("X =");
70 Dump(X);
71 New_Line;
72 New_Line;
73
74 -- Left Shifts:
75
76 FZ_ShiftLeft_O(X, Z, 1, O);
77 Put_Line("X << 1 =");
78 Dump(Z);
79 New_Line;
80 Put_Line("Overflow = ");
81 Dump(O);
82 New_Line;
83
84 FZ_ShiftLeft_O(X, Z, 13, O);
85 Put_Line("X << 13 =");
86 Dump(Z);
87 New_Line;
88 Put_Line("Overflow = ");
89 Dump(O);
90 New_Line;
91
92 FZ_ShiftLeft_O(X, Z, 40, O);
93 Put_Line("X << 40 =");
94 Dump(Z);
95 New_Line;
96 Put_Line("Overflow = ");
97 Dump(O);
98 New_Line;
99
100 -- Right Shifts:
101
102 FZ_ShiftRight_O(X, Z, 1, O);
103 Put_Line("X >> 1 =");
104 Dump(Z);
105 New_Line;
106 Put_Line("Overflow = ");
107 Dump(O);
108 New_Line;
109
110 FZ_ShiftRight_O(X, Z, 13, O);
111 Put_Line("X >> 13 =");
112 Dump(Z);
113 New_Line;
114 Put_Line("Overflow = ");
115 Dump(O);
116 New_Line;
117
118 FZ_ShiftRight_O(X, Z, 40, O);
119 Put_Line("X >> 40 =");
120 Dump(Z);
121 New_Line;
122 Put_Line("Overflow = ");
123 Dump(O);
124 New_Line;
125
126 end Demo_Shifts;
127
128 end Demo_Ch3;