DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400 Tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400 Tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: B T

⟦e17f5df8e⟧ TextFile

    Length: 3753 (0xea9)
    Types: TextFile
    Names: »B«

Derivation

└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
    └─⟦5cb1d1d7f⟧ »DATA« 
        └─⟦3b1ee7bd8⟧ 
            └─⟦this⟧ 

TextFile

with Byte_Defs;
with Byte_String_Io;
with Crc;
with Crc_Ccitt;
with Text_Io;

procedure Crc_Test (Data : Integer) is

    A : constant Byte_Defs.Byte := 16#03#;
    B : constant Byte_Defs.Byte := 16#01#;

    Sabm_A : constant Byte_Defs.Byte_String (0 .. 1) := (A, 16#3F#);
    Sabm_B : constant Byte_Defs.Byte_String (0 .. 1) := (B, 16#3F#);
    Ua_A : constant Byte_Defs.Byte_String (0 .. 1) := (A, 16#73#);
    Ua_B : constant Byte_Defs.Byte_String (0 .. 1) := (B, 16#73#);

    package Crc16 is new Crc.Accumulator (Crc.Crc16_Generator);

    function Image (Data : Integer) return String renames Integer'Image;

    function Image (Data : Byte_Defs.Byte_String) return String
        renames Byte_String_Io.Image;

    procedure Show (D : Byte_Defs.Byte_String) is
        R : Crc.Checksum;
    begin
        R := Crc_Ccitt.Preset;
        Crc_Ccitt.Accumulate (R, D);
        R := Crc."not" (R);
        Text_Io.Put_Line ("CCITT (" & Image (D) & ") =" & Crc.Image (R));

        R := Crc.All_0;
        Crc16.Accumulate (R, D);
        Text_Io.Put_Line ("CRC16 (" & Image (D) & ") =" & Crc.Image (R));

        Text_Io.Put_Line ("");
    end Show;

    function To_Byte_String (Data : Integer) return Byte_Defs.Byte_String is
        T : Integer := Data;
        D : Byte_Defs.Byte_String (0 .. 7);
    begin
        for I in reverse D'Range loop
            D (I) := Byte_Defs.Byte (T mod 256);
            T := T / 256;
        end loop;
        return D;
    end To_Byte_String;

    procedure Test_Convert (X : Natural) is
        C : Crc.Checksum := Crc.Convert (X);
        X2 : Natural := Crc.Convert (C);
    begin
        if X2 /= X then
            Text_Io.Put_Line ("*** error: " & "Convert (" & Image (X) &
                              ") =" & Crc.Image (C) & "; Convert (Convert (" &
                              Image (X) & ") =" & Image (X2));
        end if;
    end Test_Convert;

    procedure Test_Ccitt (D : Byte_Defs.Byte_String; N : Natural) is
        C : Crc_Ccitt.Checksum;
        Prefix : constant String := "*** error: CCITT (" & Image (D) & ")";
        Padding : constant String (Prefix'Range) := (others => ' ');
    begin
        C := Crc_Ccitt.Preset;
        Crc_Ccitt.Accumulate (C, D);
        C := Crc."not" (C);
        if Crc."/=" (C, Crc.Convert (N)) then
            Text_Io.Put_Line (Prefix & " =" & Crc.Image (C));
            Text_Io.Put_Line (Padding & "/=" & Crc.Image (Crc.Convert (N)));
        end if;
    end Test_Ccitt;

    procedure Loop_Ccitt (D : Byte_Defs.Byte_String) is
        C : Crc_Ccitt.Checksum;
        Prefix : constant String :=
           "*** error: CCITT remainder (" & Image (D) & ")";
        Padding : constant String (Prefix'Range) := (others => ' ');
    begin
        C := Crc_Ccitt.Preset;
        Crc_Ccitt.Accumulate (C, D);
        Crc_Ccitt.Accumulate (C, Byte_Defs.Byte_String (Crc."not" (C)));

        if Crc."/=" (C, Crc_Ccitt.Remainder) then
            Text_Io.Put_Line (Prefix & " =" & Crc.Image (C));
            Text_Io.Put_Line (Padding & "/=" & Crc.Image (Crc_Ccitt.Remainder));
        end if;
    end Loop_Ccitt;

begin
    Show (To_Byte_String (Data));

    for I in 0 .. 15 loop
        Test_Convert (2 ** I);
    end loop;
    Test_Convert (0);
    Test_Convert ((2 ** 16) - 1);

    Test_Ccitt (Sabm_A, 2#1101_1010_0011_0111#);
    Test_Ccitt (Sabm_B, 2#1101_0111_1111_1011#);
    Test_Ccitt (Ua_A, 2#1100_1100_0010_0110#);
    Test_Ccitt (Ua_B, 2#1100_0001_1110_1010#);

    Loop_Ccitt (Sabm_A);
    Loop_Ccitt (Sabm_B);
    Loop_Ccitt (Ua_A);
    Loop_Ccitt (Ua_B);
    Loop_Ccitt (To_Byte_String (0));
    for I in 0 .. 30 loop
        Loop_Ccitt (To_Byte_String (2 ** I));
    end loop;
    Loop_Ccitt (To_Byte_String (2 ** 31));
end Crc_Test;