Skip to content

Instantly share code, notes, and snippets.

@Tpaefawzen
Created February 1, 2024 12:11
Show Gist options
  • Select an option

  • Save Tpaefawzen/97d3a8f41710150c4385b3ba9850b6c2 to your computer and use it in GitHub Desktop.

Select an option

Save Tpaefawzen/97d3a8f41710150c4385b3ba9850b6c2 to your computer and use it in GitHub Desktop.
I seemed to have wanted to know what hybrid 32bit array could give me desired READ OUT output shall be done in CLC-INTERCAL.
#!/usr/bin/env perl
my $line = shift;
my @values = unpack("C*", $line);
my $ptr = 0;
my @val = ();
my $io = 172;
for my $datum (@values) {
my $chr = $datum;
my $chr0 = $chr;
my $bits0 = 0;
my $bits1 = 0;
for (my $i = 0; $i < 8; $i++) {
if ($io & 0x80) {
$bits0 <<= 1;
$bits0 |= 1 if $chr & 0x80;
} else {
$bits1 <<= 1;
$bits1 |= 1 if ! ($chr & 0x80);
}
$chr <<= 1;
$io <<= 1;
}
$chr = int(rand 0xffff) + 1;
for (my $i = 0; $i < 8; $i++) {
$chr <<= 2;
$chr |= 2 if $bits0 & 0x80;
$chr |= 1 if $bits1 & 0x80;
$bits0 <<= 1;
$bits1 <<= 1;
}
$datum = $chr;
$io = $chr0;
}
print"$_ ".($_&0xffff)."\n"foreach@values;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment