-
+ 0AF3B0F9472F5C3AA25C62E3038E27DBB016BFA0451A28A86ACFC52CF7B31BD3E51067BF679C5331BEEA94419D92DBCE45351BB00143F2865D07E44E86C5168Cffa/ffacalc/ffa_io.adb(0 . 0)(1 . 65)
719 ------------------------------------------------------------------------------
720 ------------------------------------------------------------------------------
721 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
722 -- --
723 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
724 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
725 -- --
726 -- You do not have, nor can you ever acquire the right to use, copy or --
727 -- distribute this software ; Should you use this software for any purpose, --
728 -- or copy and distribute it to anyone or in any manner, you are breaking --
729 -- the laws of whatever soi-disant jurisdiction, and you promise to --
730 -- continue doing so for the indefinite future. In any case, please --
731 -- always : read and understand any software ; verify any PGP signatures --
732 -- that you use - for any purpose. --
733 -- --
734 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
735 ------------------------------------------------------------------------------
736 ------------------------------------------------------------------------------
737
738 with OS; use OS;
739
740
741 with Words; use Words;
742 with W_Shifts; use W_Shifts;
743 with FZ_Type; use FZ_Type;
744
745
746 package body FFA_IO is
747
748 -- Obtain the WChars corresponding to the given Word
749 function W_To_WChars(N : Word) return WChars is
750 H : constant array(0 .. 15) of Character := "0123456789ABCDEF";
751 W : Word := N;
752 Result : WChars;
753 begin
754 for b in WChars'Range loop -- From bottom to top:
755 Result(B) := H(Natural(W and 16#F#)); -- Get current nibble.
756 W := Shift_Right(W, 4); -- Get the next nibble.
757 end loop;
758 return Result;
759 end W_To_WChars;
760
761
762 -- Display a hex representation of W to stdout
763 procedure Dump(W : in Word) is
764 T : WChars := W_To_WChars(W);
765 begin
766 for i in reverse T'Range loop
767 Write_Char(T(i));
768 end loop;
769 end Dump;
770
771
772 -- Display a hex representation of N to stdout
773 procedure Dump(N : in FZ) is
774 begin
775 for i in reverse N'Range loop
776 Dump(N(i));
777 end loop;
778
779 -- Newline, for clarity.
780 Write_Newline;
781 end Dump;
782
783 end FFA_IO;