> > #?!@$^%&*)&^%#@$%^&*(()_)(*&^%$#@@@#$$%^&
> Wonder if can be transmuted into a runnable C-INTERCAL program though...

Hrm, that reminds me of something. Oh yes...

#!/usr/bin/perl
$h=q,!"#$%&'()~+*[]{},,%h=map{$_=>$i++}split//,$h; sub h2d{$h{$_[0]}*16+
$h{$_[1]}}while (<>) {s}\s}}g;ilk($!,$.)if(/([^$h])/);push @_, split //;
} while(@_){($a,$b)=(shift@_,shift@_);odd() if !$b;unshift @p, h2d($a,$b
);}sub ilk {die "Illegal character $_[0] in line $_[1]\n";}sub odd { die
"Input is odd\n";}sub nop {die "No op in register $_\n";} $op[0]=\&stop;
sub stop {($a,$b)=get(2);$r[$b]=$a;}$op[16]=\&pout;sub pout{($a)=get(1);
print chr($r[$a])} sub RUN{while(@p){($_)=get(1); nop if!defined $r[$_];
&{$op[$r[$_]]}}}$r[0]=0;sub hcf{<*> while 1;}$op[1]=\&hcf;sub get{my@ret
;$a=shift;while ($a--){@p||die"Not enough arguments at ".(caller(1))[3];
push@ret,shift@p} @ret}$op[2]=\&spin;sub spin {($_)=get(1);get($_);}$op[
187]=\&foad;sub foad{die "FOAD\n"};$op[50]=\&evl; sub evl{($a,$b)=get(2)
;eval join "",map {chr} @r[$a..$b]} RUN # ******!! version 0, 09/05/2000

__END__

=head1 DESCRIPTION

The ******!! Programmer's Reference Guide

=head1 PERPETRATOR

Simon Cozens, <[EMAIL PROTECTED]>

=head1 THE ******!! LANGUAGE

=head2 Principles

******!! is a machine-code-like programming language. It has 256
registers, and a number of operations, which will be detailed later.

******!! bytes are read from a program file in pairs of characters and
in reverse order, from the last line to the first and from right-to-left
in the line - that is, the program

     "]!+!""]##!!"['%!!"*'[!!"+(#!!"~'}!!")((!!"(#!!!"'#[!!"&'}!!"%'[!!
     "$'[!!"#'&!!""%)!!"!##!!!}#!!!!{(%!!!]'{!!!['~!!!*(#!!!+(!!!!"$#!!

will be read as the bytes:

     !! $# !" !! (! !+ !! (# !* !! '~ ![ !! '{ !] !! (% !{ !! #! !} !!
     ## "! !! %) "" !! '& "# !! '[ "$ !! '[ "% !! '} "& !! #[ "' !! #!
     "( !! (( ") !! '} "~ !! (# "+ !! '[ "* !! '% "[ !! ## "] !" !+ "]

=head2 Initialisation

When ******!! begins, all registers are empty, apart from register zero
which contains a zero. This is highly significant.

Unlike most other machine code languages, you cannot execute operations
directly - this is regarded as inflexible. Instead, you execute
registers. Therefore, the first thing your program must do is call
register zero to store some operations in some other registers. Hence,
all valid ******!! program files will end in the single byte !!

Naturally, there is a code-data equivalence. The operation STOP (!!) is
also the literal zero.

=head2 Character set

******!! bytes are encoded in a special character set and number system.
The character set contains the following 16 characters:

      ! " # $ % & ' ( ) ~ + * [ ] { }

Users of bit-paired keyboards, such as the Japanese JP106, will be
grateful for this.

The number system works as one may expect from the above: !! is 0, !"
is 1, and so on.

=head1 EXAMPLES

So, for instance, storing operation POUT in register 83 may be
represented in a pseudo-assembly language like this:

      STOP POUT, 83

which translates naturally into the ******!!

      !! "! &$

However, we must take care to remember that ******!! bytes are read in
reverse order, so this should appear as

      &$ "! !!

in our program. (Spaces are, of course, optional.)

=head2 Hello, World

Here is the canonical "Hello, world" program in ******!!. It is a basic
and rather poor implementation, and doubtless there are many stylistic
improvements which could be made.

      !#!"!#!+!!!#!"!#'%!!!#!"!#'[!!!#!"!#(#!!!#!"!#'}!!!#!"!#((!!!#!"!
      ##!!!!#!"!##[!!!#!"!#'}!!!#!"!#!"!#'[!!!#!"!#'&!!!#!"!#%)!!!""!!!

=head2 EVAL

One of the things that makes ******!! more powerful and easier to use
than many other machine-code-like languages is its built-in Perl
interpreter. The EVAL operation takes two parameters comprising a range
of registers and constructs a string consisting of the ASCII values of
the contents of the registers in the range. This string is then passed
to Perl.

Accordingly, here's another way of saying "Hello, world" which makes
use of this interpreter:

     "]!+!""]##!!"['%!!"*'[!!"+(#!!"~'}!!")((!!"(#!!!"'#[!!"&'}!!"%'[!!
     "$'[!!"#'&!!""%)!!"!##!!!}#!!!!{(%!!!]'{!!!['~!!!*(#!!!+(!!!!"$#!!

You'll notice that this is exactly the same size as the pure-******!!
version.

=head1 OPERATIONS

      Code Dec NAME Args Description
      !!    0  STOP 2    Store operation #1 in register #2

NOTE! ******!! will not stop you from overwriting registers: storing an
op onto register zero can be embarrassing if you don't have STOP stored
somewhere else.

You may also use STOP for storing data, since operations are data are
equivalent.

      !"    1  HCF  0    Halt and catch fire
      !#    2  SPIN 1    Ignore the next #1 instructions
      "!   16  POUT 1    Print the ASCII value of register #1
      $#   50  EVAL 2    Convert registers #1 through #2 to ASCII and
                         execute them as a Perl program
      **  187  FOAD 0    Terminate the program

It should be noted that ******!! gets its name from one of the shortest
programs to call FOAD.

=head1 To Do

Add many, many more operations. Implement a program counter and
addresses, and allow modification of the program store. Add gotos,
conditions and loops.

=head1 COPYRIGHT

******!! is copyright Simon Cozens. You may distribute ******!! under
the same terms as Perl itself - that is, GPL or Artistic License at
your choice.
-- 
<dngor> Every little bit of seaweed kelps.

Reply via email to