raw
ffa_ch1_genesis.kv      1 ------------------------------------------------------------------------------
ffa_ch1_genesis.kv 2 ------------------------------------------------------------------------------
ffa_ch1_genesis.kv 3 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
ffa_ch1_genesis.kv 4 -- --
ffa_ch15_gcd.kv 5 -- (C) 2019 Stanislav Datskovskiy ( www.loper-os.org ) --
ffa_ch1_genesis.kv 6 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
ffa_ch1_genesis.kv 7 -- --
ffa_ch1_genesis.kv 8 -- You do not have, nor can you ever acquire the right to use, copy or --
ffa_ch1_genesis.kv 9 -- distribute this software ; Should you use this software for any purpose, --
ffa_ch1_genesis.kv 10 -- or copy and distribute it to anyone or in any manner, you are breaking --
ffa_ch1_genesis.kv 11 -- the laws of whatever soi-disant jurisdiction, and you promise to --
ffa_ch1_genesis.kv 12 -- continue doing so for the indefinite future. In any case, please --
ffa_ch1_genesis.kv 13 -- always : read and understand any software ; verify any PGP signatures --
ffa_ch1_genesis.kv 14 -- that you use - for any purpose. --
ffa_ch1_genesis.kv 15 -- --
ffa_ch1_genesis.kv 16 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
ffa_ch1_genesis.kv 17 ------------------------------------------------------------------------------
ffa_ch1_genesis.kv 18 ------------------------------------------------------------------------------
ffa_ch1_genesis.kv 19
ffa_ch1_genesis.kv 20 with Ada.Text_IO; use Ada.Text_IO;
ffa_ch1_genesis.kv 21
ffa_ch1_genesis.kv 22 with Words; use Words;
ffa_ch1_genesis.kv 23 with W_Shifts; use W_Shifts;
ffa_ch1_genesis.kv 24 with FZ_Type; use FZ_Type;
ffa_ch1_genesis.kv 25
ffa_ch1_genesis.kv 26
ffa_ch1_genesis.kv 27 package body FFA_IO is
ffa_ch1_genesis.kv 28
ffa_ch1_genesis.kv 29 -- Obtain the WChars corresponding to the given Word
ffa_ch1_genesis.kv 30 function W_To_WChars(N : Word) return WChars is
ffa_ch1_genesis.kv 31 H : constant array(0 .. 15) of Character := "0123456789ABCDEF";
ffa_ch1_genesis.kv 32 W : Word := N;
ffa_ch1_genesis.kv 33 Result : WChars;
ffa_ch1_genesis.kv 34 begin
ffa_ch1_genesis.kv 35 for b in WChars'Range loop -- From bottom to top:
ffa_ch1_genesis.kv 36 Result(B) := H(Natural(W and 16#F#)); -- Get current nibble.
ffa_ch1_genesis.kv 37 W := Shift_Right(W, 4); -- Get the next nibble.
ffa_ch1_genesis.kv 38 end loop;
ffa_ch1_genesis.kv 39 return Result;
ffa_ch1_genesis.kv 40 end W_To_WChars;
ffa_ch1_genesis.kv 41
ffa_ch1_genesis.kv 42
ffa_ch1_genesis.kv 43 -- Display a hex representation of W to stdout
ffa_ch1_genesis.kv 44 procedure Dump(W : in Word) is
ffa_ch1_genesis.kv 45 T : WChars := W_To_WChars(W);
ffa_ch1_genesis.kv 46 begin
ffa_ch1_genesis.kv 47 for i in reverse T'Range loop
ffa_ch1_genesis.kv 48 Put(T(i));
ffa_ch1_genesis.kv 49 end loop;
ffa_ch1_genesis.kv 50 end Dump;
ffa_ch1_genesis.kv 51
ffa_ch1_genesis.kv 52
ffa_ch1_genesis.kv 53 -- Display a hex representation of N to stdout
ffa_ch1_genesis.kv 54 procedure Dump(N : in FZ) is
ffa_ch1_genesis.kv 55 begin
ffa_ch1_genesis.kv 56 for i in reverse N'Range loop
ffa_ch1_genesis.kv 57 Dump(N(i));
ffa_ch1_genesis.kv 58 end loop;
ffa_ch1_genesis.kv 59 end Dump;
ffa_ch1_genesis.kv 60
ffa_ch1_genesis.kv 61 end FFA_IO;