-
+ 408328BDCB8543BFF0E7ADFD454105C5B1876C7EE71EF41337622BD95D269188F6643FD8BF9EA6076692AEFC59E63A9A02B986B7C4C697B76A3EA0B69A4FFB87ffa/ffademo/ffa_io.adb(0 . 0)(1 . 61)
297 ------------------------------------------------------------------------------
298 ------------------------------------------------------------------------------
299 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
300 -- --
301 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
302 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
303 -- --
304 -- You do not have, nor can you ever acquire the right to use, copy or --
305 -- distribute this software ; Should you use this software for any purpose, --
306 -- or copy and distribute it to anyone or in any manner, you are breaking --
307 -- the laws of whatever soi-disant jurisdiction, and you promise to --
308 -- continue doing so for the indefinite future. In any case, please --
309 -- always : read and understand any software ; verify any PGP signatures --
310 -- that you use - for any purpose. --
311 -- --
312 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
313 ------------------------------------------------------------------------------
314 ------------------------------------------------------------------------------
315
316 with Ada.Text_IO; use Ada.Text_IO;
317
318 with Words; use Words;
319 with W_Shifts; use W_Shifts;
320 with FZ_Type; use FZ_Type;
321
322
323 package body FFA_IO is
324
325 -- Obtain the WChars corresponding to the given Word
326 function W_To_WChars(N : Word) return WChars is
327 H : constant array(0 .. 15) of Character := "0123456789ABCDEF";
328 W : Word := N;
329 Result : WChars;
330 begin
331 for b in WChars'Range loop -- From bottom to top:
332 Result(B) := H(Natural(W and 16#F#)); -- Get current nibble.
333 W := Shift_Right(W, 4); -- Get the next nibble.
334 end loop;
335 return Result;
336 end W_To_WChars;
337
338
339 -- Display a hex representation of W to stdout
340 procedure Dump(W : in Word) is
341 T : WChars := W_To_WChars(W);
342 begin
343 for i in reverse T'Range loop
344 Put(T(i));
345 end loop;
346 end Dump;
347
348
349 -- Display a hex representation of N to stdout
350 procedure Dump(N : in FZ) is
351 begin
352 for i in reverse N'Range loop
353 Dump(N(i));
354 end loop;
355 end Dump;
356
357 end FFA_IO;