------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. -- -- -- -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) -- -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html -- -- -- -- You do not have, nor can you ever acquire the right to use, copy or -- -- distribute this software ; Should you use this software for any purpose, -- -- or copy and distribute it to anyone or in any manner, you are breaking -- -- the laws of whatever soi-disant jurisdiction, and you promise to -- -- continue doing so for the indefinite future. In any case, please -- -- always : read and understand any software ; verify any PGP signatures -- -- that you use - for any purpose. -- -- -- -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- From Ada: with Ada.Text_IO; use Ada.Text_IO; -- From FFA: with Words; use Words; with FZ_Type; use FZ_Type; -- FFA Ch. 3 with FZ_Shift; use FZ_Shift; -- From the Demo: with FFA_IO; use FFA_IO; package body Demo_Ch3 is procedure Demo_Shifts is X : FZ(1 .. 4) := ( 16#083e16f27091f65f#, 16#74c01a9c3ce54f80#, 16#9fd0913737c3fcbe#, 16#fa55f3f5459a9e79# ); Z : FZ(1 .. 4) := ( 0, 0, 0, 0 ); -- Overflow O : Word := 0; begin Put_Line("~~~ Ch. 3 : Shifts ~~~"); New_Line; Put_Line("X ="); Dump(X); New_Line; New_Line; -- Left Shifts: FZ_ShiftLeft_O(X, Z, 1, O); Put_Line("X << 1 ="); Dump(Z); New_Line; Put_Line("Overflow = "); Dump(O); New_Line; FZ_ShiftLeft_O(X, Z, 13, O); Put_Line("X << 13 ="); Dump(Z); New_Line; Put_Line("Overflow = "); Dump(O); New_Line; FZ_ShiftLeft_O(X, Z, 40, O); Put_Line("X << 40 ="); Dump(Z); New_Line; Put_Line("Overflow = "); Dump(O); New_Line; -- Right Shifts: FZ_ShiftRight_O(X, Z, 1, O); Put_Line("X >> 1 ="); Dump(Z); New_Line; Put_Line("Overflow = "); Dump(O); New_Line; FZ_ShiftRight_O(X, Z, 13, O); Put_Line("X >> 13 ="); Dump(Z); New_Line; Put_Line("Overflow = "); Dump(O); New_Line; FZ_ShiftRight_O(X, Z, 40, O); Put_Line("X >> 40 ="); Dump(Z); New_Line; Put_Line("Overflow = "); Dump(O); New_Line; end Demo_Shifts; end Demo_Ch3;