-
+ 5220F733B82ACDCD95B2806401322ED4657325E6D3D4F1264CFD390C304B900F6A8B1555EB48DDD966ECE7EF91BD120E54972873817A8E8E94B84BD62DD7196A
ffa/ffademo/demo_ch1.adb
(0 . 0)(1 . 69)
92 ------------------------------------------------------------------------------
93 ------------------------------------------------------------------------------
94 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
95 -- --
96 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
97 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
98 -- --
99 -- You do not have, nor can you ever acquire the right to use, copy or --
100 -- distribute this software ; Should you use this software for any purpose, --
101 -- or copy and distribute it to anyone or in any manner, you are breaking --
102 -- the laws of whatever soi-disant jurisdiction, and you promise to --
103 -- continue doing so for the indefinite future. In any case, please --
104 -- always : read and understand any software ; verify any PGP signatures --
105 -- that you use - for any purpose. --
106 -- --
107 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
108 ------------------------------------------------------------------------------
109 ------------------------------------------------------------------------------
110
111 -- From Ada:
112 with Ada.Text_IO; use Ada.Text_IO;
113
114 -- From FFA:
115 with Words; use Words;
116 with FZ_Type; use FZ_Type;
117 with FZ_Arith; use FZ_Arith;
118
119 -- From the Demo:
120 with FFA_IO; use FFA_IO;
121
122
123 package body Demo_Ch1 is
124
125 procedure Demo_Add_Sub is
126
127 -- We are using 64-bit Words (see iron.ads).
128 -- We'll begin with an elementary demo, using 256-bit FZ:
129 X : FZ(1 .. 4) := (0, 0, 0, 0);
130 Y : FZ(1 .. 4) := (16#5555#, 0, 0, 0);
131 Z : FZ(1 .. 4) := (0, 0, 0, 0);
132
133 -- Carry.
134 C : WBool := 0;
135
136 begin
137
138 Put_Line("X =");
139 Dump(X);
140 New_Line;
141
142 Put_Line("Y =");
143 Dump(Y);
144 New_Line;
145
146 FZ_Add(X, Y, Z, C);
147 Put_Line("X + Y =");
148 Dump(Z);
149 New_Line;
150 Put_Line("C = " & WBool'Image(C));
151
152 FZ_Sub(X, Y, Z, C);
153 Put_Line("X - Y =");
154 Dump(Z);
155 New_Line;
156 Put_Line("C = " & WBool'Image(C));
157
158 end Demo_Add_Sub;
159
160 end Demo_Ch1;