Deadfish

From Esolang
Jump to navigation Jump to search

Deadfish is a very odd interpreted programming language created by Jonathan Todd Skinner. It was released under public domain and was originally programmed in C, but has since been ported to many other programming languages (see below).

Deadfish has a way to output things but it has no way to input them! It only has a few commands, only four in total. It is also case-sensitive, and can deal only with integer values when adding or subtracting, however once squared this number increases greatly!

You can have several commands per line, at least in the C implementation.

Errors are not acknowledged: the shell simply adds a newline character!

Anything that is not a command is not accepted by the interpreter. As you've probably assumed deadfish was created in less than a hour, and can be very useful in creating highly interactive programs.

Commands

Increment Decrement Square Output
Standard Deadfish i d s o
XKCD variation x d k c
f() variation f f() f () f(())
F!-- variation F! U! C! K!

Sometimes, the additional command 'h', meaning halt, is used. Although the comment in the C implementation states /* Make sure x is not greater then [sic] 256 */, the implementation sets the value to zero if and only if value == -1 || value == 256.

Why "deadfish"?

Deadfish started out as a subset of HQ9+, as all it would do would be to print out hello world and give an iou depending on how many times the command 9 was entered for how many 99 bottles of beer programs it owed the programmer. Deadfish was originally going to be called fishheads as programming in this language is like eating raw fish heads. However, due to the limiting features of the language, programming in this language became like eating (and having to smell) dead, rotting fish heads, an experience not often generally considered pleasurable.

Example programs

Note: the standard shell adds >> characters for readability.

>> i
>> 
>> o
1
>> d

This program prints the ASCII values (as numbers, not characters, since Deadfish does not have character output) of the characters in the string "Hello, world!"

iiisdsiiiiiiiioiiiiiiiiiiiiiiiiiiiiiiiiiiiiioiiiiiiiooiiio
dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddoddddddddddddo
dddddddddddddddddddddsddoddddddddoiiioddddddoddddddddo
dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddo

Mandatory test cases

Since the proper behavior of Deadfish arithmetic can be *cough* surprising, here are a few important test cases for people making interpreters: The program

iissso

should print 0; the program

diissisdo

should print 288; and the program

iissisdddddddddddddddddddddddddddddddddo

should print 0.

Interpreters that do not support these test cases and cannot trivially be fixed may be removed from this page. In particular, it is required to support numbers at least up to 17^2 == 289 to showcase the strange behavior also of the s command.

Implementations

Some of these implementations may not be considered fully compliant, sometimes because an implementor has implemented the intuitive meaning of the commands rather than the subtle deadfish way. For some of the implementations it may be hard for people other than the implementor to tell whether they are compliant or not.

A:;

Interprets one instruction per line

v:-1.0;w:256.0;u:\n;t:1;r:0;j:i;l:d;b:s;o:o;c:>>;p:c;?:r:=:v:1;r:0;?:r:=:w:1;r:0;i:q;?:q:=:o:3;p:r;p:u;g:10;?:q:=:j:2;a:r:t;g:10;?:q:=:l:2;s:r:t;g:10;?:q:=:b:2;m:r:r;g:10;p:u;g:10

Ada

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Containers.Indefinite_Holders;
with Ada.Integer_Text_IO;

procedure Deadfish is
   package String_Holder is new Ada.Containers.Indefinite_Holders(String);
   use String_Holder;

   value_output : Natural := 0;
   str_input : String_Holder.Holder := To_Holder("");
begin
   Prompt :
   loop
      Put(">> ");
      String_Holder.Replace_Element(str_input, Get_Line);
      for rg in str_input.Element'Range loop
         case str_input.Element(rg) is
            when 'i' | 'x' => 
               case value_output is
                  when 255 => value_output := 0;
                  when others => value_output := Natural'Succ(value_output);
               end case;

            when 'd'       =>                   
               case value_output is
                  when 257 => value_output := 0;
                  when 0 => null;
                  when others => value_output := Natural'Pred(value_output);
               end case;
            when 's' | 'k' => 
               case value_output is
                  when 16 => value_output := 0;
                  when others =>value_output := value_output * value_output;
               end case;
            when 'o' | 'c' => Ada.Integer_Text_IO.Put(value_output, Width => 0); Put_Line("");
            when others => null;
         end case;
      end loop;
   end loop Prompt;
end Deadfish;

APL

∇Deadfish;x
   x ← 0
line:
   ⍞ ← '>> '
   { x ∘← (~x∊¯1 256) × x
     ⍵∊'ix': x ∘← x + 1
     ⍵∊'d':  x ∘← x - 1
     ⍵∊'sk': x ∘← x * 2
     ⍵∊'oc': ⎕ ← x
   }¨⍞
   → line
∇

APLBAONWSJAS

EXECUTE(Deadfish)

A Slow Language

r0:rI~rd
     x _^"i"d
           d=:r1+:rd
        d^ l
        r"d"d
           d=:r1-:rd
        d^ l
        r"s"d
           d=:r^*:rd
        d  l
        r"o"d
           d=:r^o:rd
        d  l       l
      O r:r^F1+^*d
      A     d-10^=0:rvd
      v  dr:=0:rvd
      u  l       l    l

Attache

?? state-ful deadfish interpreter
acc := 0
line := ""

deadfish[code] :=
    ForEach[code,
        If[_ = "i", acc := acc + 1];;
        If[_ = "d", acc := acc - 1];;
        If[_ = "s", acc := acc ^ 2];;
        If[_ = "o", Print[acc]];;

        If[acc = -1 or acc = 256, acc := 0]
    ]

DoWhile[line /= nil,
    deadfish[line];;
    line := Prompt[">> "]
]

Or, with the langs library:

Needs[$langs]
acc := 0
line := ""

DoWhile[line /= nil,
    acc := deadfish[line, acc];;
    line := Prompt[">> "]
]

AWK

It won't display the prompt, but other than that is complete.

sub(/o/,x=x*(x>0&&x-256)*x^/s/+/i/-/d/)

Bash

#!/bin/bash

no=0

while true; do
	((no==256||no<0)) && no=0
	echo -n '>> ' # prompt
	if read; then
		case $REPLY in
			d) ((no--)) ;;
			i) ((no++)) ;;
			o) echo $no ;;
			s) no=$((no*no)) ;;
			*) : ;;
		esac
	else
		echo # on EOF
	fi
done

Batch

@echo off
:start
set/pcmd=^>^>
if %cmd%==i set /a acc=%acc%+1
if %cmd%==d set /a acc=%acc%-1
if %cmd%==s set /a acc=%acc%*%acc%
if %cmd%==o echo %acc%
if %acc%==256 set %acc%=0
if %acc%==-1 set %acc%=0
goto start

Here is another variant with an additional debug command "?" and the halt command "h".

@echo off
set debug=0
:start
set cmd=0
set/pcmd=^>^>
if %cmd%==i set/aacc=%acc%+1&if %debug%==1 echo %acc%+1
if %cmd%==d set/aacc=%acc%-1&if %debug%==1 echo %acc%-1
if %cmd%==s set/aacc=%acc%*%acc%&if %debug%==1 echo %acc%*%acc%
if %cmd%==o echo %acc%
if %cmd%==h set acc=0&set debug=0&goto :eof
if %cmd%==? (if %debug%==0 (set debug=1) else (set debug=0))
if %acc%==256 set acc=0
if %acc%==-1 set acc=0
goto start

GNU bc

/*Bc does not support character I/O. Here is an alternate mapping:
 *0:i
 *1:d
 *2:s
 *3:o
 */
ac=0
while(1) {
    if(ac==-1)ac=0
    if(ac==256)ac=0
    print ">> "
    a=read()
    if(a==0)ac+=1
    else if(a==1)ac-=1
    else if(a==2)ac*=ac
    else if(a==3)print ac
}
quit

Befunge-93

v  Deadfish in Befunge
0
>0" >>">:vv            <
,#        _$:vv-*5+7*44
+     v    <  _:*v    
:  $  v^,_v^.<   >    
5> ~    >#$>:375**-v
^     < $ #v-*:*25:_$1+
^#-*65-*99:_$1-       #v
 ^  _$0~^ >:1+v
   -^>    #1-#_1+:48:**

Befunge-98

0v   ^;#+1$< ;;#-1$< ;;#*:$<   ;.:$<
>>#@~:'i-!#^_:'d-!#^_:'s-!#^_:'o-!#^_
^    > :f1+:*-!#v_:01--!#v_
^             0$<        <

Bidiroop

Set accumulator, 0
Class Deadfish
  Function i
    Set accumulator, accumulator + 1
    If accumulator = 256
      Set accumulator, 0
    Return 0
  Function d
    Set accumulator, accumulator - 1
    If accumulator = -1
      Set accumulator, 0
    Return 0
  Function s
    Set accumulator, accumulator ^ 2
    If accumulator = 256
      Set accumulator, 0
    Return 0
  Function o
    Print accumulator
    Return 0
Function main
  InputString code
  Set counter, 0
  Set countermax, code -^ code
  Set total_class_str, "Method run\n"
  While countermax > counter
    Set piece, code -/ (counter + 1)
    Set piece, piece /- counter
    Set total_class_str, total_class_str +* ("  Set dummy, <F>[" +* (piece +* "][]\n"))
    Set counter, counter + 1
  Set total_class_str, total_class_str +* "Return <C>(\"\")"
  Set ConstructedClass, <C>(total_class_str) &* Deadfish
  Set the_object, ConstructedClass[]
  Set dummy, <M>[the_object][run][]

Boo

/* Deadfish in Boo */
# by Chris Pressey
// Hallowe'en 2012
a = 0
while true:
    if a < 0 or a == 256:
        a = 0
    c = prompt(">> ")
    if c == 's':
        a *= a
    elif c == 'i':
        a += 1
    elif c == 'd':
        a -=  1
    elif c == 'o':
        print(a)

Brainfuck

Implementation by User:David.werecat, reads one line of input at a time (for compatibility with most brainfuck interpreters) and interprets only one instruction per line

>+[<++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++..-------
-----------------------.[-]>>[-]+>,----------[-----------------------------
-------------------------------------------------------------[-----[------[
----[<->[-]]<[>>>[-]>[-]>[-]>[-]<<<<[>+>+>+<<<-]>[>[<<+>>-]>[>+<-]>[<+<+>>-
]<<<-]<<<-]>]<[>>>[-]>[-]>[-]>[-]>[-]>[-]<<<<<<[->+>>>>>+<[-]+<<<<---------
-[>>>>[<++++++++++<<->>>-]<+<<<-]>>>[<<<+>>>-]<<+>>>[-]+<<<----------[>>>[<
++++++++++<->>-]<+<<-]>>[<<+>>-]<+<<<]>>>>[-]>[-]<<[>+<<<<[-]++++++++++++++
++++++++++++++++++++++++++++++++++>>>[<<<+>>>-]<<<.>>>]>[<<<<[-]+++++++++++
+++++++++++++++++++++++++++++++++++++>>[<<+>>-]<<.>>>>-]<<[<<[-]+++++++++++
+++++++++++++++++++++++++++++++++++++>>[<<+>>-]<<.>>]<<[-]+++++++++++++++++
+++++++++++++++++++++++++++++++>[<+>-]<.[-]++++++++++.---------->>>>>>[<<<<
<<+>>>>>>-]<<<<<<<<-]>]<[>>+<<-]>]<[>>>[-]+>[-]<<[>[-]>+<<-]>>-[<<+>>-]<<>[
<+>-]<<<-]>]<[>-<-]>+[,----------]<<]

Implementation by User:None1 and generated by BFFuck, it has an interactive shell and interprets only one instruction per line, but it runs on 8 bit cells with wrapping

>>>>>>>>>>>>>>>[-]>+[<<++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++.[-]>>>,>,>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<<<<<[-]<[-]>>>>>>[<<<<<<+>>>>>>-]+<<[<<<<->+>>>-]<<<[>>>+<<<-]<[>>>>>>-<<<<<<[-]]>[-]<[-]>>>>>>[<<<<<+<+>>>>>>-]<<<<<[>>>>>+<<<<<-]<[>>+<<[-]]>>>>>>[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<<<<<[-]<[-]>>>>>>[<<<<<<+>>>>>>-]+<<[<<<<->+>>>-]<<<[>>>+<<<-]<[>>>>>>-<<<<<<[-]]>[-]<[-]>>>>>>[<<<<<+<+>>>>>>-]<<<<<[>>>>>+<<<<<-]<[>>-<<[-]]>>>>>>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<<<<<[-]<[-]>>>>>>[<<<<<<+>>>>>>-]+<<[<<<<->+>>>-]<<<[>>>+<<<-]<[>>>>>>-<<<<<<[-]]>[-]<[-]>>>>>>[<<<<<+<+>>>>>>-]<<<<<[>>>>>+<<<<<-]<[>>>>>>>[-]<<<<<[>>>>>+<<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>-]<<<<<<<<<<<<<<<[>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<-]>>>>>>>>>>>>>>[-]<[-]>>[<<+>>-]<<[>>>>>>>[<<<<<+<+>>>>>>-]<<<<<<[>>>>>>+<<<<<<-]<-][-]]>>>>>>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<<<<<[-]<[-]>>>>>>[<<<<<<+>>>>>>-]+<<[<<<<->+>>>-]<<<[>>>+<<<-]<[>>>>>>-<<<<<<[-]]>[-]<[-]>>>>>>[<<<<<+<+>>>>>>-]<<<<<[>>>>>+<<<<<-]<[>>[<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>+>-]<<<<<<<<<<<<<++++++++++<<[->+>-[>+>>]>[+[-<+>]>+>>]<<<<<<]>>[-]>>>++++++++++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>[-]>>[>++++++[-<++++++++>]<.<<+>+>[-]]<[<[->-<]++++++[->++++++++<]>.[-]]<<++++++[-<++++++++>]<.[-]<<[-<+>]<[-]>>>>>>>>>>>>>>[>+<-][-]++++++++++.[-]<[-]]>>>]

A shorter alternative compiled with a higher version of BFFuck.

>>>>>>>>>>>>>>>[-]>+[<<++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++.[-]>>>,>,>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<<<<<[-]<[-]>>>>>>[<<<<<<+>>>>>>-]+<<[<<<<->+>>>-]<<<[>>>+<<<-]<[>>>>>>-<<<<<<[-]]>[-]<[-]>>>>>>[<<<<<+<+>>>>>>-]<<<<<[>>>>>+<<<<<-]<[>>+<<[-]]>>>>>>[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<<<<<[-]<[-]>>>>>>[<<<<<<+>>>>>>-]+<<[<<<<->+>>>-]<<<[>>>+<<<-]<[>>>>>>-<<<<<<[-]]>[-]<[-]>>>>>>[<<<<<+<+>>>>>>-]<<<<<[>>>>>+<<<<<-]<[>>-<<[-]]>>>>>>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<<<<<[-]<[-]>>>>>>[<<<<<<+>>>>>>-]+<<[<<<<->+>>>-]<<<[>>>+<<<-]<[>>>>>>-<<<<<<[-]]>[-]<[-]>>>>>>[<<<<<+<+>>>>>>-]<<<<<[>>>>>+<<<<<-]<[>>>>>>>[-]<<<<<[>>>>>+<<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>-]<<<<<<<<<<<<<<<[>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<-]>>>>>>>>>>>>>>[-]<[-]>>[<<+>>-]<<[>>>>>>>[<<<<<+<+>>>>>>-]<<<<<<[>>>>>>+<<<<<<-]<-][-]]>>>>>>[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<<<<<[-]<[-]>>>>>>[<<<<<<+>>>>>>-]+<<[<<<<->+>>>-]<<<[>>>+<<<-]<[>>>>>>-<<<<<<[-]]>[-]<[-]>>>>>>[<<<<<+<+>>>>>>-]<<<<<[>>>>>+<<<<<-]<[>>[<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>+>-]<<<<<<<<<<<<<<[-]>[-]+>[-]+<[>[-<-<<[->+>+<<]>[-<+>]>>]++++++++++>[-]+>[-]>[-]>[-]<<<<<[->-[>+>>]>[[-<+>]+>+>>]<<<<<]>>-[-<<+>>]<[-]++++++++[-<++++++>]>>[-<<+>>]<<]<[.[-]<]<[-]>>>>>>>>>>>>>>[>+<-][-]++++++++++.[-]<[-]]>>>]

Buffalo!

This is a full implementation when run under the Python interpreter (which has unbounded integers). Output of large numbers (beyond about 1000) is quite slow, since exponentiation, multiplication, division and even addition have to be implemented from scratch using unary increment/decrement, but it gets there in the end. Characters other than 'i', 'd', 's' and 'o' have arbitrary interpretation.

Unfortunately it's too large to include on the page, but it's here: [1]

Burlesque

{?i ?d S[ J}j{{'i 'd 's 'o}jFi}m[si)bx{J{-1==}{256==}m|{256.%}if}IC0je!

C

/* <-- Deadfish Interpreted Computer Language --> */
/* <-- Programmed by Jonathan Todd Skinner    --> */

/* <-- Include Header File --> */
/* Updated the Code to Remove Uneeded Header Includes - JTS */
#include <stdio.h>

/* <-- Declare some variables --> */
unsigned int x; /* make a positive integer and call it x */
char usrinput; /* string to hold user input */

/* <-- Declare a function --> */
void entercommand(void);

/* <-- Start Main Function --> */
int main(void)
{
	/* At beginning of x is always 0 */
	x = 0;
	entercommand();
}

/* <-- Enter Command --> */
void entercommand(void)
{
	/* Accept User Input */
	printf(">> "); /* output shell symbol */
	scanf("%c",&usrinput); /* scan for user input that is char */
	/* Check for commands and do action */
	/* Make sure x is not greater then [sic] 256 */
	if(x == 256) x = 0;
	if(x == -1) x = 0;
	if(usrinput == 'i')
	{
		x++;
		entercommand();
	}		
	else if(usrinput == 'd')
	{
		x--;
		entercommand();
	}
	else if(usrinput == 'o')
	{
		printf("%d\n",x);
		entercommand();
	}
	else if(usrinput == 's')
	{
		x=x*x;
		entercommand();
	}
	else
	{
		printf("\n");
		entercommand();
	}

}

Here's a slightly cleaned up version:

/* <-- Deadfish Interpreted Computer Language --> */
/* <-- Original programmed by Jonathan Todd Skinner    --> */
/* <-- Dumb stuff removed by some other guy --> */

#include <stdio.h>

int main(void)
{
    unsigned int x = 0;

    while(1) {
        char input; 

        printf(">> "); 
        scanf("%c",&input); 

        if(x == 256 || x == -1) 
            x = 0;
  
        switch(input) {
            case 'i':
                ++x;
                break;		
   	    case 'd':
	        --x;
	        break;
	    case 'o':
	        printf("%d\n",x);
	        break;
	    case 's':
	        x*=x;
	        break;
            default:
	        printf("\n");
	        break;
        }
    }
}

There is a horribly short interpreter (I won't add ">>", since it wastes a lot of code):

/* <-- By:Asdf --> */
#include<stdio.h>
int main(){
    int x=0;
    for(;;){
        char i;
        i=getchar();
        if(x==256||x==-1)x=0;
        if(i=='i')++x;
   	else if(i=='d')--x;
	else if(i=='o')printf("%d\n",x);
	else if(i=='s')x*=x;
        else printf("\n");
    }
}

Unfortunately, many inplementers use input. It would be a lot shorter if it is predefined:

/* <-- By:Asdf --> */
#include<stdio.h>
int main(){
    int ptr=0, x=0;
    char c[10000]="";//Code goes here
    for(;c[ptr]!='\0';++ptr){
        if(x==256||x<0)x=0;
        if(c[ptr]=='i')++x;
   	else if(c[ptr]=='d')--x;
	else if(c[ptr]=='o')printf("%d\n",x);
	else if(c[ptr]=='s')x*=x;
        else printf("\n");
    }
}

Also, the most horrible (but short) interpreter (spaghetti code):

#include <stdio.h> //By: Positron
int main(){int x=0,i;a:i=getchar();if(x==256||x==-1)x=0;if(i=='i')++x;else if(i=='d')--x;else if(i=='o')printf("%d\n",x);else if(i=='s')x*=x;else putchar(10);goto a;} 

or in a more readable way:

/*By: Positron*/
#include <stdio.h>

int main()
{
	int x=0,i;
	a:
	i=getchar();
	if(x==256||x==-1)
		x=0;
	if(i=='i')
		++x;
	else if(i=='d')
		--x;
	else if(i=='o')
		printf("%d\n",x);
	else if(i=='s')
		x*=x;
	else
		putchar(10);
	goto a;
}

Here's a slightly shorter (yet very unreadable) interpreter:

/* By: Presauced */
#include<stdio.h>main(){int x=0,i;for(;;){ 
i=getchar();if(x==256||x==-1)x=0;if(i=='i')
++x;else if(i=='d')--x;else if(i=='o')printf(
"%d\n",x);else if(i=='s')x*=x;else puts("\n");}}

C#

 public class Deadfish {
  private static int x = 0;
  private static Dictionary<char, Action> Commands = new Dictionary<char, Action> {
    { 'i', () => ++x },
    { 'd', () => --x },
    { 's', () => x *= x },
    { 'o', () => Console.WriteLine(x) }
  };
  static void Main(string[] args) {
    Action prompt = () => {
      Console.Write(">> ");
      Console.Out.Flush();
    };
    prompt();
    int cmd;
    while ((cmd = Console.Read()) != -1) {
      char command = Convert.ToChar(cmd);
      if (!Environment.NewLine.Contains(command)) {
        x = x == 256 || x < 0 ? 0 : x;
        (Commands.ContainsKey(command) ? Commands[command] : () => Console.WriteLine())();
        prompt();
      }
    }
  }
 }

another C# implementation

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Deadfish_Interpreter
{
    class Program
    {
        static void Main(string[] args)
        {
            StreamReader sr = new StreamReader(args[0]);
            string code = sr.ReadToEnd();
            code = code.Replace(((char)13).ToString(), "");

            int cell = 0;

            foreach (char c in code)
            {
                if (c == 'i')
                {
                    cell++;
                }
                else if (c == 'd')
                {
                    cell--;
                }
                else if (c == 's')
                {
                    int i = cell * cell;
                    cell = i;
                }
                else if (c == 'o')
                {
                    Console.Write(cell);
                }

                if (cell == -1 || cell == 256)
                {
                    cell = 0;
                }
            }

            Console.ReadLine();
        }
    }
}

Here is a large C# implementation written in only one statement by BoundedBeans. It's possibly a bit too large for this page.

C++ Codegolfed

//By: Areallycoolusername
// Supports one-liners
#include <iostream> 
using namespace std;
int main() {
int acc = 0; 
char a;
do {
    std::cout << ">> ";
    std::cin >> a;
    if(a=='i') { 
        acc++;
    }
    if(a=='d') { 
        acc--;
    }
    if(a=='s') {
        acc *= acc;
    }
    if(a=='o') { 
        std::cout << acc << endl;
    }   
    if(acc<0||acc==256) { 
        acc = 0;
    }
} while(a!='h');
return 69; //For the lols
}

Another implementation, based on the previous implementation:

// Implementation by Tsuki
#include<iostream>
int main(){int ac=0;char a;do{std::cout<<">>";std::cin>>a;switch(a){case'i':ac++;break;case'd':ac--;break;case's':ac*=ac;break;case'o':std::cout<<ac<<'\n';break;}if(ac<0||ac==256){ac=0;}}while(a!='q');return 0;}

C++ templates

#include <iostream>

//
#define PROGRAM i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,i,o,s,i,o,i,i,i,i,i,i,i,s,s,s,o
//

template <char n, typename Ns>
struct Cons {
  static void print() {
    Ns::print();
    std::cout << n;
  }
};

struct Nil {
  static void print() {}
};

template <typename Ms, typename Ns> struct Append;

template <typename Ns>
struct Append<Nil, Ns> {
  typedef Ns String;
};

template <char m, typename Ms, typename Ns>
struct Append<Cons<m, Ms>, Ns> {
  typedef Append<Ms, Ns> Next;
  typedef Cons<m, typename Next::String> String;
};

#define INS(name, expr) \
  struct name { \
    template <int n, typename Out> struct Result { \
      static const int value = expr; \
      typedef Out Output; \
    }; \
  }

INS(i, n + 1);
INS(d, n - 1);
INS(s, n * n);

template <int n> struct DecimalLoop;

template <> struct DecimalLoop<0> {
  typedef Nil String;
};

template <int n> struct DecimalLoop {
  typedef DecimalLoop<n / 10> Next;
  typedef Cons<'0' + (n % 10), typename Next::String> String;
};

template <int n> struct ToDecimal;

template <> struct ToDecimal<0> {
  typedef Cons<'\n', Cons<'0', Nil>> String;
};

template <int n> struct ToDecimal {
  typedef Cons<'\n', typename DecimalLoop<n>::String> String;
};

struct o {
  template <int n, typename Out> struct Result {
    static const int value = n;
    typedef typename Append<typename ToDecimal<n>::String, Out>::String Output;
  };
};

template <int n> struct Wrap {
  static const int value = n < 0 || n == 256 ? 0 : n;
};

template <typename... Is> struct Seq;

template <typename I, typename... Is>
struct Seq<I, Is...> {
  template <int n, typename Out> struct Result {
    typedef typename I::template Result<n, Out> A;
    typedef typename Seq<Is...>::template Result<Wrap<A::value>::value, typename A::Output> B;
    typedef typename B::Output Output;
  };
};

template <> struct Seq<> {
  template <int n, typename Out> struct Result {
    typedef Out Output;
  };
};

int main() {
  Seq<PROGRAM>::Result<0, Nil>::Output::print();
}

Castile

Runs under (at least) Castile 0.3. Does not accept more than one command per line.

fun main() {
  a = 0;
  c = "";
  while true {
    if a == 256 or a < 0 {
	a = 0;
    }
    c = input(">> ");
    if c == "i" {
        a = a + 1;
    } else if c == "d" {
        a = a - 1;
    } else if c == "s" {
        a = a * a;
    } else if c == "o" {
        print(str(a));
    }
  }
}

Chicken

chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken
chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken
chicken
chicken chicken
chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken chicken
chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken
chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken chicken
chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken
chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken chicken
chicken
chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken chicken
chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken

chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken

chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken chicken
chicken chicken chicken
chicken chicken chicken chicken chicken chicken chicken chicken

C-INTERCAL


PLEASE NOTE Written by oshaboy

DO ,1 <- #1024
DO WRITE IN ,1
DO .3 <- #0
PLEASE NOTE .20 is index
DO .20 <- #1
DO NOTE :10 is the accumulator
PLEASE :10 <- #0


DO COME FROM (40)
PLEASE NOTE Check if EOF
PLEASE .6 <- ',1 SUB .20'~#256
PLEASE ABSTAIN .6 FROM COMING FROM

(60) DO NOTHING
PLEASE (20) NEXT
DO COME FROM (60)
PLEASE REINSTATE COMING FROM
DO NOTE This loads the next char into .3
PLEASE REINSTATE NEXTING
DO .1 <- .3
DO .2 <- ,1 SUB .20
PLEASE (1009) NEXT
PLEASE NOTE This removes capitalization and makes the code MUCH shorter
DO .5 <- .3~#31
PLEASE ABSTAIN .5 FROM NEXTING

PLEASE (20) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
PLEASE (31) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
PLEASE (32) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
PLEASE (33) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
PLEASE (34) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT
DO REINSTATE NEXTING
DO (44) NEXT

DO COME FROM (51)
DO COME FROM (52)
DO COME FROM (53)
DO COME FROM (54)
(44) DO FORGET #1
DO .1 <- .20
PLEASE (1020) NEXT
PLEASE .20 <- .1
PLEASE NOTE Check if greater then[sic] 256
DO :1 <- :10
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1



DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1


DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1


DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1
DO :1 <- :&1

PLEASE :1 <- :1~#1
PLEASE ABSTAIN :1 FROM COMING FROM
(46) DO NOTHING
DO (35) NEXT
PLEASE REINSTATE COMING FROM
PLEASE COME FROM (46)
PLEASE :1 <- :10~#256
PLEASE ABSTAIN :1 FROM COMING FROM
(47) DO NOTHING
PLEASE REINSTATE COMING FROM
DO :1 <- :10~'#65535$#65519'

DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1

DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1

DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1

DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1
DO :1 <- :V1

PLEASE :1 <- :1~#1

PLEASE ABSTAIN :1 FROM NEXTING
PLEASE (35) NEXT
PLEASE REINSTATE NEXTING
PLEASE COME FROM (47)



(40) PLEASE DO NOTHING



(20) PLEASE GIVE UP

(31)
PLEASE :1 <- :10
PLEASE :2 <- #1
DO (1510) NEXT
(51) PLEASE :10 <- :3

(32)
PLEASE :1 <- :10
PLEASE :2 <- #1
DO (1509) NEXT
(52) PLEASE :10 <- :3

(33) PLEASE READ OUT :10
(53) DO NOTHING

(34)
PLEASE :1 <- :10
PLEASE :2 <- :10
DO (1549) NEXT
(54) PLEASE :10 <- :3

(35)
PLEASE :10 <- #0
PLEASE RESUME #1

Clever

import std.io.* as io;
Int a = 0;
String c;
while (true) {
    if (a < 0 || a == 256) {
        a = 0;
    }
    io::print(">> ");
    c = io::readln();
    if (c == "s") {
        a *= a;
    } else if (c == "i") {
        a += 1;
    } else if (c == "d") {
        a -=  1;
    } else if (c == "o") {
        io::print(a);
        io::print("\n");
    }
}

COBOL

       identification division.
       program-id. deadfish.
       data division.
       working-storage section.
       77 n                    usage binary-int unsigned.
       77 deadfish             pic x.
       procedure division.
       perform forever
           call "printf" using z">> " end-call
           call "scanf" using z"%c" deadfish end-call
           if (n equal -1) or (n equal 256) then move 0 to n end-if
           evaluate deadfish
               when equal "d"
                   subtract 1 from n giving n end-subtract
               when equal "i"
                   add 1 to n giving n end-add
               when equal "o"
                   call "printf" using x"25641000" by value n end-call
               when equal "s"
                   multiply n by n end-multiply
               when equal "h"
                   exit perform
               when other
                   call "printf" using x"1000" end-call
           end-evaluate
       end-perform
       goback.
       end program deadfish.

Commodore 64 BASIC

Type "H" to quit. (Fixed to comply with the Deadfish 0-255 rule (again (again))). This program will also work in several other 8-bit BASICs, such as Applesoft BASIC.

10 INPUT A$
20 IF A$="I" THEN B = B+1
21 IF A$="D" THEN B = B-1
22 IF A$="S" THEN B = B*B
23 IF A$="O" THEN PRINT B
24 IF A$="H" THEN END
31 IF B = 256 THEN B = 0
32 IF B = -1 THEN B = 0
33 GOTO 10

Common Lisp

Ensures full compliance, but throws an error when an invalid command is given.

;;; The deadfish macro expects a string as its argument.
(defparameter *acc* 0)
(defvar deadfish-dictionary '((#\i '1+)(#\d '1-)(#\s 'square)(#\o 'print)))
(defun square (x) (* x x))
(defun deadfish-limit (x) (if (or (< x 0) (eql x 256)) 0 x))
(defmacro deadfish (input)
  (setf *acc* 0)
  `(progn ,@(mapcar (lambda (ch) `(setf *acc* (deadfish-limit (funcall ,(cadr (assoc ch deadfish-dictionary)) *acc*))))
		            (coerce input 'list))
	  nil))

This version prompts the user for an input and responds to invalid characters with a newline.

(let ((accumulator 0))
  (declare (type integer accumulator))
  (loop with input of-type (or null string) = NIL do
    (format T "~&>> ")
    (setf input (read-line))
    (clear-input)
    (when input
      (loop for token of-type character across input do
        (when (or (= accumulator -1) (= accumulator 256))
          (setf accumulator 0))
        (case token
          (#\i (incf accumulator))
          (#\d (decf accumulator))
          (#\o (write accumulator))
          (#\s (setf accumulator (* accumulator accumulator)))
          ((#\Newline #\Space #\Tab) NIL)
          (otherwise (terpri)))))))

CraftyFunge

Video

Code

Cthulhu

0A *]A
1A i
2A i[6A
3A e2AdE2A[6A
4A e2AE2BE4Be8AE3B[0B[6A
5A e2Ao[0A
6A e2Aiiiiiiii]A
7A E2A[0A
8A [0A
264A E2A[0A
265A [0A
0B e4B]C
0C e3BE2A
1C e4BdE4Be2BE5B[1B[0B
1B e5B]D
0D i
1D e5BdE5Be3BiE3B[1B

Note that since there is no character input in Cthulhu, input is supplied as numbers - 1 is end, 2 is i, 3 is d, 4 is s and 5 is o.

dc

# Implements XKCD variation of Deadfish.
[p]1:z[d*]2:z[1+]3:z[1-]4:z[0sB]dsAx[lB0>AlB256=A0d?lBz;zxsBclCx]dsCx

To use, enter each command in lower case on a line by itself.

This program uses the fact that in dc, each of "x", "k", "c", and "d" each do a different thing to a stack that has been pre-seeded with "0 0". The stack depth is then used to index an array of macros.

The "idso" version can't be done for that reason. "i" and "o" both consume a single positive integer off the top of the stack and error otherwise.

Deadfish

A brief study of the Deadfish language should convince you that it is not possible to implement a Deadfish interpreter in it.

However, on August 4 2012, Chris Pressey took it upon himself to visit the Deadfish Cafe in Winnipeg, Manitoba and, while having coffee there, to implement Deadfish in Turing, in order to come as close as possible to "implementing Deadfish in Deadfish".

Deadfish "self-interpreter"

This is very close to a Deadfish self-interpreter.

a:i:d:s:oj

Deadfish++

Please enter 1 character at a time. Supports both idso and xkcd. h to halt.

[u~a;f(a=i):i;f(a=x):i;f(a=d):d;f(a=s):s;f(a=k):s;f(a=o):o;f(a=c):o;f(a=h):h;]

Difficult

thing.keyword.while true[
	thing.keyword.if (n eq 256)or(n ls 0)[n=0?]
	n=thing.console.input(">> ")?
	thing.keyword.switch n[
		thing.keyword.wheneq "d"[
			n--?
		]
		thing.keyword.wheneq "i"[
			n++?
		]
		thing.keyword.wheneq "o"[
			thing.console.print("*(n)")?
		]
		thing.keyword.wheneq "s"[
			n=n^2?
		]
	]
]

DL

Interprets a command per line.

DL Start
Var Integer @x
Var String @cmd
Var Bool @bool
Var Integer @pos
ParStr(@cmd)
StrPos(@cmd,i,@pos)
Cmp(@pos,0,@bool)
IfNot(@bool)
	Add(@x,1,@x)
###
StrPos(@cmd,d,@pos)
Cmp(@pos,0,@bool)
IfNot(@bool)
	Sub(@x,1,@x)
###
StrPos(@cmd,s,@pos)
Cmp(@pos,0,@bool)
IfNot(@bool)
	Mul(@x,@x,@x)
###
StrPos(@cmd,o,@pos)
Cmp(@pos,0,@bool)
IfNot(@bool)
	say @x
	NL
###
Cmp(@x,-1,@bool)
If(@bool)
@x = 0
###
Cmp(@x,256,@bool)
If(@bool)
@x = 0
###
Goto(6)
DL End

Drift

filo cell.0
fifo uin
loop {
  if ?uin = 0 {
    print char '\n
    print char '>
    uin.sin
  }
  if ^cell = 256 | ^cell = (0-1) {
    ~cell
    cell.0
  }
  filo curr.(~uin)
  if ^curr = 'i {
    cell.(~cell+1)
  }else if ^curr = 'd {
    cell.(~cell-1)
  }else if ^curr = 's {
    cell.(^cell*~cell)
  }else if ^curr = 'o {
    print int ^cell
  } else {
    break
  }
  del curr
}

Easyfuck

This program takes in the code character by character and executes it after encountering a "carriage return" character:

i(#increment bi-cell
    +`(<+>)
    #check if number is 0b00000001 00000000 (256)
    -`(<--`(0-->0-<)++>)+
    #check if number is 0b11111111 11111111 (-1)
    <$>>!<$>&>0--------<[}`(>+<)]>-`(<<0<0>>>)0<0<<
)
d(#decrement bi-cell
    -`(<->)
    #check if number is 0b00000001 00000000 (256)
    -`(<--`(0-->0-<)++>)+
    #check if number is 0b11111111 11111111 (-1)
    <$>>!<$>&>--------<[}`(>+<)]>-`(0<0<0<0>>>)<<<
)
l(#left-rotate bi-cell
    <{>{`(<+>)
)
a(#add bi-cell to one to the left
    $0<<=`(<+>)>$0<<=>
)
o(#print int at bi-cell, then a space
    OS2.S
)
r(#copy bi-cell to the right
    <$>>!<$>>!
)
s(#square bi-cell
    r$<<M>$>Mlllllllla
    #check if number is 0b00000001 00000000 (256)
    -`(<--`(0-->0-<)++>)+
)
<>0>0>0>0>0>1---$0      #alloc memory and set storage to 13
>,.^[^>,.^]^---.        #take input until 13 (enter on windows), then output new line
[#main loop
    J>>>>>>>>>>S0+S         #go past memory and set storage to 1
    S[S>`X-``(S0S)+S]S$0J!  #go through code until nonzero encountered, take to storage and turn into zero
    >^-`(>>>>>iJ$>)+^       #compare against i and if equal, increment
    >^-`(>>>>dJ$>>)+^       #compare against d and if equal, decrement
    >^-`(>>>sJ$>>>)+^       #compare against s and if equal, square
    >^-`(>>oJ$>>>>)+^       #compare against o and if equal, output
]
#structure: 0[stdin]1-4[chars i d s o]5-10[3 memory bi-cells]11+[deadfish program]
@ idso

Here is a minified version:

i(+`(<+>)-`(<--`(0-->0-<)++>)+<$>>!<$>&>
0--------<[}`(>+<)]>-`(<<0<0>>>)0<0<<)d(
-`(<->)-`(<--`(0-->0-<)++>)+<$>>!<$>&>--
------<[}`(>+<)]>-`(0<0<0<0>>>)<<<)l(<{>
{`(<+>))a($0<<=`(<+>)>$0<<=>)o(OS2.S)r(<
$>>!<$>>!)s(r$<<M>$>Mlllllllla-`(<--`(0-
->0-<)++>)+)<>0>0>0>0>0>1---$0>,.^[^>,.^
]^---.[J>>>>>>>>>>S0+SS[S>`X-``(S0S)+S]S
$0J!>^-`(>>>>>iJ$>)+^>^-`(>>>>dJ$>>)+^>^
-`(>>>sJ$>>>)+^>^-`(>>oJ$>>>>)+^]@ idso

eWagon2

Neat:

Enter your program as one line
" >>"^^^!!!? "h" '0'
{~
"i"^%=^ [`^'1'^+]
"d"^%=^ [`^'1'^-]
"s"^%=^ [`%^*]
"o"^%=^ [`%$]
"h"^%=^ [.]
` '256'^%=^ [,'0']
'-1'^%=^ [,'0']
~ , '1'^ }

Compact:

" >>"^^^!!!?"h"'0'{~"i"^%=^[`^'1'^+]"d"^%=^[`^'1'^-]"s"^%=^[`%^*]"o"^%=^[`%$]"h"^%=^[.]`'256'^%=^[,'0']'-1'^%=^[,'0']~,'1'^}

Falcon

no=0
loop
  if no==-1 or no==256
    no=0
  end
  >> ">> "
  the_cmd = input()
  switch the_cmd
    case "d"
      no=no-1
    case "i"
      no=no+1
    case "o"
      > no
    case "s"
      no=no*no
  end
end

FALSE

[0~]["
>> "^
\$\$256=\1_=&[%0]?\
$'i=[\1+\]?
$'d=[\1-\]?
$'s=[\$*\]?
 'o=[$,]?
]#

Felix

include "std/textio";
open Text_file;
var a : int;
while {true}
{
  write(stdout, ">> ");
  a = if a == 256 or a < 0 then 0 else a;
  match readln stdin with
  | "i\n" => { ++a; }
  | "d\n" => { --a; }
  | "s\n" => { a*=a; }
  | "o\n" => { print a; endl; }
  endmatch;
};

><>

This is the actual idso version, with the correct x==-1||x==256 behaviour.

v                       Load zero in the register
\0&
v                   <

\" >>"ooo
v     <                 The input loop, stopping on 13 (CR, enter press)
\i:o
\:d=?!^~aor
                        We process in reverse order, that's why the 'r'
v                  <
\&::&01-=$f1+:*=+?v
v             &0~&<     The x==0||x==256 -> x=0 thing
\l0=?v
     >ao            ^   If done with input, output newline and return to input loop
\:"i"=?v
       >~&1+&      ^    Increment
\:"d"=?v
       >~&1-&      ^    Decrement
\:"s"=?v
       >~&:*&      ^    Square
\:"o"=?v
       >~&:n&      ^    Output
\:"h"=?v
       >~;        (^)   HALT
>~                 ^    If none of those, just remove it from input and run next

Fishing

v+CC[vCCCCCCCC?!CCCCCCCCCC?!CCCCCCCCCCCCCCCCC?!CCCCCC?!CCCCCC?!CCCCCC?!CCCCCCD_
  n{D E`-1`n} = {E`256`n} =  { E`>>`PEI{E`i`}= {E`d`}= {E`s`}= {E`o`}=  {{N}} D
    D         _DDDDDDDDDDD]                  D       D       D       D        D      
    D         <                              D       D       D       D        D
    D         D                              <       <       <       <        D
    D        EC                             }C      }C      }C      }C        D
    D        `C                             iC      dC      SC      NC        D
    D        0C                             {C      {C      {C      {C        D
    D        `C                              D       D       D       D        D
    D        nC                              D       D       D       D        D
    D        {C                              D       D       D       D        D      
    |DDDDDDDDD]DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD]DDDDDDD]DDDDDDD]DDDDDDD]DDDDDDDD]

FlinnScrip

while(0=nil){
input(1);//this does not output ">>" because flinnscript does not support prepends and appends in inputs.
if(1="i"||1="x"){add(2,1);};
if(1="d"){add(2,-1);};
if(1="s"||1="k"){multiply(2,var(2));};
if(1="o"||1="c"){print(2);};
if(2=256||2=-1){set(2,0);};
};

Forobj

">> "d'>i[,n>c[$i'1+>i][[$i'1->i][[$i,*>i][[$i d"\n"d][">> "d]$c"o"=?]$c"s"=?]$c"d"=?]$c"i"=?['>i][]$i'256=$i'=|?\],._

Forth

\ Type 'h' to halt
: MAIN
  0 BEGIN
    DUP 256 = OVER -1 = OR IF DROP 0 THEN
    KEY CASE
      'i' OF 1+ ENDOF
      'd' OF 1- ENDOF
      's' OF DUP * ENDOF
      'o' OF DUP . ENDOF
      'h' OF DROP EXIT ENDOF
    ENDCASE
  AGAIN
;
MAIN BYE

FORTRAN 77

c Deadfish interpreter in FORTRAN 77
      PROGRAM DEADFISH
      CHARACTER*1 inp
      INTEGER state
      state = 0
      DO
          WRITE(*,'(2A)', ADVANCE='no')">>"
          READ(*,*)inp
          IF (state .EQ. 256 .OR. state .LT. 0)
     +       state = 0
          IF (inp .EQ. 'i') THEN
               state = state + 1
          ELSE IF (inp .EQ. 'd') THEN
               state = state - 1
          ELSE IF (inp .eq. 's') THEN
               state = state**2
          ELSE IF (inp .EQ. 'o') THEN
               WRITE(*,"(I3)")state
          END IF
      END DO
      END

Free Hero Mesh

; Of course, it is not possible to win this game.
(Control Player Input
  ('I %x 1 + =%x)
  ('D %x 1 - =%x)
  ('S %x %x * =%x)
  ('O %x PopUp)
  (BEGIN_TURN %x -1 eq %x 256 eq lor if 0 =%x then)
)

Fueue

This hits some bugs in all the known Fueue interpreters. Join it into a single line to run it in the C one.

[0]):[
    )$$17--1[)$5~[)~[0]])$[[)[~~~~()+1])])]<<<[[
        )~<[)$%+-~)~~~100[)[
            )~+[~:~~~)(]-1)
        ]!]~][
        )~<[)$%+-~)~~~105[)[
            )~+[~:~~~)(]%0)
        ]!]~][
        )~<[)$%+-~)~~~111[)[
            ):[)$$7--1[
                )$3~[)$~!~~%~)]$2<[):]~:
            ]~)~~[
                )~~~[~)~$7~~:~~([$3~)+[~~~<~()+48]~~~-)~10*)]/]--10):
            ]]
            ~[10 ~:)~]~: 
        ]!]~][
        )~<[)$%+-~)~~~115[)[
            )~*~~:[~:~~~)(])
        ]!]~][)[
            10 ~:)~
        ]!]:]:]:]:
    ]]]
    62 62 32 )~<~[
        )$%+%~)~~~0[[0]!]~
    ]~:[)~([
        )$%+-~)~~~256[[0]!]~
    ]:]~
]

Office VBA

Sub Deadfish()
    Dim Code As String
    Dim i As Integer
    Dim v As String
    Dim Accumulator As Integer
    Code = InputBox("Deadfish code?", "Deadfish")
    Accumulator = 0
    
    For i = 1 To Len(Code)
        v = Mid(Code, i, 1)
        Select Case v
            Case "i"
                Accumulator = Accumulator + 1
            Case "d"
                Accumulator = Accumulator - 1
            Case "s"
                Accumulator = Accumulator * Accumulator
            Case "o"
                MsgBox (Accumulator)
        End Select
        
        If Accumulator = 256 Or Accumulator = -1 Then
            Accumulator = 0
        End If
    Next
End Sub

gar

>
<
+
^
{
??
>>>>>>>>>>
:
*
|
+
]
~
)
[
<<<<<
+
]]
~
))
[[
<<<<<<
+
]]]
~
)))
[[[
<<<<
+
]]]]
~
))))
[[[[
~~
)))))
(
~~
^^
<
+
^
~~
)))))
((
~~
^^
>
+
^
~~
)))))
(((
~~
^^
!
}
((((
~~
^^
:
*
^
~
(((((
~~
>
^^
+
]]]]]
>
<
+
^
[[[[[
~~
>>>>
:
:
:
*
*
*
|
^^
+
]]]]]]
>
<
+
^
[[[[[[
~~
}

Glass

{M[moO!iI!aA!sS!n<0>=c<1>=/cc<1>ie.?as.?=ec*=/e">> "oo.?fil.?=gf
*sl.?=hg*=l<-1>n*ae.?<256>n*ae.?aa.?=/ln<0>=l<0>=\/hjf*g*h*as.?s
i.?=kj*"i"se.?=/knn*<1>aa.?=k<0>=\kj*"d"se.?=/knn*<1>as.?=k<0>=\
kj*"s"se.?=/knn*n*am.?=k<0>=\kj*"o"se.?=/kn*o(on).?<10>s(ns).?oo
.?k<0>=\hh*<1>as.?=\e<0>=\\<10>s(ns).?oo.?]}

Glulx

	<!include ":glulx"
	<!include ":glk"
	!stack 256

:Prompt	!string ">> "

	!main 3

	; Check if Glk supported; quit if not
	gestalt gs.IOSystem,2,$
	jz $,0

	; Open window
	!pushr 0,0,0,glk.wintype_TextBuffer,0
	glk glk_window_open,5,$2
	jz $2,0
	push $2
	glk glk_set_window,1,0
	setiosys 2,0

	; Main loop

	; Check if number is -1 or 256
0h	jne $0,-1,1f
2h	copy 0,$0
1h	jeq $0,256,2b

	; Prompt and get input
	streamstr Prompt
	!pushr $2,Buf,1,0
	glk glk_request_line_event,4,0
1h	push Event
	glk glk_select,1,0
	jne @Etype,glk.evtype_LineInput,1b
	jz @Eval1,0b

	; Execute operation
	copyb @Buf,$1
	jeq $1,'i',I
	jeq $1,'d',D
	jeq $1,'s',S
	jeq $1,'o',O
	jump 0b

	; Increment
:I	add $0,1,$0
	jump 0b

	; Decrement
:D	sub $0,1,$0
	jump 0b

	; Square
:S	mul $0,$0,$0
	jump 0b

	; Output
:O	streamnum $0
	streamchar 10
	jump 0b

	!bss
:Event	!allot 16
:Etype	!is Event
:Ewin	!is Event+4
:Eval1	!is Event+8
:Eval2	!is Event+12
:Buf	!allot 8

Go

package main

import (
	"os"
	"fmt"
	"bufio"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	var x int
	for {
		fmt.Print(">> ")
		input, err := reader.ReadString('\n')
		if err != nil {
			return
		}
		for _, c := range input {
			switch c {
			case 's':
				x = x * x
			case 'i':
				x++
			case 'd':
				x--
			case 'o':
				fmt.Println(x)
			}
			if x < 0 || x == 256 {
				x = 0
			}
		}
	}
}

GotoScript

# Variables
1 x := 0
2 new_x := ""

# Reset accumulator on under/overflow
3 GOTO 1 IF x < 0 | x = 256

# Get input
4 GOTO INPUT '>> ' CATCH 5

# Invalid input
5 PRINT 'Invalid command.'

# Increment
'i' new_x := x + 1

# Decrement
'd' new_x := x - 1

# Square
's' new_x := x * x

# Output
'o' PRINT x
6 GOTO 4

# Loop back
7 GOTO 2 WHEN new_x != ""

Gray Snail

Instead of squaring numbers above 31, it just returns 0. Instead of increasing above 999, it goes to 0. However, you can reach 999, as 999 is regarded as separate from -1 (it checks whether 999 was obtained by increment or decrement).

POP a number a000
POP a "show number" a
POP a carry a0
POP a newline a"
"
POP a "all input" a">>"
"input more commands"
OUTPUT "[all input]"
INPUT commands
"analyse commands"
OUTPUT "[all input]"
POP instruction commands [commands]
GOTO "input more commands" [instruction] ""
POP a temp a[number]
POP hundreds temp [temp]
POP tens temp [temp]
POP ones temp [temp]
GOTO "o command" [instruction] o
GOTO "s command" [instruction] s
GOTO "di command" [instruction] d
GOTO "di command" [instruction] i
POP a "all input" a"[all input][instruction][newline]>>"
GOTO "analyse commands"
"o command"
GOTO "skip hundreds" [hundreds] 0
POP a "all input" a"[all input]o[newline][number][newline]>>"
GOTO "analyse commands"
"skip hundreds"
GOTO "skip tens" [tens] 0
POP a "all input" a"[all input]o[newline][tens][ones][newline]>>"
GOTO "analyse commands"
"skip tens"
POP a "all input" a"[all input]o[newline][ones][newline]>>"
GOTO "analyse commands"
"s command"
POP a "all input" a"[all input]s[newline]>>"
GOTO "square 0[ones]" [number] 00[ones]
GOTO "square 1[ones]" [number] 01[ones]
GOTO "square 2[ones]" [number] 02[ones]
GOTO "square 30" [number] 030
GOTO "square 31" [number] 031
GOTO "to 000"
"di command"
POP a "all input" a"[all input][instruction][newline]>>"
POP a digit aones
GOTO "[instruction] [ones]"
"finished with one operation"
GOTO "completely finished" [carry] 0
GOTO "completely finished" [digit] hundreds
"#This is in case we have just changed tens, so we have to change hundreds."
GOTO "digit is tens" [digit] tens
POP a digit atens
GOTO "[instruction] [tens]"
"digit is tens"
POP a digit ahundreds
GOTO "[instruction] [hundreds]"
"completely finished"
GOTO "to 000" [hundreds][tens][ones] 256
GOTO "to 000" [instruction][hundreds][tens][ones] d999
POP a number a[hundreds][tens][ones]
"number is changed"
POP a carry a0
GOTO "analyse commands"
"to 000"
POP a number a000
GOTO "number is changed"
"d 0"
POP a [digit] a9
POP a carry a1
GOTO "finished with one operation"
"d 1"
POP a [digit] a0
POP a carry a0
GOTO "finished with one operation"
"d 2"
POP a [digit] a1
POP a carry a0
GOTO "finished with one operation"
"d 3"
POP a [digit] a2
POP a carry a0
GOTO "finished with one operation"
"d 4"
POP a [digit] a3
POP a carry a0
GOTO "finished with one operation"
"d 5"
POP a [digit] a4
POP a carry a0
GOTO "finished with one operation"
"d 6"
POP a [digit] a5
POP a carry a0
GOTO "finished with one operation"
"d 7"
POP a [digit] a6
POP a carry a0
GOTO "finished with one operation"
"d 8"
POP a [digit] a7
POP a carry a0
GOTO "finished with one operation"
"d 9"
POP a [digit] a8
POP a carry a0
GOTO "finished with one operation"
"i 0"
POP a [digit] a1
POP a carry a0
GOTO "finished with one operation"
"i 1"
POP a [digit] a2
POP a carry a0
GOTO "finished with one operation"
"i 2"
POP a [digit] a3
POP a carry a0
GOTO "finished with one operation"
"i 3"
POP a [digit] a4
POP a carry a0
GOTO "finished with one operation"
"i 4"
POP a [digit] a5
POP a carry a0
GOTO "finished with one operation"
"i 5"
POP a [digit] a6
POP a carry a0
GOTO "finished with one operation"
"i 6"
POP a [digit] a7
POP a carry a0
GOTO "finished with one operation"
"i 7"
POP a [digit] a8
POP a carry a0
GOTO "finished with one operation"
"i 8"
POP a [digit] a9
POP a carry a0
GOTO "finished with one operation"
"i 9"
POP a [digit] a0
POP a carry a1
GOTO "finished with one operation"
"square 00"
POP a number a000
GOTO "analyse commands"
"square 01"
POP a number a001
GOTO "analyse commands"
"square 02"
POP a number a004
GOTO "analyse commands"
"square 03"
POP a number a009
GOTO "analyse commands"
"square 04"
POP a number a016
GOTO "analyse commands"
"square 05"
POP a number a025
GOTO "analyse commands"
"square 06"
POP a number a036
GOTO "analyse commands"
"square 07"
POP a number a049
GOTO "analyse commands"
"square 08"
POP a number a064
GOTO "analyse commands"
"square 09"
POP a number a081
GOTO "analyse commands"
"square 10"
POP a number a100
GOTO "analyse commands"
"square 11"
POP a number a121
GOTO "analyse commands"
"square 12"
POP a number a144
GOTO "analyse commands"
"square 13"
POP a number a169
GOTO "analyse commands"
"square 14"
POP a number a196
GOTO "analyse commands"
"square 15"
POP a number a225
GOTO "analyse commands"
"square 16"
GOTO "to 000"
"square 17"
POP a number a289
GOTO "analyse commands"
"square 18"
POP a number a324
GOTO "analyse commands"
"square 19"
POP a number a361
GOTO "analyse commands"
"square 20"
POP a number a400
GOTO "analyse commands"
"square 21"
POP a number a441
GOTO "analyse commands"
"square 22"
POP a number a484
GOTO "analyse commands"
"square 23"
POP a number a529
GOTO "analyse commands"
"square 24"
POP a number a576
GOTO "analyse commands"
"square 25"
POP a number a625
GOTO "analyse commands"
"square 26"
POP a number a676
GOTO "analyse commands"
"square 27"
POP a number a729
GOTO "analyse commands"
"square 28"
POP a number a784
GOTO "analyse commands"
"square 29"
POP a number a841
GOTO "analyse commands"
"square 30"
POP a number a900
GOTO "analyse commands"
"square 31"
POP a number a961
GOTO "analyse commands"
end

Haskell

import Data.Int (Int32)
main = loop (0, "")
loop :: (Int32, String) -> IO ()
loop (x', s) = do
    putStr $ s ++ ">> "
    c <- getChar
    let x = case x' of -1 -> 0; 256 -> 0; _ -> x'
    loop $ case c of
        'i' -> (x+1, "")
        'd' -> (x-1, "")
        'o' -> (x, show x ++ "\n")
        's' -> (x*x, "")
        _   -> (x, "\n")

Hot Soup Processor

; Deadfish in Hot Soup Processor (ver3.51), version 1 -- dnm 2021-06-04

accumulator = 0
command = ""
exitbtn="EXIT"

onexit goto *exit
onkey goto *interpret

objsize 600,24
mes "Deadfish Interpreter"
mes "Enter command:"
input command
button exitbtn,*exit

*loopreset
	stop

*interpret
	if accumulator = 256 | accumulator < 0 : accumulator = 0
	if iparam=73 : accumulator = accumulator + 1
	if iparam=68 : accumulator = accumulator - 1
	if iparam=83 : accumulator = accumulator * accumulator
	if iparam=79 : mes accumulator
	goto *loopreset

*exit
	end

hsifdaeD

,idso

This terminates when you enter something that is not i, d, s or o.

HTML / Javascript

This interpreter is archived online (from the Wayback Machine; retrieved on 23 September 2012).

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><TITLE>Deadfish in HTML</TITLE>
<SCRIPT type="text/javascript">
var i=0;
function deadfish()
{
  var c=document.getElementById("cmd").value;
  document.getElementById("cmd").value="";
  document.getElementById('op').innerHTML+=
    "&gt;&gt;&nbsp;&#"+c.charCodeAt(0)+";<BR/>";
  if(c=='i') i++;
  else if(c=='d') i--;
  else if(c=='s') i*=i;
  else if(c=='o') document.getElementById('op').innerHTML+=i+"<BR/>";
  else document.getElementById('op').innerHTML+="<BR/>";
  if(i==256||i==-1) i=0;
  return false;
}
</SCRIPT>
</HEAD><BODY>
<H1>Deadfish in HTML</H1>
<DIV id="op"></DIV>
<FORM onsubmit="return deadfish()">
&gt;&gt;&nbsp;<INPUT type="text" maxlength="1" size="1" id="cmd" /><BR/>
<INPUT type="submit" value="Submit" />
</FORM>
</BODY></HTML>

Another one:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
     <head><title>Deadfish in HTML</title></head>

     <body>
        <h1><a href="http://esolangs.org/wiki/Deadfish"<a>Deadfish in HTML</a></h1>
        <span id="out">>> </span>
        <input id="cmd" type="text" onkeypress="if(event.charCode==13) deadfish();"/>

    <script type="text/javascript">
        var acc = 0;
        function deadfish(){
            var cmd=document.getElementById('cmd').value;

            if(cmd=='i') acc++;
            if(cmd=='d') acc--;
            if(cmd=='s') acc *= acc;
            if(acc==256 || acc<0) acc=0;
            if(cmd=='o') cmd+='<br/>'+acc;
  
            document.getElementById('out').innerHTML+=cmd+'<br/>>> ';
            document.getElementById('cmd').value='';
        }
    </script>
    </body>
</html>

A shorter(and programmer friendly)one(I made it print every value after entering every command just for easier debugging).

<span id="out"></span>
<input id="cmd" type="text" onkeypress="d();"/>
<script>var a=0;
function d(){
    var c=document.getElementById('cmd').value;
    if(c=='i')a++;
    if(c=='d')a--;
    if(c=='s')a*=a;
    c+=' key pressed, the accumulator becomes '+a;
    if(a==256||a<0)a=0;
    document.getElementById('out').innerHTML+=c+'. <br/>';
    document.getElementById('cmd').value='';
}</script>

Html/Javascript Simplified

<!DOCTYPE html>
<html>
<head><title>Deadfish Interpreter</title></head>
<body>
<script>
var acc = 0;
do {
var a = prompt(">> ");
    if(a=='i') acc++;
    
    if(a=='d') acc--;
    
    if(a=='s') acc *= acc;
    
    if(a=='o') console.log(acc);  
    if(acc<0||acc==256) acc = 0;
    
} while(a!='h');
</script>
</body> 
</html>

ICI

Quick and dirty, has an obvious bug I need to fix...

// Deadfish in ICI (4.1.0), version 1 -- dnm 2022-02-17

static accumulator = 0;

// BUG: each trip through the loop, e.g., via (each) break, prints anew (">> ")
// i.e., n command(s) submitted per line will print n prompt(s)
// Hitting ENTER at a prompt (i.e., no [other] input) will print just one ">> "

while (1) {
    if (accumulator == 256 || accumulator < 0) { accumulator = 0; }
    printf(">> ");  
    command := getchar();
    switch (command) {
        case "i": ++accumulator; break;
        case "d": --accumulator; break;
        case "s": accumulator = accumulator * accumulator; break;
        case "o": printf("%i\n", accumulator); break;
    }
}

Io

This implementation uses Io REPL itself (so you have the powers of Io at your disposal). Should be either entered into REPL directly or with -i option.

CLI setPrompt(">> ")
CLI writeCommandResult = false

x := 0
check := method(if(x == -1 or x == 256, x = 0))
i := method(check x = x + 1)
d := method(check x = x - 1)
s := method(check x = x * x)
o := method(x println)

itflabtijtslwi

Another implementation using a unary representation. On the machine I tested it with, it did not manage to print numbers much larger than 1000 in the time I had patience to wait.

/  / //
 //
    /*/()()()()()()()()()()()()()()()()/
    /./<\\\\>\\\\\\/
    /P1/
        >> 
        GGC.0GG
        ./N.a****************N.b./N.aN.b./
        ./C.a.\.\iC.b./
            .\./N.a.\./.\.\.\./N.\0.\.\.\./.\./
            .\./N.b.\./().\.\.\./.\./
        ./
        ./C.a.\.\dC.b./
            .\./N.a.\./.\.\.\./N.\0.\.\.\./.\./
            .\./()N.b.\./.\.\.\./.\./
            .\./N.b.\./.\.\.\./.\./
        ./
        ./C.a.\.\oC.b./
            .\./N.a.\./.\.\.\./N.\1.\.\.\./.\./
            .\./N.b.\./.\.\.\./
                .\.\.\./N.\d().\.\.\./N.\d1N.\d.\.\.\./
                .\.\.\./1N.\d.\.\.\./N.\d1.\.\.\./
                .\.\.\./N.\d1.\1.\1.\1.\1.\1.\1.\1.\1.\1.\.\.\./
                    1.\.\.\.\N.\d
                .\.\.\./
                .\.\.\./N.\cN.\d.\.\.\./N.\c.\.\.\./
                .\.\.\./N.\c.\.\.\./N.\d.\.\.\./
                .\.\.\./N.\e.\.\.\./N.\d.\.\.\./
                .\.\.\./1.\1.\.\.\./2.\.\.\./.\.\.\./2.\1.\.\.\./3.\.\.\./
                .\.\.\./2.\2.\.\.\./4.\.\.\./.\.\.\./2.\3.\.\.\./5.\.\.\./
                .\.\.\./4.\2.\.\.\./6.\.\.\./.\.\.\./4.\3.\.\.\./7.\.\.\./
                .\.\.\./4.\4.\.\.\./8.\.\.\./.\.\.\./4.\5.\.\.\./9.\.\.\./
                .\.\.\./N.\dN.\d.\.\.\./0N.\d.\.\.\./
                .\.\.\./N.\d.\.\.\./.\.\.\./
                N.\cN.\dN.\1N.\e

                .\.\.\./N.\0.\.\.\./N.\1.\.\.\./
               .\./
        ./
        ./C.a.\.\sC.b./
            .\./N.a.\./.\.\.\./N.\1.\.\.\./.\./
            .\./N.b.\./.\.\.\./
                .\.\.\./N.\c().\.\.\./N.\1N.\c.\.\.\./
                .\.\.\./N.\c.\.\.\./.\.\.\./
                .\.\.\./N.\0.\.\.\./N.\cN.\1.\.\.\./
               .\./
        ./
        ./C.a./.\./W.b.\././
        ./C.b./.\./
            .\./N.a.\./.\.\.\./N.\0.\.\.\./.\./
            .\./N.b.\./.\.\.\./.\./

        ./
        C.a.\C.0C.b
        ./<.\>./<.\.\.\.\>.\.\.\.\.\.\./
        ./P.1./P.2./
        ./P.0./P.1./
        ./<.\>././
        ./P.\2./P.1./
        N.aN.0N.b
        P.0
    /
    /P0/P1/
    /<\>//
    /P2/P1/
    /N0//
    P0

ΙΧΘΥΣ

Non-Latin Deadfish superset that can redefine itself to `idso` Deadfish

  ΙiιΘΙdχΘΙsθΘΙoυΘΧ

J

This is a serious language that gets used in the finance industry, believe it or not.

getchar =: 'libc.so.6 getchar >c'&cd
bounds  =: (]*>&0*~:&256)@]
prompt  =: ][1!:2&4&'>> '@1:
cmds    =: 'idso', LF, 255{a.
cmdfns  =: (>:@])`(<:@])`(*:@])`(][echo@])`prompt`(exit@0:)
loop    =: getchar&''@1:$:bounds@(cmdfns`]@.(cmds&i.@[))
LF loop 0

Here is a one line "incantation" by User:BoundedBeans. In J, one line is one expression, so everything here is in one expression as well. You can get past that limitation by using the LF constant inside of an explicit verb (or using control words inside of one), but I explicitly avoided this (although I did use explicit definitions as verbs). Originally this was going to be a script, but I also thought I wanted to remove all whitespace, and specifically one verb : doesn't work if you remove the whitespace around it (and a ton of other methods failed as well). What I settled on was dynamically loading the script from a string which all question marks are replaced with spaces, but none occur literally. To run this, either you can type it into the J shell, or it sort of works on tio.run (example here). Either way, you'll have to run Deadfish 0 after you run the incantation (it merely loads the Deadfish function; immediately calling it in the same line doesn't work for some reason).

It only accepts one command per line, and will crash if you try entering more, none, or any invalid command.

Anyway, here is the program:

(0!:101)((u:11$32)((11,17,47,62,95,131,155,183,208,245,301)})'Deadfish=:3?:''((3?:''''(((256=0{y)+.(_1=0{y)){((3?:''''''''y'''''''')`(3?:''''''''0(0})y'''''''')))(`:6)y'''')&:((3?:''''(((''''''''idsoh''''''''i.((1!:1)1)){((3?:''''''''(1+0{y)0}y'''''''')`(3?:''''''''y(0})~(_1+0{y)'''''''')`(3?:''''''''y(0})~*:0{y'''''''')`(3?:''''''''>(1{((":0{y)(1!:2)2);y)'''''''')`(3?:''''''''y(1})~(_1+1{y)'''''''')))(`:6))(y(1})~(1+1{y))'''')&:((3?:''''>1{((''''''''>>''''''''(1!:2)2);y)'''')))^:_)0,0''')

Java

// Deadfish in Java -- JTS
// Compiled with JDK 6 and tested with JRE 6 on Ubuntu 9.0.4
// And yes, I do hate Java like most people, and I hate how I have to do it for comp sci!
import java.util.Scanner;
public class Deadfish
{
	public static void main(String args[])
	{
		Scanner comm = new Scanner(System.in);
		boolean isSquared = false;
		int x = 0;
		String usrinput;
		while(true)
		{
			System.out.print(">> ");
			usrinput = comm.next();
			if(usrinput.contentEquals("i"))
			{
				if(x >= 256 && isSquared == false)
					x = 0;
				x++;
			}
			else if(usrinput.contentEquals("d"))
			{
				if(x <= -1 && isSquared == false)
					x = 0;
				x--;
			}
			else if(usrinput.contentEquals("o"))
				System.out.println(x);
			else if(usrinput.contentEquals("s"))
			{
				if(x >= 256)
					isSquared = true;
				x = x * x;
			}
			else
				System.out.println();
		}
	}
}
//FIN

Another one, compiling on JDK1.1

import java.io.*;
public class Deadfish {
    public static void main(String[] args) throws IOException { new Deadfish(); }

    public Deadfish() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int acc = 0;
        for(char ch=0; ch!='h'; ch = in.readLine().charAt(0)){
            if(ch=='i') acc++;
            if(ch=='d') acc--;
            if(ch=='s') acc*=acc;
            if(acc==256 | acc<0) acc=0;
            if(ch=='o') System.out.println(acc);
            System.out.print(">> ");
        }
    }
}

Yet another one, now in JDK 11

import java.util.Scanner;
public class Deadfish{
  public static void main(String[] args){
    int x = 0;
    String code;
    while(true){
      System.out.print("\n>> ");
      code = input.nextLine();
      for(int i = 0; i < code.length; ++i){
        if(x == -1 || x == 256) x = 0;
        switch(code.charAt(i)){
          case 'i': ++x; break;
          case 'd': --x; break;
          case 's': x *= x; break;
          case 'o': System.out.print("\n"+x); break;
          case 'h': return;
        }
      }
    }
  }
}

Might as well add another one to the mix

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int acc = 0;
		Scanner input = new Scanner(System.in);
		String program = input.nextLine();
		
		for (char command : program.toCharArray()) {
			if (acc == -1 || acc == 256) { acc = 0;}
			switch (command) {
				case 'i': acc++; break;
				case 'd': acc--; break;
				case 's': acc *= acc; break;
				case 'o': System.out.print(acc); break;
			}
		}
	}
}

JavaScript

Exports a function, import it with

import { deadfish } from "./path/to/deadfish.js"

and use it with

deadfish(/*code string/*, /*ascii output (boolean)*/)
export function deadfish (code, ascii) {
	let a = 0
	let x = []
	if (typeof(code) === "string") {
		let c = code.split("")
		for (let i = 0; i < code.length; i++) {
			switch (c[i]) {
				case 'i':
					a++
					break
				case 'd':
					a--
					break
				case 's':
					a *= a
					break
				case 'o':
					x.push(a)
					break
				default:
					break
			}
			if (a == 256 || a < 0) {
				a = 0
			}
		}
	}
	if (ascii === true) {
		return String.fromCharCode.apply(null, x)
	} else {
		return x
	}
}

JavaScript (very short)

A very concise JS implementation by User:Nomad. I believe it is fully compliant.

(Had a fun time golfing to achieve this - JS has some pretty crazy quirks)

Save in a file, and call with deadfish code as command line parameter:

Ex:

node interpreter.js iissso
(c => [0,...c.split('')].forEach((v,i,a) => 
    i < 1 ? null : ((a[0] = a[0] === 256 || a[0] === -1 ? 0 : a[0]), 
    a[0] += (v === 'i' ? 1 : v === 'd' ? -1 : v === 's' ? (a[0]**2)-a[0] :
    (0, console.log(v === 'o' ? a[0] : ''))))
))(process.argv.slice(2)[0] || '')

Julia

Using multiple dispatch to implement several versions for user convenience.

# Deadfish implementation in Julia

# Run fully compliant version (infinite input/output loop):
#                   deadfish() or deadfish(0)

# Run version that exits when entering 'h':
#                   deadfish(1)

# Run version that simulates manual input and
# appropriate output, given the input string as a whole:
#                   deadfish("input string")

function deadfish()
#= Run fully compliant version of deadfish if
   no parameters are given =#
    deadfish(0)
end

function deadfish(compliance::Int)
    x=0
    while true
        print(">> ")

        input=readline(STDIN)[1]

        # Make sure x is not greater then 256 ;)
        x == 256 ? x=0 : nothing
        x == -1 ? x=0 : nothing
        input == 'i' ? x=x+1 :
        input == 'd' ? x=x-1 :
        input == 'o' ? println(x) :
        input == 's' ? x=x^2 :
        input == 'h' && compliance ==1 ? break : println()
    end
end

function deadfish(code::AbstractString)
    x=0
    for i = 1:length(code)
        input=code[i]
        println(">> $input")

        # Make sure x is not greater then 256 ;)
        x == 256 ? x=0 : nothing
        x == -1 ? x=0 : nothing
        input == 'i' ? x=x+1 :
        input == 'd' ? x=x-1 :
        input == 'o' ? println(x) :
        input == 's' ? x=x^2 : println()
    end
end

Example output of test strings for "true" deadfish overflow detection:

julia> include("deadfish.jl")
deadfish (generic function with 3 methods)

julia> deadfish("iissso")
>> i
>> i
>> s
>> s
>> s
>> o
0

julia> deadfish("iissiso")
>> i
>> i
>> s
>> s
>> i
>> s
>> o
289

K

{1">>";0{x*2=-1 256?x:y@x}/("xkcdiso"!7#(1+;{x*x};{-1@$x;x};-1+))@0:0;.z.s`}`

Keg

0{'::"ÿ1+=$0<+['_0"] \>\>\
,,,,?:o=[':."]:i=['1+"]:d=['1-"]:s=[':*"

Kipple

(i>r)
(r
  r-105 r>c 0>y c? (c y? 0>c?) (y a+1 1>f y?)
  r-100 r>c 0>y c? (c y? 0>c?) (y a-1 1>f y?)
  r-111 r>c 0>y c? (c y? 0>c?) (y a+0 a>@ (@>p) (p>q) 10>q y?)
  r-115 r>c 0>y c? (c y? 0>c?) (y a+0 a>m+0 m>n 0>s (m-1 n+0 s+n m?) s>a 0>s? y?)

  r>t
  
  a+0 a>b 0>y b+1   b? (b y? 0>b?) (y 0>a y?)
  a+0 a>b 0>y b-256 b? (b y? 0>b?) (y 0>a y?)
)
(q>o)

Kitanai

  • Compact version :
$0[0]#$1[input">> "]?(add(eq($0@)256)
(eq($0@)-1))([0])?(eq($1@)"i")($0[add@1])?
(eq($1@)"d")($0[sub@1])?(eq($1@)"o")
(print($0@))?(eq($1@)"s")($0[mul@@])&1
  • "Clean" version :
$"accumulator"[0]
#
    $"userInput"[input">> "]
    ?(eq ($"accumulator" @) 256)
        ($"accumulator"[0])
    ?(eq ($"accumulator" @) -1)
        ($"accumulator"[0])
    ?(eq ($"userInput" @) "i")
        ($"accumulator"[add @ 1])
    ?(eq ($"userInput" @) "d")
        ($"accumulator"[sub @ 1])
    ?(eq ($"userInput" @) "o")
        (print($"accumulator" @))
    ?(eq ($"userInput" @) "s")
        ($"accumulator"[mul @ @])
&1

Kotlin

fun main(args : Array<String>) {
    var isSquared : Boolean = false
    var input : String?
    var a : Int = 0
    while (true){
        print(">> ")
        input = readLine()
        when(input){
            "i" -> {if (a == 256 && !isSquared) a = 0; a++}
            "d" -> {if (a < 0 && !isSquared) a = 0; a--}
            "o" -> println(a)
            "s" -> {isSquared = (a >= 256); a *= a}
            else -> println()
        }
    }
}

LOLCODE

#!/usr/bin/env lci
BTW, This is a Deadfish interpreter in LOLCODE.

HAI 1.3

HOW IZ I reading YR op
    GIMMEH op, FOUND YR op
IF U SAY SO

I HAS A x ITZ 0

IM IN YR reader...
    I IZ reading YR op MKAY TIL BOTH SAEM op AN ""
    op, WTF?
        OMG "i", x R SUM OF x AN 1, GTFO
        OMG "d", x R DIFF OF x AN 1, GTFO
        OMG "s", x R PRODUKT OF x AN x, GTFO
        OMG "o", VISIBLE x
    OIC

    EITHER OF BOTH SAEM x AN -1 AN BOTH SAEM x AN 256, O RLY?
        YA RLY, x R 0
    OIC
IM OUTTA YR reader

KTHXBYE

Lua

#!/usr/bin/env lua

local acc = 0
io.write(">> ")
while true do
	local c = io.read(1)
	if not c then break end
	    if c == 'i'  then acc = acc + 1
	elseif c == 'd'  then acc = acc - 1
	elseif c == 's'  then acc = acc*acc
	elseif c == 'o'  then io.write(tostring(acc)) io.write('\n')
	elseif c == 'h'  then break
	elseif c == 'r'  then acc = 0
	elseif c == '\n' then io.write(">> ")
	else io.write('\n') end
	if acc == 256 or acc == -1 then acc = 0 end
end

Numbers

20 0 20 100 35 11 24 40 42 17 20 1 21 11 42 44 20 5 25 11 24 40 42 31 20 1 21 10 42 44 20 6 25 11 24 40 42 42 30 42 44 26 12 42 3

Metabox

┌────────────────────────────────────────────────────────────────────────────┐
│┌──────────────────────────────────────────────────────────────────────────┐│
││┌─────────────────────────────────┐                                       ││
│││┌───────────────────────────────┐│                                       ││
││││┌─────────────────────────────┐││                                       ││
│││││┌─────────────┐ set variable │││                                       ││
││││││start program│ "a" to 0     │││                                       ││
│││││└─────────────┘              │││                                       ││
││││└─────────────────────────────┘││                                       ││
││││     set variable "b" to 0     ││                                       ││
│││└───────────────────────────────┘│                                       ││
│││       print ">> " & input       │                                       ││
││└─────────────────────────────────┘                                       ││
││                                                                          ││
││                                                                          ││
││                      loop (length of input) times                        ││
││┌────────────────────────────────────────────────────────────────────────┐││
│││if character (variable                                                  │││
│││  "a") of input = o                                                     │││
│││ ┌──────────────────┐                                                   │││
│││ │print variable "b"│                                                   │││
│││ └──────────────────┘                                                   │││
│││┌──────────────────────────────────────────────────────────────────────┐│││
││││┌────────────────────────────────────────────────────┐                ││││
│││││   if character (variable "a") of input = s         │                ││││
│││││┌───────────────────────────────────────────────┐   │                ││││
││││││set variable "b" to variable "b" * variable "b"│   │                ││││ 
│││││└───────────────────────────────────────────────┘   │                ││││
│││││┌──────────────────────────────────────────────────┐│                ││││
││││││ if variable "b" = -1                             ││ if variable "b"││││
││││││┌─────────────────────┐                           ││     = 256      ││││
│││││││set variable "b" to 0│                           ││ ┌────────────┐ ││││
││││││└─────────────────────┘                           ││ │set variable│ ││││
││││││┌────────────────────────────────────────────────┐││ │ "b" to 0   │ ││││
│││││││┌──────────────────────┐                        │││ └────────────┘ ││││
││││││││if character (variable│ if character (variable │││                ││││
││││││││  "a") of input = i   │   "a") of input = d    │││                ││││
││││││││  ┌───────────────┐   │    ┌───────────────┐   │││                ││││
││││││││  │set variable   │   │    │set variable   │   │││                ││││
││││││││  │"b" to variable│   │    │"b" to variable│   │││                ││││
││││││││  │"b" + 1        │   │    │"b" - 1        │   │││                ││││
││││││││  └───────────────┘   │    └───────────────┘   │││                ││││
│││││││└──────────────────────┘                        │││                ││││
││││││└────────────────────────────────────────────────┘││                ││││
│││││└──────────────────────────────────────────────────┘│                ││││
││││└────────────────────────────────────────────────────┘                ││││
│││└──────────────────────────────────────────────────────────────────────┘│││
││└────────────────────────────────────────────────────────────────────────┘││
│└──────────────────────────────────────────────────────────────────────────┘│
│                                end program                                 │
└────────────────────────────────────────────────────────────────────────────┘

METAFONT

This is limited range due to limit of numbers in METAFONT.

scrollmode;
warningcheck:=0;
inner end;
Q:=0;
def Z = if(Q<0)or(Q=256):Q:=0;fi enddef;
def i = Q:=Q+1;Z; enddef;
def d = Q:=Q-1;Z; enddef;
def s = Q:=Q*Q;Z; enddef;
def o = message decimal Q; enddef;
def h = ;end; enddef;

Minecraft commands

# works in Minecraft 1.19.4-pre1 (and later, hopefully)
# this file should be located at data/deadfish/functions/deadfish.mcfunction in a data pack
# (for example, see data pack on GitHub: https://github.com/Arctenik/mc-data-packs/tree/main/interpreters/Deadfish)
# to use the interpreter, run a command like this to initialize the program in the "code" tag of the deadfish storage:
# /data modify storage deadfish code set value "iiisiiisdddddddo"
# and then run this function:
# /function deadfish:deadfish
#####################################

# make sure the scoreboard objective exists
scoreboard objectives add deadfish dummy
# if a program is stored in the "code" tag, start running that program
# move it the the "code_internal" tag and set the accumulator to 0
execute if data storage deadfish code run data modify storage deadfish code_internal set from storage deadfish code
execute if data storage deadfish code run scoreboard players set $accumulator deadfish 0
data remove storage deadfish code
# if running a program, move its first character to the "command" tag
execute if data storage deadfish code_internal unless data storage deadfish {code_internal:""} run data modify storage deadfish command set string storage deadfish code_internal 0 1
execute if data storage deadfish code_internal unless data storage deadfish {code_internal:""} run data modify storage deadfish code_internal set string storage deadfish code_internal 1
# evaluate the command, if it exists and is a valid command
execute if data storage deadfish {command:"i"} run scoreboard players add $accumulator deadfish 1
execute if data storage deadfish {command:"d"} run scoreboard players remove $accumulator deadfish 1
execute if data storage deadfish {command:"s"} run scoreboard players operation $accumulator deadfish *= $accumulator deadfish
execute if data storage deadfish {command:"o"} run tellraw @a {"score":{"name":"$accumulator","objective":"deadfish"}}
data remove storage deadfish command
# zero the accumulator as appropriate
execute if score $accumulator deadfish matches -1 run scoreboard players set $accumulator deadfish 0
execute if score $accumulator deadfish matches 256 run scoreboard players set $accumulator deadfish 0
# recurse if there's a non-empty program being run
execute if data storage deadfish code_internal unless data storage deadfish {code_internal:""} run function deadfish:deadfish

MineFriff

` [MineFriff Deadfish Interpreter]
0,` [The first item in the stack will always be the accumulator]
>Ca*62,a*62, oo i` [Output the interpreter prompt and then accept input]
 r.rI, Cffc, $` [Switch the stack around, adding a star on]
 v
^>r:Cffc,=?#v!~ 
            >r:I8*8*4,= ?#v.*0,` [Check the 256 requirement]
            v             >:I1-2,=?#~.*0,~ [Check the -1 requirement]
 ^          >r:Cf*7,=?#v!rI1,+~ [i(ncrement the accumulator)]
 ^                     >:Ca*a,=?#v!rI1,-1~ [d(ecrement the accumulator)]
 ^                               >:Ca*b1,=?#v!r:oCa,o~ [o(utput the accumulator)]
 ^                                          >:Ca*b5,=?#v!r:*~ [s(quare the accumulator)]
                                                      ;

minigolf

0i,nWT*+1,;,nB=,:_n0=,T+_n5=,1+_nF=,:*__::V=sT=+,0*__,_

MIPS Assembly

This code only accepts one lowercase letter at a time as a valid Deadfish command.

.data
readable: .asciiz ">> "
character: .space 2 # 1 bit + \0
new_line: .asciiz "\n"
.text
li $t0, 0 # character
li $t1, 0 # numeral
start_deadfish_loop:
la $a0, readable
li $v0, 4
syscall
la $a0, character
li $a1, 2
li $v0, 8
syscall
lbu $t0, ($a0)
bne $t0, 100, not_d
addi $t1, $t1, -1
j end_chars
not_d:
bne $t0, 105, not_i
addi $t1, $t1, 1
j end_chars
not_i:
bne $t0, 111, not_o
la $a0, new_line
li $v0, 4
syscall
move $a0, $t1
li $v0, 1
syscall
j end_chars
not_o:
bne $t0, 115, end_chars # s
mul $t1, $t1, $t1
end_chars:
la $a0, new_line
li $v0, 4
syscall
blt $t1, $zero, set_to_zero
beq $t1, 256, set_to_zero
end_number_checking:
j start_deadfish_loop
set_to_zero:
li $t1, 0
j end_number_checking

Mirah

no=0
while true do
   if no==-1 or no==256 then
      no=0
   end
   print ">> "
   the_cmd = System.console.readLine()
   if the_cmd.equals("d") then
      no=no-1
   elsif the_cmd.equals("i") then
      no=no+1
   elsif the_cmd.equals("s") then
      no=no*no
   end
   if the_cmd.equals("o") then
      puts "#{no}"
   end
end

MIX (Knuth)

Assembly code (the MIXPC assembler; not quite the same as MIXAL):

* DEADFISH ON MIX
* PUBLIC DOMAIN

        * CHANGE TO 64 FOR BINARY COMPUTERS
        BASE 100
        START

        * STORE CURRENT VALUE IN ACCUMULATOR
RESET   ENTA 0

        * DISPLAY PROMPT AND REQUEST INPUT
MAIN    CMPA =256=
        JE RESET
        OUT PROMPT(19)
        IN INBUF(19)
        JBUS *(19)

        * DISPATCH BY INPUT
        LD1 INBUF(1:1)
        DEC1 'D'
        J1Z OP_D
        DEC1 'I'-'D'
        J1Z OP_I
        DEC1 'O'-'I'
        J1Z OP_O
        DEC1 'S'-'O'
        J1Z OP_S
        JMP MAIN

        * DECREMENT
OP_D    JAZ MAIN
        DECA 1
        JMP MAIN

        * INCREMENT
OP_I    INCA 1
        JMP MAIN

        * SQUARE
OP_S    STA 0
        MUL 0
        SLAX 5
        JMP MAIN

        * OUTPUT
OP_O    STA 0
        CHAR
1H      CMPA ='0'(1:1)=(1:1)
        JNE 1F
        SLAX 1
        JMP 1B
1H      JANZ 1F
        LDA ='0'(1:1),0(2:5)=
1H      STA INBUF
        STX INBUF+1
        OUT INBUF(19)
        LDA 0
        JMP MAIN

PROMPT  TEXT ">>"
        FILL PROMPT+14

INBUF   FILL *+14

        END

Deck (for use with decimal versions of MIX) (note that each card has a space in the first character position):

 N O6 A O4    H N ENX   E K BU    I OALH   A. PAEN D LB    E  AEU  ABG G  9     
   5 7   5  2487 5 5  53971 25 193671 25  9 97 665  1417 695  1417 755  141     
   5171165  5567 885 19377 555 19347  45  1497  55  1497  75  1497  65  149     
   647 715  1417 515  14 7 515   397 515   397   5  5 37 515   397   5  1 5     
   657 515   397  15  1487  15   487   5  5247  55  2 67   5  52471175  956     
   787 815  8397 775   3971185  5 871 35  5317   5  5 821515     7   5          
   797  15  2 67 835  44 71 25  52471 25 19377 515   397   5     7   5          
   927   5     7   5     7   5     7   5     7   5     7   5     7   5          
   937   5     7   5     7   5     7   5     7   5     7   5     7   5          
  1 67   5     7   5     7   5     7   5     7   5     7   5  2560   5          
  1 77   5     7   5     7   5     7   5     7   5     0   5                    
   147 5 5   39                                                                 

This is the version of the deck for binary computers:

 N O6 A O4    H N ENX   E K BU    I OALH   A. PAEN D LB    E  AEU  ABG G  9     
   5 7   5  1767 136 75597 2623994 7 262392737 178 16 97 18588 417 1916 9 5     
   517 3 9 9 8 7 235699257 1491917 7  15486897  181 8337  13351217  1072977     
   647 181123297 138694487 138693837 138693837   5  3237 138693837   5   69     
   657 138693837   7622567   7621927   5  3447  181 8547   5  3447 3 17148      
   787 217342157 2 6851277 3 43332 7 275 11837   5  32878695 736 7   5          
   797   7622787 212582487 26239 327 262399417 138693837   5     7   5          
   927   5     7   5     7   5     7   5     7   5     7   5     7   5          
   937   5     7   5     7   5     7   5     7   5     7   5     7   5          
  1 67   5     7   5     7   5     7   5     7   5     7   5  25675 381648      
  1 77   5     7   5     7   5     7   5     7   5     75 381648                
   147 136 7239                                                                 

MMIX

v	GREG 0
	LOC Data_Segment
buf	OCTA 0,0,0,0
buf2	BYTE 0,10,0
arg	OCTA buf,1
	GREG buf

	LOC #100
	BYTE ">> ",0
G256	GREG #100
	% Prompt for and read input
Main	LDA $255,#100
	TRAP 0,Fputs,1
	LDA $255,arg
	TRAP 0,Fread,0
	% Set to zero if -1 or 256
	ZSP v,v,v
	CMP $0,v,G256
	CSZ v,$0,0
	% Check what command has been specified
	LDBU $0,buf
	SUB $0,$0,10
	BZ $0,Main
	SUB $0,$0,'d'-10
	PBNZ $0,1F
	% Decrement
	SUB v,v,1
	PBZ $0,2F
1H	SUB $0,$0,'i'-'d'
	PBNZ $0,1F
	% Increment
	ADD v,v,1
	PBZ $0,2F
1H	SUB $0,$0,'o'-'i'
	PBNZ $0,1F
	% Output
	LDA $255,buf2
	DIV $1,v,10
3H	GET $0,rR
	ADDU $0,$0,'0'
	STBU $0,$255
	BZ $1,3F
	SUBU $255,$255,1
	DIV $1,$1,10
	PBNZ $255,3B
3H	TRAP 0,Fputs,1
	PBZ $1,2F
1H	SUB $0,$0,'s'-'o'
	PBNZ $0,1F
	% Square
	MUL v,v,v
	PBZ $0,2F
1H	ADD $0,$0,'s'-'h'
	BNZ $0,2F
	% Halt
	TRAP 0
	% Skip the rest of the input line
2H	LDA $255,arg
	TRAP 0,Fread,0
	LDBU $0,buf
	SUB $0,$0,10
	PBNZ $0,2B
	PBZ $0,Main

MNNBFSL

Currently, all instructions must be on a single line.

[ _
<[<[-"]++++++">>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<[<_[->+<"][]>"+_
]_+">++++]_checked if acc = 1 under 0>
<"[<[-"]++++"">>>[<[-"]<<-[>"<-"][]<-[>>>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<<-"][][->+<"][][->-<"]_
[<[-"]++++++">>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<[<_[->+<"][]>[]_
][-"]">++++] checked if acc = 256       >_
,_+[-"][][<[-"]++++++++++">>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<[->-<"]
[++++++++++">>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<<[->+<"][]>"_
]<->++">] checked if command = d  _
_
-----_
[<[-"][++++++++++">>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<<[->+<"][]>"_
]<+>++">] checked if command = i  _
_
------_
[<[-"][++++++++++">>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<<[->+<"][]>"_
]<".>++">] checked if command = o_
_
----_
[<[-"][++++++++++">>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<<[->+<"][]>"_
]<">>[<[-"]<<-[>"<-"][]>[[-<<<+>>>"][]"][]<>++">] checked if command = ^2

Nim

var a = 0
while true:
  if a == -1 or a == 256:
    a = 0
  write(stdout, ">> ")
  case readLine(stdin)
  of "d":
    a -= 1
  of "i":
    a += 1
  of "o":
    echo(a)
  of "s":
    a = a * a

Nqubl

Implementation by User:David.werecat, interprets only one instruction per line.

#
" >>"E
GT3S3T0T0T0T0S0
#G~10~=KX}{#
"i"=!KX}S2MS0#
"d"=!KX}S2DS0#
"s"=!KX}S2T3S4~0~]#S3T0S0~0~=KX}S3DS2T0S4T0S0+T4{#S4T2S0#
"o"=!KX}S2NS0~10~P#
S2T0T0S0
~256~=!KX}S2~0~S0#
~-1~=!KX}S2~0~S0#
[[[[[[[[{

OASYS (OAC)

class player {}

property int dummy

int value

method check {
  if value == -1 or value == 256 value = 0
}

method increment verbs {{i} {x}} {
  value = value + 1
  this check
}

method decrement verbs {{d}} {
  value = value - 1
  this check
}

method square verbs {{s} {k}} {
  value = value * value
  this check
}

method output verbs {{o} {c}} {
  print value
  print "\n"
}

method init {
  player = create player
}

OASYS Assembler

[&]%@*>
['I'X]%#%#<UP>+&CHK
['D]%#%#<DN>+&CHK
['S'K]%#%#<%#<MUL>+&CHK
['O'C]%#<PI CR
[&CHK]%#<-1EQ/%#<256EQ/ RP:%#0>

Obfuscated C

Implementation by User:David.werecat, interprets only one instruction per line.

#include <stdio.h>
#define A case
#define B(x,y) A x:;y;R;
#define C "%c"
#define D(x) O(S,x);S(x)
#define E(x) O(while,x){
#define F(x,y,z) x(y,z);
#define G getchar()
#define H char
#define I "%i"
#define J main
#define K(x,y,z) x y z
#define L printf
#define M }}}}
#define N "\n"
#define O(x,y) x(y)
#define P(x) F(L,I N,x)
#define Q(x,y) K(x,=,y)
#define R break
#define S(x) F(L,C,x)
#define T(x) O(if,x){
#define U(x) O(switch,x){
#define V void
#define W int
#define X(x,y) x y
#define Y(x) K(x,!=,10)
#define Z(x) Q(x,0);
V J(){W Z(a)H m;E(1)D(K((K(30,+,1)),<<,1))F(Q,m,G)U(m)B(K(3,*,K(5,*,7)),X(a,++))B(K((K(5,*,5)),<<,2),X(a,--))B(111,P(a))B(K(5,*,23),K(a,*=,K(a,^,0)))}T(K((K(a,<,0)),|,(K(a,==,(K(1,<<,8))))))Z(a)}T(Y(m))E(Y(G))M

OCaml

let rec loop (x', s) : (int * string) -> unit =
  print_string (s ^ ">> ");
  let line = read_line () in
  let c = if String.length line > 0 then line.[0] else '?' in
  let x = match x' with (-1 | 256) -> 0 | _ -> x' in
  loop (match c with
  | 'i' -> (x+1, "")
  | 'd' -> (x-1, "")
  | 'o' -> (x, string_of_int x ^ "\n")
  | 's' -> (x*x, "")
  | _   -> (x, "\n")
  )
let _ = loop (0, "")

OLNMLN

j0006A?p0000#p0000ij0006Fcˇi=GIGcˇd=HDHcˇs=JSJcˇo=KOKp0000=LALˇ{^rj0007Zr@p-001=QWQ@p0256=EREj0006YFI.ZD,ZS@@*#ZO&ZW.YRp0000#Y

ONE WAY

second
  push 0
push true
push type
push true
while
  push ">> 
  print
  input
  split
  dupe
  push type
  equal
  not
  while
    dupe
    push "h
    equal
    if
      drop
      push true
      while
        push type
        equal
        not
      push false
    else
      dupe
      push "d
      equal
      if
        second
          dupe
          push 0
          equal
          not
          if
            dupe
            push 257
            equal
            if
              drop
              push 0
            else
              push -1
              add
      else
        dupe
        push "i
        equal
        if
          second
            dupe
            push 255
            equal
            if
              drop
              push 0
            else
              push 1
              add
        else
          dupe
          push "o
          equal
          if
            second
              dupe
              repr
              print
              push "\n
              print
          else
            second
              dupe
              push 16
              equal
              if
                drop
                push 0
              else
                dupe
                multiply
      drop
      dupe
      push type
      equal
      not
  dupe
  push type
  equal

OOLANG

In this interpreter added instruction "h", to end execution.

x.0.set;
a.label;
a.Input code:..in;

x>256.31.5.ifa;

x<0.31.7.ifa;

a==i.9.12.ifa;

x.inc;
a.goto;

a==d.14.17.ifa;

x.dec;
a.goto;

a==s.19.22.ifa;

x.x.mul;
a.goto;

a==o.24.27.ifa;

x.get;
a.goto;

a==h.29.29.ifa;

.halt;

x.0.set;
a.goto;

Pair

Set output_as_string to true if you want unicode output instead of integer list.

output_as_string = false
main src = format_output | reverse | index 1 | exec_state (map_m run src) [int_0, ""]

format_output = ite output_as_string (map | dot int_val abs) | show_list show_int
run x = index (elem_index' x "idso") inst_funcs
inst_funcs = [increment, decrement, square, output]
normalize n = ite (elem n [int_neg_1, mk_int 0 256]) int_0 n
modify_val f = modify' 0 | dot normalize f
increment = modify_val inc_int
decrement = modify_val dec_int
square = modify_val | pow_int' | mk_int 0 2
output = bind (get' 0) | dot (modify' 1) cons

Parse this sic

Prompts the user to input a one-line idso Deadfish program. Outputs are separated by spaces (" ").

-((dominate&&(*)))/(**)(&)|/(&*)
|&((ditto&(times&G&G&)(*)))/(**)(&)
/*&(((p&(dominate&p&1&)&)p&))((ditto&H&(*)))/=
/*((ditto&(c&(*)I&)iI&))/(**)((ameliorate&*1&))|
/*((ditto&(c&(*)D&)dD&))/(**)((dominate&*1&))_|&|
/*((ditto&(c&(*)S&)sS&))/(**)((times&(*)*))_|&|
/*((ditto&(c&(*)O&)oO&))/(**)(walking&(651&&)&)*_|&|
/(**)_|&(2&)+((*))&/|/( &)/**( &)=/**(0 &)=
|((dominate&(*)(times&(spaces&(*)A&)A&)))/|
/*( &0& &)|((dominate&(*)1&))/*( &* &)_|&|/**( &1& &)
|&((spaces&*A&))_+(((()&%&deeccus)))(&1&&p)&H%

Pascal

PROGRAM deadfish (INPUT, OUTPUT);
VAR
    cmd: CHAR;
    acc: INTEGER;
BEGIN
    acc := 0;
    REPEAT
        WRITE(‘>>’);
        READLN(cmd);
        CASE cmd OF
            ‘i’ : acc := acc+1;
            ‘d’ : acc := acc-1;
            ‘s’ : acc := SQR(acc);
            ‘o’ : WRITELN(acc);
        END;
        IF acc<0 THEN acc := 0;
        IF acc=256 THEN acc := 0;
    UNTIL cmd=‘h’;
END.

Path

┐       ┌$$$┐
├256JJ=1^┐  ├~:001jj±-&-%v$$$$:501jj±-&-%v$$$$:111jj±-&-%v$$$$:115JJ±-&-%v┐
│      ┌─┘  0  ┌-$v1$$$$$┘               │               │               ││
│      └$$$$┘  │  │                      │               │               ││
└──────────────┤  └─$─$─0─┬────────+$$$$$┘               │               ││
               └──────────┤            ┌─────────p.:$$$$$┘               ││
                          └────────────┤               ┌──────────×:$$$$$┘│
                                       └───────────────┤                  │
                                                       └─────────────$$$$$┘

Perl

#!/usr/bin/perl -w

my $acc=0;
while (1) {
    print ">> ";
    $_ = <>;
    if ($acc==-1 or $acc==256) { $acc=0; }
    if (/^i$/) { $acc++; }
    elsif (/^d$/) { $acc--; }
    elsif (/^o$/) { print $acc, "\n"; }
    elsif (/^s$/) { $acc*=$acc; }
    else { print "\n"; }
}

Pike

A terrible oversight (that of not having a Pike Deadfish) has now been corrected. ;)

// Deadfish in Pike (Pike v8.0 release 702), version 1 -- dnm 2023-11-08

int a = 0;

int main() {
    while(1) {
        write(">> ");
        string in = Stdio.stdin->gets();
        array(string) chars = in/"";
        foreach(chars ;; string char) {
            switch(char) {
                case "i": a = a + 1; break;
                case "d": a = a - 1; break;
                case "s": a = a * a; break;
                case "o": write(a + "\n"); break;
            }
        if((a == 256) || (a < 0)) { a = 0; }
        }
    }
}

Plurple

xkcd only.

ooc:Used targets as input.
create ranged number acc.
fight:@targets.
 attack (acc<0 or acc==256);
 hit:
  acc is 0.
 done.
 menu target.
 option:"x".
  acc up.
 option:"d".
  acc down.
 option:"k".
  acc is (acc ^ 2).
 option:"c".
  say acc.
 done.
 grind yes.
 ooc:this is valid.
done.

PostScript

% Run with:  gs -q -dNODISPLAY deadfish.ps
/C <<
  (i) {1 add}
  (d) {1 sub}
  (h) {quit}
  (o) {dup =}
  (s) {dup mul}
>> def
0 {
  (>> ) print flush
  C (%lineedit) (r) file 1 string readstring pop get exec
  dup 256 eq {pop 0} if
  dup 0 lt {pop 0} if
} loop

Prolog

deadfish(Prog, I) :-
   when((ground(Prog);ground(ProgList)), atom_chars(Prog, ProgList)),
   when((ground(I);ground(Digits)), number_chars(I, [Digit | Digits])),
   phrase(deadfish(ProgList, 0), [Digit | Digits]).

deadfish([], _) -->
   [].
deadfish([o | Prog], I) -->
   {
      I >= 0,
      number_chars(I, Digits)
   },
   Digits,
   deadfish(Prog, I).
deadfish([i | Prog], I) -->
   {
      I1 is I + 1,
      deadfish_(I1, I2)
   },
   deadfish(Prog, I2).
deadfish([d | Prog], I) -->
   {
      I1 is I - 1,
      deadfish_(I1, I2)
   },
   deadfish(Prog, I2).
deadfish([s | Prog], I) -->
   {
      I1 is I * I,
      deadfish_(I1, I2)
   },
   deadfish(Prog, I2).

deadfish_(I, I) :-
   dif(I, -1),
   dif(I, 256).
deadfish_(-1, 0).
deadfish_(256, 0).

This prolog implementation is fully pure and can be used to evaluate, generate and test deadfish programs.

Pure

using system;
fish a "i" = a+1;
fish a "d" = a-1;
fish a "s" = a*a;
fish a "o" = a when puts (str a) end;
limit a = if a == 256 || a < 0 then 0 else a;
main a = (printf "%s " ">>") $$ (main (fish (limit a) (gets)));
main 0;

Python

"""
Deadfish Programming Language Interpreter
Programmed by Jonathan Todd Skinner
This code is hereby released into the public domain
Harry eased the mess
"""

# Initialization
accumulator = 0

# Main program loop
while True:
    # Get user input
    cmd = raw_input('>> ')
    if accumulator == 256 or accumulator == -1:
        # Overflow, reset accumulator
        accumulator = 0
    # Process input
    if cmd == 'i':
        accumulator += 1 # Increment
    elif cmd == 'd':
        accumulator += -1 # Decrement
    elif cmd == 'o':
        print accumulator # Output
    elif cmd == 's':
        accumulator *= accumulator # Square
    else:
        print 'Unrecognized command.'

A shorter one by User:None1 that uses the built-in function exec():

exec('x=0\n'+'\n'.join([{'i':'x+=1','d':'x-=1','s':'x*=x','o':'print(x%256)'}[i] for i in input()]))

Python 3.x

#!/bin/env python3

'''
Deadfish Interpreter written in python3.
Written by chill0r.
Everything is free to use - no restrictions.

Startup arguments:
	-strict: Output errors (and abort) on invalid characters and Overflow
	-p program: Execute program (does not exit if not told so)
	
Accepted characters (case sensitive!):
	i / x: increment by 1
	d: decrement by 1
	s / k: square
	o / c: print accumulator
	h: exit interpreter (and stop program) (non standard)
	r: reset accumulator to 0 (non standard)
'''
import sys

class DeadfishError(Exception):	
	def __init__(self, message):
		print(message)
		sys.exit(1)

prog = sys.argv[sys.argv.index('-p')+1] if '-p' in sys.argv else None
strict = '-strict' in sys.argv

acc = 0
i = 0

print('''Python3 Deadfish interpreter version 0.1''')

while True:
	if not bool(prog):
		prog = input('>>')
	for char in prog:
		if strict and not char in ['i', 'x', 'd', 's', 'k', 'h', 'o', 'c', 'r']:
			raise DeadfishError('Invalid character {} at index {}'.format(char, i))
		if char in ['i','x']:
			acc += 1
		elif char == 'd':
			acc -= 1
		elif char in ['s', 'k']:
			acc *= acc
		elif char == 'h':
			print('Long live the fish!')
			sys.exit(0)
		elif char == 'r':
			acc = 0
		if acc < 0 or acc == 256:
			if strict:
				raise DeadfishError('Overflow at char {} (Index {}) accumulator = {}'.format(char, i, acc))
			else:
				acc = 0
		if char in ['o', 'c']:
			print(acc)
		i += 1
	prog = None
	i = 0

another one:

#Deadfish Interpreter by User:Asdf (Prints X when error)
a=0
while 1:
    c=input()
    if a==256 or a<0:
        a=0
    if c=='i':
        a+=1
    elif c=='d':
        a-=1
    elif c=='o':
        print(a)
    elif c=='s':
        a*=a
    else:
        print('X')

Yet another one by User:Tux1

accumulator = 0

while True:
    command = input(">> ")

    if accumulator == 256 or accumulator == -1:
        accumulator = 0

    if command == "i":
        accumulator += 1
    elif command == "d":
        accumulator -= 1
    elif command == "s":
        accumulator **= 2
    elif command == "o":
        print(accumulator)

And another one with built in halting... -User:Myoitzi

string = input()
run = 1
a = 0
num = 0
maxnum = len(string)
while run == 1:
    if a == -1:
        a = 0
    if a == 256:
        a = 0
    if num < maxnum:
        if string[num] == 'i':
            a = a+1
            num = num+1
        elif string[num] == 'd':
            a = a-1
            num = num+1
        elif string[num] == 's':
            a = a*a
            num = num+1
        elif string[num] == 'o':
            print(a)
            num = num+1
        else:
            num = num+1
    else:
        run = 0

QuickBasic/QBasic/QB64

Takes input as arguments from the command-line.

PRG$ = COMMAND$
FOR I& = 0 TO LEN(PRG$)
  SELECT CASE MID$(PRG$, I&, 1)
    CASE "i": A% = A% + 1
    CASE "d": A% = A% - 1
    CASE "s": A% = A% * A%
    CASE "o": PRINT CHR$(A%);
    CASE "h": SYSTEM
    CASE ELSE: PRINT
  END SELECT
  IF (A% AND 255) <> A% THEN A% = 0 'A less resource-intensive way of checking if it is not equal to
NEXT

R

n <- 0
while(TRUE) {
  if(n==-1 || n==256) n <- 0
  cmd <- scan(n=1,what='character')
  fun <- switch(cmd,
                d=function(x) x-1,
                i=function(x) x+1,
                o=function(x) { cat(x,"\n"); x },
                s=function(x) x*x)
  if(!is.null(fun)) n <- fun(n)
}

Another interpreter:

#This uses normal commands, xkcd commands, and h.

num <- 0 # accumulator
keep_going <- TRUE # indicates to keep going
while(keep_going){
  # Cat prints formatted strings.
  cat('Enter code:')
  
  # You can add one whole line of code.
  # The line can include spaces and ends at a newline
  entered_code <- scan(nlines=1,what='character')
  
  # This allows the members of the character vector
  # to be interpreted as a single string.
  entered_code <- paste(entered_code, collapse = " ")
  
  # This for-loop analyses each command.
  for(pointer in 1:nchar(entered_code)){
    letter <- substr(entered_code,pointer,pointer)
    
    # This outputs each input command.
    cat(paste('>> ',letter,'\n',sep=''))
    
    if(letter %in% c("i","x")){num <- num + 1}
    else if(letter %in% c("s","k")){num <- num * num}
    else if(letter %in% c("o","c")){cat(paste(num,'\n',sep=''))}
    else if(letter == "d"){num <- num - 1}
    else if(letter == "h"){keep_going <- FALSE;break}
    
    if(num == -1 | num == 256){num <- 0}
  }
}

Raku

use v6.d;

# set accumulator as a defined integer
my Int:D $acc = 0;

# loop forever
loop {

  # get a line of input with a prompt of >>
  my Str:D $input = prompt ">> ";

  # iterate and map a function over each character
  $input.comb.map(-> $command {

    # switch statement with pattern matching and no fallthrough
    given $command {

      # check if command is either "i" or "x" and increment acc
      when "i" | "x" {
        ++$acc
      }

      # decrement acc
      when "d" {
        --$acc
      }

      # square acc
      when "s" | "k" {
        $acc **= 2
      }

      # print acc with newline
      when "o" | "c" {
        say $acc
      }

      # exit with exit status 0
      when "h" {
        exit
      }
    }

    # set acc to 0 if it is -1 or 256 after command
    $acc = $acc == -1 | 256 ?? 0 !! $acc
  })
}

REBOL 3

f: does [if a = -1 or (a = 256) [a: 0]]
d: [
    any [
        ["i"|"x"] (++ a f) |
        ["d"] (-- a f) |
        ["s"|"k"] (a: a * a f) |
        ["o"|"c"] (print a) |
        skip
    ]
]
a: 0 
forever [parse (ask ">>") d]

Rexx

Derived from Deadfish in Zeno (in turn derived from Deadfish in Turing, a.k.a. "Deadfish in Deadfish"), then modified slightly with respect to whitespace to make it "reasonably" compact.

/* Deadfish in Rexx -- dnm 2021-06-04 */
accumulator = 0

do forever
    if (accumulator = 256) | (accumulator < 0) then accumulator = 0
    call charout ,">> " ; parse pull command
    select
        when command == "i" then accumulator = accumulator + 1
        when command == "d" then accumulator = accumulator - 1
        when command == "s" then accumulator = accumulator * accumulator
        when command == "o" then say accumulator
        otherwise say "Unrecognized command"
    end
end

Ruby

Implementation by Abe Voelker

#!/usr/bin/env ruby
 
n = 0
while true
  print '>> '
  gets.chomp.each_char do |c|
    n = 0 if [-1, 256].include?(n)
    case c
      when 'd' then n -= 1
      when 'i' then n += 1
      when 'o' then puts n
      when 's' then n *= n
    end
  end
end

Here is an implementation that doesn't return an error, and produces more clear output, by Areallycoolusername.

acc = 0
i = nil
while i != 'h' 
  print '>> '
  i = gets.chomp
  if i == 'i' then acc += 1
  	puts "\n"
  end
  if i == 'd' then acc -= 1
  	puts "\n"
  end
  if i == 's' then acc *= acc
  	puts "\n"
  end
  if i == 'o' then puts "#{acc}\n" end
  if acc < 0 || acc == 256 then acc = 0 end
end

Rust

use std::io::{self, Write};

fn main() -> io::Result<()> {
    let stdin = io::stdin();
    let mut input = String::new();
    let mut acc: i64 = 0;
    loop {
        print!(">> ");
        io::stdout().flush()?;
        input.clear();

        stdin.read_line(&mut input)?;
        for ch in input.chars() {
            match ch {
                'i' => acc += 1,
                'd' => acc -= 1,
                'o' => println!("{acc}"),
                's' => acc *= acc,
                _ => println!(),
            }
        }
        if acc < 0 || acc == 256 {
            acc = 0;
        }
    }
}

Robin

Runs under Robin 0.3 to (at least) Robin 0.7. Requires stdlib to be loaded before running. Does not accept more than one command per line.

(reactor (line-terminal) 0
  (macro (self args env)
    (bind event (head args)
      (bind event-type (head event)
        (bind event-payload (head (tail event))
          (bind prev-state (head (tail args))
            (bind state
              (if (equal? prev-state (subtract 0 1))
                0
                (if (equal? prev-state 256)
                  0
                  prev-state))
              (bind prompt (macro (self args env)
                  (bind show (eval env (head args))
                    (bind state (eval env (head (tail args)))
                      (if show
                        (list state
                              (list (literal writeln) (itoa state))
                              (list (literal write) (literal ''>> '')))
                        (list state
                              (list (literal write) (literal ''>> '')))))))
                (choose
                  ((equal? event-type (literal init))
                    (prompt #f state))
                  ((equal? event-type (literal readln))
                    (bind letter event-payload
                      (choose
                        ((equal? letter (literal ''d''))
                          (prompt #f (subtract state 1)))
                        ((equal? letter (literal ''i''))
                          (prompt #f (subtract state (subtract 0 1))))
                        ((equal? letter (literal ''s''))
                          (prompt #f (multiply state state)))
                        ((equal? letter (literal ''o''))
                          (prompt #t state))
                        (else (prompt state)))))
                  (else
                    (list state)))))))))))

Rockstar

The beginning is perfection.
Perfection is an alert fisher.

The end is perfection.
Desperate is a mysterious individual.
Burn it.
Innocent is a respectful horse.
Burn it.
Savage are a contestant's words.
Burn it.
Honest is a proposition unfulfilled.
Burn it.

Listen to the fish.
Cut it.
The man is respectful.
While the man is weaker than the fish,
let the story be the fish at the man
if the story is innocent
build the end up

if the story is desperate
knock the end down

if the story is savage
let the end be of the end

if the story is honest
say the end

if the end is weaker than the beginning
the end is perfection

if the end is perfection
the end is perfection

Build the man up

Röda

{i=0;chars|{|k|i++if[k="i"];i--if[k="d"];i*=i if[k="s"];print i if[k="o"];i=0 if[i=-1 or i=256]}_}

The language defined by the Revised Revised Revised Revised Revised Report on the Algorithmic Language Scheme

(define (execute n cmd)
  (case cmd
    ((#\i) (+ n 1))
    ((#\d) (- n 1))
    ((#\s) (* n n))
    ((#\o) (display n) (newline) n)
    (else n)))

(define (deadfish n)
  (let ((char (read-char)))
    (cond
     ((or (= n -1) (= n 256)) (deadfish 0))
     ((eof-object? char) n)
     (else (deadfish (execute n char))))))

(deadfish 0)

Scratch 3.0

Here

Seabass

iisibCmbCZbmbbCZbmbbbCZbmbbbbCbcazZZxnzZaCaczciZxbbIIIIZnzZaCaczciiiZxaxzcaxziibIIIIbIIIZTaxzcaxziiibIIIIbIIIZTaxzcaxziiiibIIIIbIIIZTaxzcaxzbbIIIIZTzZaCaczcbIZxbIbIIIIZnzZaCaczcibIZxbbIIIIZnzZaCaczciibIZxbIIIbIIIIZnzZaCaczciiibIZxibIIbIIIIZnzZaCaczciiiibIZxnzZaCaczcbIIZxnzZaCaczcibIIZxbIbbIIZnzZaCaczciibIIZxaxzcaxziibIIbIIZTaxzcaxziibIIbIIZTzZaCaczciiibIZ;zZaCaczciibIIZxiiiZQzZaCaczciibIZ;zZaCaczcixlxaaxzcxlaaxz{zZaCaczciiiiZxnzZaCaczcxlaCzxiii#aCzxiiiiad=i>.izxT>zZaCaczcbIZxlxaaxzciiiixlaaxz=zZaCaczciiiibIZxlinzZaCaczc>zZaCaczcibIZxlxaaxzciiiixlaaxz=zZaCaczciiiibIZxldnzZaCaczc>zZaCaczciibIZxlxaaxzciiiixlaaxz=zZaCaczciiiibIZxlsfzZaCaczc>zZaCaczciiibIZxlxaaxzciiiixlaaxz=zZaCaczciiiibIgOzZaCaczc>zZaCaczcbIIZxlxaaxzciiiibIZxlaaxz=zZaCaczcbIIZxlaCzxiiiibIZxfzZaCaczc>zZaCaczcibIIZxlxaaxzciiiibIZxlaaxz=zZaCaczcibIIZxlaCzxiiiibIZxfzZaCaczc>zZaCaczcZxlinzZaCaczciibIZjzZaCaczc>zZaCaczcZxnzZaCaczciiibIZjzZaCaczc

(GNU) sed

Takes input on separate lines.

G
s/i./;/
s/d.;\?//
/o/{g
:b;s/\n\?;\{10\}/;\n/;tb
s/$/0123456789w/mg
:a;s/;\w//;ta
s/\B\w*\n*//gp
x}
/s/{g;:c;/^;/G;s///;tc;s/\n//g}
s/^;\{256\}$//;x;d

Seed7

This version includes the optional halt command (for if this was not included, you would need to press Ctrl+C, then *, to exit the interpreter. Or enter a blank line to make it crash.) This is not really conformant as the spec says that errors are ignored

$ include "seed7_05.s7i";
  include "stdio.s7i";

var boolean: keep_going is TRUE;
var integer: accumulator is 0;
var string: command is "";

const proc: main is func
  begin
    while keep_going do
      if accumulator = 256 or accumulator < 0 then
          accumulator := 0;
      end if;
      write(">> ");
      readln(command);
      case command[1] of
        when {'s'}: accumulator := accumulator * accumulator;
        when {'o'}: writeln(accumulator);
        when {'i'}: accumulator := accumulator + 1;
        when {'d'}: accumulator := accumulator - 1;
        when {'h'}: keep_going := FALSE;
        otherwise: writeln("STOP CONFUSING ME");
      end case;
    end while;
  end func;

A more awesome version of this implementation would use Seed7's ability to create new program structures.

S-Lang

#!/usr/bin/env slsh

variable l=" ", n=0, r;
forever {
  if (n==-1||n==256) n=0;
  r=fputs(">> ", stdout);
  r=fgets(&l, stdin);
  switch (l[0])
    { case 'd': n--; }
    { case 'i': n++; }
    { case 'o': print(n); }
    { case 's': n=n*n; }
  }
}

Protip 1: if you do not do something with the result of fputs and fgets (assign them to the scratch variable r in this case), slsh eventually runs out of stack space.

Protip 2: the braces in the above program are not matched correctly. slsh does not seem to care.

Selt

# https://esolangs.org/wiki/Deadfish
loop:
  print \>\>\ 
  input = @stdin
  index = 0
  goto inloop~(@input != `) # jump to end when input is empty
  inloop1:
    goto @input.@index # go to the label corresponding to each command
    i:val = @val+1
    goto end
    d:val = @val-1
    goto end
    s:val = @val*@val
    goto end
    o:println @val
    goto end
    end:goto reset~((@val == \-1) || (@val == 256))
    reset1:val = 0
    reset0:
    index = @index+1
    goto inloop~(@index < ?@input)
  inloop0: goto loop
index:0
val:0
input:

Shakespeare

Tested on the tio.run implementation. Written by User:BoundedBeans

A Shakespearean Depiction of a Deceased Fish;
----------------------------------------------------
This is a Deadfish interpreter written in Shakespeare;
End the program with a pipe character ('|');
Methinks this is the end of this wretched commentary.

Romeo, the program stack.
Lady Macbeth, a helper stack.
Juliet, the register.
Hamlet, for checking ASCII codes.

Act I: The lone wolf act (other than halting).
Scene I: Startup.
[Enter Romeo and Lady Macbeth]
    Lady Macbeth:
        You are nothing!
        Remember yourself!

    Romeo:
        You are nothing!
        Remember yourself!

[Exit Lady Macbeth]
[Enter Juliet]
    Romeo:
        You are nothing!
        Let us proceed to Scene II.

Scene II: The input loop.
[Exeunt]
[Enter Romeo and Lady Macbeth]
    Romeo:
        Open your mind! 

[Exit Romeo]
[Enter Hamlet]
    Lady Macbeth:
        You are the difference between a big big big big big big big cat and a big big cat! 
        Am I as good as you?

    Hamlet:
        If so, let us proceed to Scene III. 
        Remember yourself!

    Lady Macbeth:
        Let us proceed to Scene II.

Scene III: Transfer stack from Lady Macbeth to Romeo to reverse the input data.
[Exeunt]
[Enter Romeo and Lady Macbeth]
    Romeo:
        Recall your wretched nightmare!

    Lady Macbeth:
        Am I as good as nothing?

    Romeo:
        If so, let us proceed to Scene IV.

    Lady Macbeth:
        Remember me!
        Let us proceed to Scene III.

Scene IV: Main interpretation.
[Exeunt]
[Enter Romeo and Hamlet]
    Hamlet:
        Recall the king's treason!

    Romeo:
        Am I as good as nothing?

    Hamlet:
        If so, let us proceed to Act II.

    Romeo: 
        You are the sum of a cat and a big big big cat!
        You are the sum of thyself and a big big big big big cat.
        You are the sum of thyself and a big big big big big big cat. 
        Am I as good as you?

    Hamlet:
        If so, let us proceed to Scene V.

    Romeo:
        You are the square of the sum of a big big big cat and a big cat!
        Am I as good as you?

    Hamlet:
        If so, let us proceed to Scene VI.

    Romeo:
        You are the sum of a cat and a big cat!
        You are the sum of thyself and a big big big big cat!
        You are the sum of thyself and a big big big big big cat!
        You are the sum of thyself and a big big big big big big cat! 
        Am I as good as you?

    Hamlet:
        If so, let us proceed to Scene VII.

    Romeo:
        You are the difference between yourself and a big big cat!
        Am I as good as you?

    Hamlet:
        If so, let us proceed to Scene VIII.

    Romeo:
        Let us proceed to Scene IV.

Scene V: The 'i' command.
[Exeunt]
[Enter Romeo and Juliet]
    Romeo:
        You are the sum of yourself and a cat!
        Let us proceed to Scene IX.

Scene VI: The 'd' command.
[Exeunt]
[Enter Romeo and Juliet]
    Romeo:
        You are the difference between yourself and a cat!
        Let us proceed to Scene IX.

Scene VII: The 's' command.
[Exeunt]
[Enter Romeo and Juliet]
    Romeo:
        You are the product of yourself and yourself!
        Let us proceed to Scene IX.

Scene VIII: The 'o' command.
[Exeunt]
[Enter Romeo and Juliet]
    Romeo:
        Open your heart! 
        Remember yourself.
        You are the sum of a big big big cat and a big cat.
        Speak your mind!
        Recall yourself.
        Let us proceed to Scene IX.

Scene IX: 256 or -1 checker.
[Exeunt]
[Enter Hamlet and Juliet]
    Juliet:
        You are a big big big big big big big big cat!
        Am I as good as you? 
        If so, let us proceed to Scene X. 
        You are the difference between nothing and a cat!
        Am I as good as you?
        If so, let us proceed to Scene X.
        Let us proceed to Scene IV.

Scene X: Casting Juliet into the abyss.
[Exeunt]
[Enter Hamlet and Juliet]
    Hamlet:
        You are nothing!
        Let us proceed to Scene IV.

Act II: The Halting.
Scene I: The only scene in The Halting.
[Exeunt]

SmileBASIC

Takes a line from stdin and runs all characters in said line. Unrecognized commands print a newline. Commands are case-sensitive, lowercase. Implements h and proper x==0||x==256 behavior.

OPTION STRICT
'declare vars
VAR X%
VAR S$,C$

'REPL loop
REPEAT
 LINPUT ">> ";S$ 'get line from stdin
 'exec all chrs in line
 WHILE LEN(S$)!=0
  C$=SHIFT(S$) 'pop chr from front of string
  IF C$=="i" THEN
   INC X%
  ELSEIF C$=="d" THEN
   DEC X%
  ELSEIF C$=="s" THEN
   'square x
   X%=X%*X%
  ELSEIF C$=="o" THEN
   'output x
   PRINT X%
  ELSEIF C$=="h" THEN
   BREAK
  ELSE
   PRINT 'adds a newline
  ENDIF
  IF X%<0||X%>255 THEN X%=0 'zero behavior
 WEND
UNTIL C$=="h"

SNUSP

              /@@@=@@@=++++#	100 = 5*5*4 = 'd'
   /          |                \! \
$=!\>,+?!#-=>@/=!/?!\<?\>!/?\<</  |
      eof? 'd'   \->| -/  \-/     |
                    \<?\==!=== < -/
           'i'/  +++++>/  |       !
              \ !/?!\<?\> /       |
                 \->| -/  !       |
                    \<?\==|==  < +/
           'o'/ ++++++>/  |       !
              \ !/?!\<?\> /       |
                 \->| -/  !       |
                    \<?\==|==  < ./
           's'/   ++++>/  |       !
              \ !/?!\<?\> /       |
                 \->| -/          |
 /= square = < = /?</             |
 |  /======= > =!\ noop =!/==  <  /
 |  |       / ++<+<\      |
 \?!/>>+<<-?\>!/>-?/<<+>?!/>+<\
    \  up2  /  \          \?- /

SOAP

This will only run in the copied implementation. You will need to follow the steps listed on the SOAP page, it's not as simple as inputting the program.

This supports numbers up to 299. Suffix with a period.

*1*102011⊇{102011}[
  ~
  'i/*%:*%⊇{100112}[*%;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*%]\
  'd/*%;*%⊇{100112}[*%;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*%]\
  's/
    *102012
    ⊇{10,102012}[*%::*%*102012]
    ⊇{11,102012}[*%::::::*%*102012]
    ⊇{12,102012}[*%::::::::::::*%*102012]
    ⊇{20,102012}[*%::::::::::::::::::::*%*102012]
    ⊇{21,102012}[*%::::::::::::::::::::::::::::::*%*102012]
    ⊇{22,102012}[*%::::::::::::::::::::::::::::::::::::::::::*%*102012]
    ⊇{100,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012]
    ⊇{101,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012]
    ⊇{102,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012]
    ⊇{110,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012]
    ⊇{111,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012]
    ⊇{112,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012]
    ⊇{120,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012]
    ⊇{121,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012]
    ⊇{122,102012}[*%;;;;;;;;;;;;;;;;*%*102012]
    ⊇{200,102012}[*%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*%*102012]
   ⊇{102012}[*102012]
  \
  'o/
    *102012
    ⊇{1,102012}["0*102012]
    ⊇{2,102012}["1*102012]
    ⊇{10,102012}["2*102012]
    ⊇{11,102012}["3*102012]
    ⊇{12,102012}["4*102012]
    ⊇{20,102012}["5*102012]
    ⊇{21,102012}["6*102012]
    ⊇{22,102012}["7*102012]
    ⊇{100,102012}["8*102012]
    ⊇{101,102012}["9*102012]
    ⊇{102,102012}["1"0*102012]
    ⊇{110,102012}["1"1*102012]
    ⊇{111,102012}["1"2*102012]
    ⊇{112,102012}["1"3*102012]
    ⊇{120,102012}["1"4*102012]
    ⊇{121,102012}["1"5*102012]
    ⊇{122,102012}["1"6*102012]
    ⊇{200,102012}["1"7*102012]
    ⊇{201,102012}["1"8*102012]
    ⊇{202,102012}["1"9*102012]
    ⊇{210,102012}["2"0*102012]
    ⊇{211,102012}["2"1*102012]
    ⊇{212,102012}["2"2*102012]
    ⊇{220,102012}["2"3*102012]
    ⊇{221,102012}["2"4*102012]
    ⊇{222,102012}["2"5*102012]
    ⊇{1000,102012}["2"6*102012]
    ⊇{1001,102012}["2"7*102012]
    ⊇{1002,102012}["2"8*102012]
    ⊇{1010,102012}["2"9*102012]
    ⊇{1011,102012}["3"0*102012]
    ⊇{1012,102012}["3"1*102012]
    ⊇{1020,102012}["3"2*102012]
    ⊇{1021,102012}["3"3*102012]
    ⊇{1022,102012}["3"4*102012]
    ⊇{1100,102012}["3"5*102012]
    ⊇{1101,102012}["3"6*102012]
    ⊇{1102,102012}["3"7*102012]
    ⊇{1110,102012}["3"8*102012]
    ⊇{1111,102012}["3"9*102012]
    ⊇{1112,102012}["4"0*102012]
    ⊇{1120,102012}["4"1*102012]
    ⊇{1121,102012}["4"2*102012]
    ⊇{1122,102012}["4"3*102012]
    ⊇{1200,102012}["4"4*102012]
    ⊇{1201,102012}["4"5*102012]
    ⊇{1202,102012}["4"6*102012]
    ⊇{1210,102012}["4"7*102012]
    ⊇{1211,102012}["4"8*102012]
    ⊇{1212,102012}["4"9*102012]
    ⊇{1220,102012}["5"0*102012]
    ⊇{1221,102012}["5"1*102012]
    ⊇{1222,102012}["5"2*102012]
    ⊇{2000,102012}["5"3*102012]
    ⊇{2001,102012}["5"4*102012]
    ⊇{2002,102012}["5"5*102012]
    ⊇{2010,102012}["5"6*102012]
    ⊇{2011,102012}["5"7*102012]
    ⊇{2012,102012}["5"8*102012]
    ⊇{2020,102012}["5"9*102012]
    ⊇{2021,102012}["6"0*102012]
    ⊇{2022,102012}["6"1*102012]
    ⊇{2100,102012}["6"2*102012]
    ⊇{2101,102012}["6"3*102012]
    ⊇{2102,102012}["6"4*102012]
    ⊇{2110,102012}["6"5*102012]
    ⊇{2111,102012}["6"6*102012]
    ⊇{2112,102012}["6"7*102012]
    ⊇{2120,102012}["6"8*102012]
    ⊇{2121,102012}["6"9*102012]
    ⊇{2122,102012}["7"0*102012]
    ⊇{2200,102012}["7"1*102012]
    ⊇{2201,102012}["7"2*102012]
    ⊇{2202,102012}["7"3*102012]
    ⊇{2210,102012}["7"4*102012]
    ⊇{2211,102012}["7"5*102012]
    ⊇{2212,102012}["7"6*102012]
    ⊇{2220,102012}["7"7*102012]
    ⊇{2221,102012}["7"8*102012]
    ⊇{2222,102012}["7"9*102012]
    ⊇{10000,102012}["8"0*102012]
    ⊇{10001,102012}["8"1*102012]
    ⊇{10002,102012}["8"2*102012]
    ⊇{10010,102012}["8"3*102012]
    ⊇{10011,102012}["8"4*102012]
    ⊇{10012,102012}["8"5*102012]
    ⊇{10020,102012}["8"6*102012]
    ⊇{10021,102012}["8"7*102012]
    ⊇{10022,102012}["8"8*102012]
    ⊇{10100,102012}["8"9*102012]
    ⊇{10101,102012}["9"0*102012]
    ⊇{10102,102012}["9"1*102012]
    ⊇{10110,102012}["9"2*102012]
    ⊇{10111,102012}["9"3*102012]
    ⊇{10112,102012}["9"4*102012]
    ⊇{10120,102012}["9"5*102012]
    ⊇{10121,102012}["9"6*102012]
    ⊇{10122,102012}["9"7*102012]
    ⊇{10200,102012}["9"8*102012]
    ⊇{10201,102012}["9"9*102012]
    ⊇{10202,102012}["1"0"0*102012]
    ⊇{10210,102012}["1"0"1*102012]
    ⊇{10211,102012}["1"0"2*102012]
    ⊇{10212,102012}["1"0"3*102012]
    ⊇{10220,102012}["1"0"4*102012]
    ⊇{10221,102012}["1"0"5*102012]
    ⊇{10222,102012}["1"0"6*102012]
    ⊇{11000,102012}["1"0"7*102012]
    ⊇{11001,102012}["1"0"8*102012]
    ⊇{11002,102012}["1"0"9*102012]
    ⊇{11010,102012}["1"1"0*102012]
    ⊇{11011,102012}["1"1"1*102012]
    ⊇{11012,102012}["1"1"2*102012]
    ⊇{11020,102012}["1"1"3*102012]
    ⊇{11021,102012}["1"1"4*102012]
    ⊇{11022,102012}["1"1"5*102012]
    ⊇{11100,102012}["1"1"6*102012]
    ⊇{11101,102012}["1"1"7*102012]
    ⊇{11102,102012}["1"1"8*102012]
    ⊇{11110,102012}["1"1"9*102012]
    ⊇{11111,102012}["1"2"0*102012]
    ⊇{11112,102012}["1"2"1*102012]
    ⊇{11120,102012}["1"2"2*102012]
    ⊇{11121,102012}["1"2"3*102012]
    ⊇{11122,102012}["1"2"4*102012]
    ⊇{11200,102012}["1"2"5*102012]
    ⊇{11201,102012}["1"2"6*102012]
    ⊇{11202,102012}["1"2"7*102012]
    ⊇{11210,102012}["1"2"8*102012]
    ⊇{11211,102012}["1"2"9*102012]
    ⊇{11212,102012}["1"3"0*102012]
    ⊇{11220,102012}["1"3"1*102012]
    ⊇{11221,102012}["1"3"2*102012]
    ⊇{11222,102012}["1"3"3*102012]
    ⊇{12000,102012}["1"3"4*102012]
    ⊇{12001,102012}["1"3"5*102012]
    ⊇{12002,102012}["1"3"6*102012]
    ⊇{12010,102012}["1"3"7*102012]
    ⊇{12011,102012}["1"3"8*102012]
    ⊇{12012,102012}["1"3"9*102012]
    ⊇{12020,102012}["1"4"0*102012]
    ⊇{12021,102012}["1"4"1*102012]
    ⊇{12022,102012}["1"4"2*102012]
    ⊇{12100,102012}["1"4"3*102012]
    ⊇{12101,102012}["1"4"4*102012]
    ⊇{12102,102012}["1"4"5*102012]
    ⊇{12110,102012}["1"4"6*102012]
    ⊇{12111,102012}["1"4"7*102012]
    ⊇{12112,102012}["1"4"8*102012]
    ⊇{12120,102012}["1"4"9*102012]
    ⊇{12121,102012}["1"5"0*102012]
    ⊇{12122,102012}["1"5"1*102012]
    ⊇{12200,102012}["1"5"2*102012]
    ⊇{12201,102012}["1"5"3*102012]
    ⊇{12202,102012}["1"5"4*102012]
    ⊇{12210,102012}["1"5"5*102012]
    ⊇{12211,102012}["1"5"6*102012]
    ⊇{12212,102012}["1"5"7*102012]
    ⊇{12220,102012}["1"5"8*102012]
    ⊇{12221,102012}["1"5"9*102012]
    ⊇{12222,102012}["1"6"0*102012]
    ⊇{20000,102012}["1"6"1*102012]
    ⊇{20001,102012}["1"6"2*102012]
    ⊇{20002,102012}["1"6"3*102012]
    ⊇{20010,102012}["1"6"4*102012]
    ⊇{20011,102012}["1"6"5*102012]
    ⊇{20012,102012}["1"6"6*102012]
    ⊇{20020,102012}["1"6"7*102012]
    ⊇{20021,102012}["1"6"8*102012]
    ⊇{20022,102012}["1"6"9*102012]
    ⊇{20100,102012}["1"7"0*102012]
    ⊇{20101,102012}["1"7"1*102012]
    ⊇{20102,102012}["1"7"2*102012]
    ⊇{20110,102012}["1"7"3*102012]
    ⊇{20111,102012}["1"7"4*102012]
    ⊇{20112,102012}["1"7"5*102012]
    ⊇{20120,102012}["1"7"6*102012]
    ⊇{20121,102012}["1"7"7*102012]
    ⊇{20122,102012}["1"7"8*102012]
    ⊇{20200,102012}["1"7"9*102012]
    ⊇{20201,102012}["1"8"0*102012]
    ⊇{20202,102012}["1"8"1*102012]
    ⊇{20210,102012}["1"8"2*102012]
    ⊇{20211,102012}["1"8"3*102012]
    ⊇{20212,102012}["1"8"4*102012]
    ⊇{20220,102012}["1"8"5*102012]
    ⊇{20221,102012}["1"8"6*102012]
    ⊇{20222,102012}["1"8"7*102012]
    ⊇{21000,102012}["1"8"8*102012]
    ⊇{21001,102012}["1"8"9*102012]
    ⊇{21002,102012}["1"9"0*102012]
    ⊇{21010,102012}["1"9"1*102012]
    ⊇{21011,102012}["1"9"2*102012]
    ⊇{21012,102012}["1"9"3*102012]
    ⊇{21020,102012}["1"9"4*102012]
    ⊇{21021,102012}["1"9"5*102012]
    ⊇{21022,102012}["1"9"6*102012]
    ⊇{21100,102012}["1"9"7*102012]
    ⊇{21101,102012}["1"9"8*102012]
    ⊇{21102,102012}["1"9"9*102012]
    ⊇{21110,102012}["2"0"0*102012]
    ⊇{21111,102012}["2"0"1*102012]
    ⊇{21112,102012}["2"0"2*102012]
    ⊇{21120,102012}["2"0"3*102012]
    ⊇{21121,102012}["2"0"4*102012]
    ⊇{21122,102012}["2"0"5*102012]
    ⊇{21200,102012}["2"0"6*102012]
    ⊇{21201,102012}["2"0"7*102012]
    ⊇{21202,102012}["2"0"8*102012]
    ⊇{21210,102012}["2"0"9*102012]
    ⊇{21211,102012}["2"1"0*102012]
    ⊇{21212,102012}["2"1"1*102012]
    ⊇{21220,102012}["2"1"2*102012]
    ⊇{21221,102012}["2"1"3*102012]
    ⊇{21222,102012}["2"1"4*102012]
    ⊇{22000,102012}["2"1"5*102012]
    ⊇{22001,102012}["2"1"6*102012]
    ⊇{22002,102012}["2"1"7*102012]
    ⊇{22010,102012}["2"1"8*102012]
    ⊇{22011,102012}["2"1"9*102012]
    ⊇{22012,102012}["2"2"0*102012]
    ⊇{22020,102012}["2"2"1*102012]
    ⊇{22021,102012}["2"2"2*102012]
    ⊇{22022,102012}["2"2"3*102012]
    ⊇{22100,102012}["2"2"4*102012]
    ⊇{22101,102012}["2"2"5*102012]
    ⊇{22102,102012}["2"2"6*102012]
    ⊇{22110,102012}["2"2"7*102012]
    ⊇{22111,102012}["2"2"8*102012]
    ⊇{22112,102012}["2"2"9*102012]
    ⊇{22120,102012}["2"3"0*102012]
    ⊇{22121,102012}["2"3"1*102012]
    ⊇{22122,102012}["2"3"2*102012]
    ⊇{22200,102012}["2"3"3*102012]
    ⊇{22201,102012}["2"3"4*102012]
    ⊇{22202,102012}["2"3"5*102012]
    ⊇{22210,102012}["2"3"6*102012]
    ⊇{22211,102012}["2"3"7*102012]
    ⊇{22212,102012}["2"3"8*102012]
    ⊇{22220,102012}["2"3"9*102012]
    ⊇{22221,102012}["2"4"0*102012]
    ⊇{22222,102012}["2"4"1*102012]
    ⊇{100000,102012}["2"4"2*102012]
    ⊇{100001,102012}["2"4"3*102012]
    ⊇{100002,102012}["2"4"4*102012]
    ⊇{100010,102012}["2"4"5*102012]
    ⊇{100011,102012}["2"4"6*102012]
    ⊇{100012,102012}["2"4"7*102012]
    ⊇{100020,102012}["2"4"8*102012]
    ⊇{100021,102012}["2"4"9*102012]
    ⊇{100022,102012}["2"5"0*102012]
    ⊇{100100,102012}["2"5"1*102012]
    ⊇{100101,102012}["2"5"2*102012]
    ⊇{100102,102012}["2"5"3*102012]
    ⊇{100110,102012}["2"5"4*102012]
    ⊇{100111,102012}["2"5"5*102012]
    ⊇{100112,102012}["2"5"6*102012]
    ⊇{100120,102012}["2"5"7*102012]
    ⊇{100121,102012}["2"5"8*102012]
    ⊇{100122,102012}["2"5"9*102012]
    ⊇{100200,102012}["2"6"0*102012]
    ⊇{100201,102012}["2"6"1*102012]
    ⊇{100202,102012}["2"6"2*102012]
    ⊇{100210,102012}["2"6"3*102012]
    ⊇{100211,102012}["2"6"4*102012]
    ⊇{100212,102012}["2"6"5*102012]
    ⊇{100220,102012}["2"6"6*102012]
    ⊇{100221,102012}["2"6"7*102012]
    ⊇{100222,102012}["2"6"8*102012]
    ⊇{101000,102012}["2"6"9*102012]
    ⊇{101001,102012}["2"7"0*102012]
    ⊇{101002,102012}["2"7"1*102012]
    ⊇{101010,102012}["2"7"2*102012]
    ⊇{101011,102012}["2"7"3*102012]
    ⊇{101012,102012}["2"7"4*102012]
    ⊇{101020,102012}["2"7"5*102012]
    ⊇{101021,102012}["2"7"6*102012]
    ⊇{101022,102012}["2"7"7*102012]
    ⊇{101100,102012}["2"7"8*102012]
    ⊇{101101,102012}["2"7"9*102012]
    ⊇{101102,102012}["2"8"0*102012]
    ⊇{101110,102012}["2"8"1*102012]
    ⊇{101111,102012}["2"8"2*102012]
    ⊇{101112,102012}["2"8"3*102012]
    ⊇{101120,102012}["2"8"4*102012]
    ⊇{101121,102012}["2"8"5*102012]
    ⊇{101122,102012}["2"8"6*102012]
    ⊇{101200,102012}["2"8"7*102012]
    ⊇{101201,102012}["2"8"8*102012]
    ⊇{101202,102012}["2"8"9*102012]
    ⊇{101210,102012}["2"9"0*102012]
    ⊇{101211,102012}["2"9"1*102012]
    ⊇{101212,102012}["2"9"2*102012]
    ⊇{101220,102012}["2"9"3*102012]
    ⊇{101221,102012}["2"9"4*102012]
    ⊇{101222,102012}["2"9"5*102012]
    ⊇{102000,102012}["2"9"6*102012]
    ⊇{102001,102012}["2"9"7*102012]
    ⊇{102002,102012}["2"9"8*102012]
    ⊇{102010,102012}["2"9"9*102012]
    ⊇{102012}[*102012]
  \
  './*102011\
]

SQL

In order to use this program, another program (possibly written in C or some other programming language) must make the INPUT and OUTPUT views to do the necessary things.

PRAGMA RECURSIVE TRIGGERS = 1;

CREATE TABLE `DEADFISH` (`VALUE` INT);

INSERT INTO `DEADFISH` VALUES (0);

CREATE VIEW `INPUT` AS SELECT '' AS `INPUT`;

CREATE VIEW `OUTPUT` AS SELECT '' AS `OUTPUT`;

CREATE TRIGGER `INCREMENT` INSTEAD OF INSERT ON `INPUT` WHEN NEW.`INPUT` = 'i' BEGIN
  UPDATE `DEADFISH` SET `VALUE` = `VALUE` + 1;
  UPDATE `DEADFISH` SET `VALUE` = 0 WHERE `VALUE` = 256;
END;

CREATE TRIGGER `DECREMENT` INSTEAD OF INSERT ON `INPUT` WHEN NEW.`INPUT` = 'd' BEGIN
  UPDATE `DEADFISH` SET `VALUE` = `VALUE` - 1 WHERE `VALUE` > 0;
  UPDATE `DEADFISH` SET `VALUE` = 0 WHERE `VALUE` = 256;
END;

CREATE TRIGGER `SQUARE` INSTEAD OF INSERT ON `INPUT` WHEN NEW.`INPUT` = 's' BEGIN
  UPDATE `DEADFISH` SET `VALUE` = `VALUE` * `VALUE`;
  UPDATE `DEADFISH` SET `VALUE` = 0 WHERE `VALUE` = 256;
END;

CREATE TRIGGER `OUTPUT` INSTEAD OF INSERT ON `INPUT` WHEN NEW.`INPUT` = 'o' BEGIN
  INSERT INTO `OUTPUT` SELECT `VALUE` AS `OUTPUT` FROM `DEADFISH`;
END;

Stackstack

0 ">> " dup while
    dup print swap inputstr

    dup "d" eq if swap   1 - endif
    dup "i" eq if swap   1 + endif
    dup "s" eq if swap dup * endif
    dup "o" eq if swap dup tostring 10 char concat print endif

    dup  -1 eq if pop 0 endif
    dup 256 eq if pop 0 endif

    -3 roll pop
dup endwhile

Standard ML

Supports both the IDSO and XKCD variants. Use ^D or ^C to quit.

(* deadfish.sml: Simple Deadfish interpreter in Standard ML. *)

fun id x = x

fun apply (f, x) = f(x)

fun fixAcc ~1  = 0
  | fixAcc 256 = 0
  | fixAcc n   = n

fun inc    (output, acc) = (output, fixAcc(acc + 1))
fun dec    (output, acc) = (output, fixAcc(acc - 1))
fun square (output, acc) = (output, fixAcc(acc * acc))
fun output (output, acc) = (acc::output, acc)

fun charToFun #"i" = inc
  | charToFun #"x" = inc
  | charToFun #"d" = dec
  | charToFun #"s" = square
  | charToFun #"k" = square
  | charToFun #"o" = output
  | charToFun #"c" = output
  | charToFun _    = id

local
	fun interpret seed program = foldl apply seed (map charToFun (explode program))
in
	fun main _ =
	    let val is  = TextIO.stdIn
	        and acc = ref 0
	        fun display (output, acc) =
	            ((app (fn n => print(Int.toString n ^ "\n")) (rev output));
	             (output, acc))
	    in while (print ">> "; not (TextIO.endOfStream is))
	       do acc := #2 (display (interpret ([], !acc) (valOf(TextIO.inputLine is))))
	    end

	val interpret = rev o #1 o interpret ([], 0)
end

StaPLe

eval;dup;
[eval;dup;if;swap;[R0;];||;!;+;1;swap;!;-;256;dup;pop;dup;push;ife;swap;
[drop;pop;+;1;push;];swap;[ife;swap;[drop;pop;-;1;push;];swap;[ife;swap;
[drop;pop;*;dup;push;];swap;[ife;swap;[putc;10;put;pop;dup;push;];
swap;[putc;10;];==;"o;];==;"s;dup;];==;"d;dup;];==;"i;dup;getc;];R0;

Staq

&iiqqq&{o:&iiiqi;@X}{T-!@_x}{i_iT}{D_d}{d?DT}{sqT}{ks}{xi}{co}{>id}

Allows the command sets of both variations.

*><>

r01[D63.
>:884**=  ?!\~0v
^v0~u!?=-10:<u <
^>  OD~l0=?!\;
^+1I/!?="i":/
^   \:"d"=?!\I1-
^*:I/!?="s":/
^   \:"o"=?!;I:aon

Stlang

Reads one line of input.

M 0 (i /r f \
fn f .<+;h d ;t f \
fn f: .$ \
fn d \
fn d:i .$<>I c <> \
fn d:d .$<>D c <> \
fn d:s .$<><+* c <> \
fn d:o .$<><+@<> \
fn c \
fn c:256 .$0(i \
fn c:-1 .$0(i \

stupidc

Input is defined as %PGM.

system(&BE6502);
include(&lcd);
include(&stupidc);
mem(%pgm, "Your program here");
def(%pos);
def(%a);

onreset({
  set(%pos, #0);
  set(%a, #0);
  $lcd.init(&2line);
  forever({
    choose(%pgm@%pos,
      #'i', { inc(%a); }, <255 rolls over to 0 so we don't need to check>

      #'d', {
        if (%a, { dec(%a); }); <Only allow it to be decremented if it's NOT equal to zero>
      },

      #'s', {
        if (?lt(%a, #16), { <Only allow it to be squared if it is less than 16, because 16*16=256.>
          set(%a, *mult(%a, %a));
         }, {
          set(%a, #0);
        });
      },

      #'p', {
        $lcd.printchar(%a);
      },

      &else, {
        $lcd.locate(&l2);
      }
    );
    inc(%a);
  });
});

stupidExpr

(result = {
 def:
  inp, str,
  c, [str: 1],
  pos, ulong,
  a, ubyte.zero /* automatically does zero-out behavior */
  ;
 (i = [input]);
 loop: {
  (c = [charof: inp, pos]);
  (pos ++ 1);
  choose:
   (c = "i"), { (a ++ 1); },
   (c = "d"), { (a -- 1); },
   (c = "s"), { (a = (a * a)); },
   (c = "p"), { print: [chr: a]; },
              { print: "\n"; }
  ;
  if: (pos > [len: inp]), { stop; };
 };
});

Surtic

I chose to have the deadfish code be stored within the string at the very beginning (between the single quotes), though simply accepting an input of a whole program would work with little modification. This example uses the test case that prints 288.

s0'diissisdo'c9-c10++++fc10[fc10[c10++]]c8++++++++++fc8[fc8[c3+c4+c5+c6+]c10+++c5+c6+]fc8[c8-]c3+++++fc4[c10-]c10++c6+c5+++++lc7:s0?b1(c1<c7)wb1[gc0:s0(c1)?b3(c0==c3)?b4(c0==c4)?b5(c0==c5)?b6(c0==c6)ib3{c2+}ib4{c2-}ib5{fc2[fc2[c8+]]fc2[c2-]fc8[c2+c8-]}ib6{noc2}?b7(c2==c9)?b8(c2==c10)ib7{c2+}ib8{fc2[c2-]}c1+?b1(c1<c7)]

TailDot

Accepts one command at the time

c,x,>>,v,x,i,x,v,x,e,x,i,28,e,x,d,37,e,x,s,46,e,x,o,53,j,1,a,a,1,e,a,256,57,j,1,s,a,1,e,a,-1,57,j,1,o,a,e,a,256,57,j,1,v,a,j,1,a,a,1,e,a,0,1,s,a,1,e,a,0,1,j,64

TAVERN

INCLUDE standard.inc

<RAM>

0 VARIABLE VALUE

HERE CONSTANT INPUT-TABLE
1 , 4 ALLOT

<ROM>

:START
  BEGIN
    || >> | INPUT-TABLE ACCEPT
    INPUT-TABLE 1 + @ IF
      INPUT-TABLE 2 + @ ?DUP IF
        EXECUTE
      ELSE
        CR
      THEN
    ELSE
      CR
    THEN
    VALUE @ 256 = VALUE @ -1 = OR IF 0 VALUE ! THEN
  AGAIN
;

:: VALUE INCR ; VOCAB I
:: VALUE DECR ; VOCAB D
:: VALUE @ DUP * VALUE ! ; VOCAB S
:: VALUE @ . CR ; VOCAB O
:: QUIT ; VOCAB H

TeX

% Deadfish interpreter in TeX

\catcode32=9\endlinechar=-1

\newcount\accumulator

\def\checkwrapping{
  \ifnum\accumulator=256\accumulator=0\fi
  \relax
  \ifnum\accumulator=-1\accumulator=0\fi
}

\def\I{
  \advance\accumulator by 1
  \checkwrapping
}

\def\D{
  \advance\accumulator by -1
  \checkwrapping
}

\def\S{
  \multiply\accumulator by \accumulator
  \checkwrapping
}

\def\O{
  \message{\the\accumulator}
}

\tracingonline=-1
\scrollmode

\def\Activate{
  \catcode105=13
  \catcode100=13
  \catcode115=13
  \catcode111=13
}

\catcode62=11

\def\Start{
  \escapechar=-1
  \loop
    \read16 to \>>
    \>>
  \iftrue\repeat
}

\Activate
\leti=\I
\letd=\D
\lets=\S
\leto=\O
\Start

TeXnicard

(Note: This is the old version of TeXnicard. The new version is entirely different; it is like a combination of SQL and PostScript, but using the mechanisms like TeX for text rendering rather than those of PostScript.)

To use this program, save it in the file called "deadfish.cards" and then type in "@I deadfish.cards" at the "E>" prompt. And then it change to "C>" prompt and it is ready for typing in commands of deadfish.

@. Deadfish implementation in TeXnicard.
[d[c0][]dixd256-[][0*][]ix[]]s0
(patterns)sP0
@S i
1+`0x
@S d
1-`0x
@S s
d*`0x
@S o
?s[]
@P patterns
<i
: i;
<d
: d;
<s
: s;
<o
: o;
@C main

This=That

shell=>> 
flag=1
while loop x=flag~~flag
print shell
input i
if loop a=i~~i
ac=ac plus 1
if loop a=end
if loop b=i~~d
ac=ac minus 1
if loop b=end
if loop c=i~~s
ac=ac times ac
if loop c=end
if loop d=i~~o
print ac
if loop d=end
if loop e=ac<0
ac=0
if loop e=end
if loop f=ac~~256
ac=0
if loop f=end
while loop x=end

Thue

Deadfish in Thue by Amb ::=
This implementation represents the value in binary. ::=
It does not convert binary to decimal for output. ::=
Fixed to support 256->0 by Oerjan ::=
| ::=|
$<00::=$<0
$<01::=$<1
$<0|::=$0*|
$<11::=$11*
$<1|::=$1*|
$<101::=$101*
$<10|::=$10*|
$<1001::=$1001*
$<100|::=$100*|
$<10001::=$10001*
$<1000|::=$1000*|
$<100001::=$100001*
$<10000|::=$10000*|
$<1000001::=$1000001*
$<100000|::=$100000*|
$<10000001::=$10000001*
$<1000000|::=$1000000*|
$<100000001::=$100000001*
$<10000000|::=$10000000*|
$<1000000000::=$1000000000*
$<1000000001::=$1000000001*
$<100000000|::=$0*|
><::=>*
0<::=<0
1<::=<1
*|i::=i|
*|d::=d|
*|s::=s|
*|o::=o|
*0::=0*
*1::=1*
0i::=<1
1i::=i0
$i::=$<1
1d::=<0
0d::=d1
$d1::=$d
$d|::=$0*|
0o::=o0
1o::=o1
$o::=$*#o
#::=~ 
*o0::=0*[o
[::=~0
*o1::=1*]o
]::=~1
*o|::=*|
0s::=s0
1s::=s1
0-::=-0
0+::=+0
1-::=-1
1+::=+1
$-::=0$
$+::=1$
$s::=$*s
*s0::=-0*s
*s1::=+1*s
*s|::=t|
0t::=t(0)
1t::=t(1)
$t::=$u
$u::=d$
>d1::=>d
>d$::=>$w
*$::=$uv
v(0)::=(0)v
v(1)::=(1)1v
v0::=0v
v1::=1v
v|::=|
w(0)::=%w
w(1)::=%w
w1::=1w
w|::=x|
%x::=x0
%1x::=x1
11x::=yx
1y::=y1
%y::=1%
$y::=$1%
$1x::=$<1
$x::=$<
?::=:::
::=
>$0*|?

Thutu

This stores data in unary, which explains its inefficiency and the length of one of the lines.

/=>=> =x/z=x/
*
  /=>=> =x/>
  /=1/=n=>=> =xse/
  /^i=xs(a*)e/=>=> =xs$1ae/
  /^d=xsa?(a*?)e/=>=> =xs$1e/
  /^s=xs(a*)a(b*)e/s=xs$1b$2e$1$2b/
  /^s=xs(b*)e(a*)b/s=xs$1e$2a/
  /^s=xs(b*)e(a*)$/=>=> =xs$2e/
  /^o=xs(a*)e$/o=xs$1v/
  /(=x.*[sbc])v/$1w0/
  /(=x.*[sbc])av/$1cw1/
  /(=x.*[sbc])aav/$1ccw2/
  /(=x.*[sbc])aaav/$1cccw3/
  /(=x.*[sbc])aaaav/$1ccccw4/
  /(=x.*[sbc])aaaaav/$1cccccw5/
  /(=x.*[sbc])aaaaaav/$1ccccccw6/
  /(=x.*[sbc])aaaaaaav/$1cccccccw7/
  /(=x.*[sbc])aaaaaaaav/$1ccccccccw8/
  /(=x.*[sbc])aaaaaaaaav/$1cccccccccw9/
  /(=x.*[sbc])aaaaaaaaaa(a*)v/$1bbbbbbbbbb$2v/
  /(=xsc*)bbbbbbbbbb(.*)w/$1ccccccccca$2w/
  /(=x.*)ab(.*w)/$1ba$2/
  /(=x.*)ac(.*w)/$1ca$2/
  /(=x.*)bc(.*w)/$1cb$2/
  /=xs([ca]*)aw/=xs$1av/
  /=xs(c*)w/=xs$1x/
  /=xs(c*)c(a*)x/=xs$1a$2x/
  /^o=xs(a*)x(.*)$/$2=n=>=> =xs$1e/
  /^.*=x/=n=>=> =x/
.
*
  /=xsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaae/se/
.

TI-68k

deadfish(src)
Prgm
Local acc
0->acc
Loop
Local cmd
left(src,1)->cmd
If acc=256 or acc<0 Then
0->acc
EndIf
If cmd="i" Then
acc+1->acc
ElseIf cmd="d" Then
acc-1->acc
ElseIf cmd="s" Then
acc^2->acc
ElseIf cmd="o" Then
Disp acc
EndIf
If dim(src)=1 or cmd="h" Then
Exit
EndIf
right(src,dim(src)-1)->src
EndLoop
EndPrgm

TI-BASIC

ClrHome
Disp "REGULAR DEADFISH","IDSO INTERPRETER
DelVar AInput Str1 //DelVar doesn't need a colon or newline after its argument; this is the same as "DelVar A:Input Str1"
For(B,1,length(Str1
sub(Str1,B,1
If Ans="O
Disp A
A(not(Ans="S")+A(Ans="S"))+(Ans="I")-(Ans="D
Ans(Ans<256 and Ans->A
End

Ti-Nspire Basic

Note: Since Ti-Nspire Basic doesn't support printing without making a new line, it stores the output then displays it at the end.

Define deadfish(program)=Prgm
  Local program,pos,acc,command,line
  line:=""
  acc:=0
  For pos,1,dim(program)
    command:=Mid(program,pos,1)
    
    If command="i" Then
      acc:=acc + 1
    ElseIf command="d" Then
      acc:=acc - 1
    ElseIf command="s" Then
      acc:=acc<sup>2</sup>
    ElseIf command="o" Then
      line:=line&char(acc)
    Else
      line:=line&char(13)
    EndIf
    If (acc<0) Or (acc>255) acc:=0
  EndFor
  Disp line
EndPrgm

Timers

~~ call deadfish
,(deadfish~)

~~ display prompt, get input and call process
'>> '{([.:]~)-128(^,~).(@process~)}

~~ process the input
'process'{
  1(;^<!| check256 checkneg default ?)
  1(;^< |~) ~~ exit process
  check256 {(^:#)256(^=!:|`~)256($$~)}
  checkneg {(^:#)2(^).(^\/<!:|`~).($$~)}
  default {(:[?]~)'idos'($~)-($"~)}
  i {(^:#)1(^+`~)}
  d {(^:#)1(^-`~)}
  o {(^#."~)}
  s {(^:#)?(^*`~)}
}

~~ setting up deadfish
deadfish {
  0(^loop) ~~ set initial value
  loop{('>> ')} ~~ loop prompt
}

Tosh

when flag clicked
delete all of Console
set accumulator to 0
set Read to 0
ask Code: and wait
repeat until <Read > (length of answer)>
	if <(letter Read of answer) = 'i'> or <(letter Read of answer) = 'x'> then
		change accumulator by 1
	end
	if <(letter Read of answer) = 'd'> then
		change accumulator by -1
	end
	if <<(letter Read of answer) = 's'> or <(letter Read of answer) = 'k'>> then
		set accumulator to (accumulator * accumulator)
	end
	if <<(letter Read of answer) = 'o'> or <(letter Read of answer) = 'c'>> then
		add accumulator to Console
	end
	if <<(accumulator) < 0> or <(accumulator) = 256>> then
		set accumulator to 0
	end
	change Read by 1
end

Turing

% Deadfish in Turing
% Implemented by Chris Pressey on August 4 2012,
% in the Deadfish Cafe in Winnipeg, Manitoba, Canada
% (Thus, this is also "Deadfish in Deadfish")

var accumulator : int
var command : string (1)

accumulator := 0
loop
    if accumulator = 256 or accumulator < 0 then
	accumulator := 0
    end if
    put ">> " ..
    get command
    if command = "i" then
	accumulator := accumulator + 1
    elsif command = "d" then
	accumulator := accumulator - 1
    elsif command = "s" then
	accumulator := accumulator * accumulator
    elsif command = "o" then
	put accumulator
    else
	put "Unrecognized command."
    end if
end loop

Uiua

# Experimental!
quote(⊂ : "0" /⊂⇌ ≡(⊂ "⌵(×≠256.×≠¯1.)" ⟨"+1 "|"-1 "|"×. "|"⟜&p"⟩)⊗:"idso" &sc)

Umka

This version has three main changes from the previous Umka (0.6) version: slightly shortened names, a small for...in syntax change so that the code works in Umka 1.2, and an (optional) default statement inside the switch to explicitly report unrecognized commands.

// Deadfish in Umka (1.2), version 2 -- dnm 2022-02-17, 2023-10-16

import "std.um"

var acc: int = 0

fn getIn(): str {
    s := ""
    for true {
        c := std.getchar()
        if c == '\n' { break }
        s += c
    }
    return s
}

fn main() {
    for true {       
        printf(">> ")
        input := getIn()
        for i, cmd in input {
            switch cmd {
                case 'i': acc++
                case 'd': acc--
                case 's': acc = acc * acc
                case 'o': printf("%i\n", acc)
                default : printf("Unrecognized command\n")
            }
            if acc == 256 || acc < 0 { acc = 0 }
        }
    }
}

Unlambda

This implementation uses Church numerals, which are essentially unary. Use large ones at your own risk.

````sii
 ``s``s`ks ``s``s`kskk
  `k ``s``s `d`k `````.>.>. @ic
      `k ``s``s``s``s`k?i`kii`k ``s``s`ks ``s`k`s`ks ``s`k`s`kk i `ki
          ``s``s``s``s`k?d`kii`k
           ``s``s``si
            `k ``s``s`ks ``s`k`si
                ``s`kk ``s``s`ks ``s`k`s`ks ``s`k`s`kk ``si`kk `ki
                ``s`kk ``si`kk
            `k`k`ki `k`ki
          ``s``s``s``s`k?o`kii`k
           ``sk ``s`kr ``s`k
            ```sii ``s `k `s``s``si
             `k ``s``s``si`kk
                 ``s`k`s``si`k
                  `k``si`k `k``si`k `k``si`k `k``si`k `k``si`k
                   `k``si`k `k``si`k `k``si`k `k``si`k k
                  ``s`kk ``s``s`ks``s`k`s`ks ``s`k`s`kk ``si`k`ki `ki
                 ``s`k`s``s`ks``s`k`sik ``s`kk``s`kk``si`k`ki
             `ki ``s`kk
              ``s``s`ks ``s`k`s`ks ``s`k`s`kk
               `k ``s``si`k.9 `k ``s``si`k.8 `k ``s``si`k.7 `k ``s``si`k.6 `k
                   ``s``si`k.5 `k ``s``si`k.4 `k ``s``si`k.3 `k ``s``si`k.2 `k
                   ``s``si`k.1 `k `k.0
               ``s`kk
                ``s``s`ks``s``s`ks
                 `k ``s`kc ``s`k`s`k`k`ki ``s``s`ks``s``s`ksk `k`k``si`ki `kk
                 ``s``s`kskk `ki
            ``s `k`s``s`ks k i
          ``s``s``s``s`k?s`kii`k ``s``s`ks k i
          ``si`kr
      ``s``s`kc
       ``s`k`s`k`ki
        ``s``s`ks ``s``s`ks ``s``s`ks k `k``s`k`sik
         `k `k ``````s``s`ks k ``s``s`ks k i
                ``s``s`ks k i ``s``s`ks k i
                k ``si`ki
         `k ``s`kd ``si `k`k`ki
       i
 `ki

Unofficial MagicKit Assembler

This is probably the longest one (due to so many things that aren't built-in, so it has to implement all of them). Note, it contains tabs which are necessary to compile properly. You can download the compiled file, source codes, and ".NES.INI" in the external resources section.

To use, push a key "I", "D", "S", or "O" at the prompt. A line break is automatically added after each command; all keys other than "I", "D", "S" and "O" (including the DELETE and RETURN key) are ignored; all buttons on both gamepads are also ignored, and so is the microphone. (If you want to restart the program, push the RESET button on the console.)

; Deadfish implementation for Nintendo Famicom
	inesprg 1 ; 16K PRG ROM
	ineschr 1 ; 8K CHR ROM
	inesmir 1 ; vertical mirroring
	inesmap 0 ; NROM

	zp
digits	ds 8
spare	ds 1
scroll1	ds 1
scroll2	ds 1
blink1	ds 1
blink2	ds 1
csrlin	ds 1
temp2	ds 1
temp3	ds 1
temp4	ds 1
multacc	ds 17

	code

	bank 0

	; Sprites
	org $C000
oamdata	db 215,16,0,32 ; Cursor
	db 223,15,0,$08, 223,15,0,$10, 223,15,0,$18, 223,15,0,$20 ; First hidden row
	db 223,15,0,$28, 223,15,0,$30, 223,15,0,$38, 223,15,0,$40
	db 231,15,0,$08, 231,15,0,$10, 231,15,0,$18, 231,15,0,$20 ; Second hidden row
	db 231,15,0,$28, 231,15,0,$30, 231,15,0,$38, 231,15,0,$40

	; Multiplication table
	org $C100
muones	db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
	db 0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5
	db 0,2,4,6,8,0,2,4,6,8,0,2,4,6,8,0
	db 0,3,6,9,2,5,8,1,4,7,0,3,6,9,2,5
	db 0,4,8,2,6,0,4,8,2,6,0,4,8,2,6,0
	db 0,5,0,5,0,5,0,5,0,5,0,5,0,5,0,5
	db 0,6,2,8,4,0,6,2,8,4,0,6,2,8,4,0
	db 0,7,4,1,8,5,2,9,6,3,0,7,4,1,8,5
	db 0,8,6,4,2,0,8,6,4,2,0,8,6,4,2,0
	db 0,9,8,7,6,5,4,3,2,1,0,9,8,7,6,5
mutens	db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ;0
	db 0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1 ;1
	db 0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,3 ;2
	db 0,0,0,0,1,1,1,2,2,2,3,3,3,3,4,4 ;3
	db 0,0,0,1,1,2,2,2,3,3,4,4,4,5,5,6 ;4
	db 0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7 ;5
	db 0,0,1,1,2,3,3,4,4,5,6,6,7,8,9,9 ;6
	db 0,0,1,2,2,3,4,4,5,6,7,7,8,9,9,0 ;7
	db 0,0,1,2,3,4,4,5,6,7,8,8,9,0,1,2 ;8
	db 0,0,1,2,3,4,5,6,7,8,9,9,0,1,2,3 ;9
	;; 0 1 2 3 4 5 6 7 8 9 A B C D E F

	; Addition table
adones	db 0,1,2,3,4,5,6,7,8,9
	db 0,1,2,3,4,5,6,7,8,9
	db 0,1,2,3,4,5,6,7,8,9
	db 0,1,2,3,4,5,6,7,8,9
	db 0,1,2,3,4,5,6,7,8,9
	db 0,1,2,3,4,5,6,7,8,9
	db 0,1,2,3,4,5,6,7,8,9
	db 0,1,2,3,4,5,6,7,8,9
	db 0,1,2,3,4,5,6,7,8,9
	db 0,1,2,3,4,5,6,7,8,9
adtens	db 0,0,0,0,0,0,0,0,0,0
	db 1,1,1,1,1,1,1,1,1,1
	db 2,2,2,2,2,2,2,2,2,2
	db 3,3,3,3,3,3,3,3,3,3
	db 4,4,4,4,4,4,4,4,4,4
	db 5,5,5,5,5,5,5,5,5,5
	db 6,6,6,6,6,6,6,6,6,6
	db 7,7,7,7,7,7,7,7,7,7
	db 8,8,8,8,8,8,8,8,8,8
	db 9,9,9,9,9,9,9,9,9,9

	; =256 table
eq256	db 6,5,2,0,0,0,0,0

	bank 1
	org $E000

	; Initialize APU/PPU/CPU
reset	sei
	ldx #$FF
	txs
	inx
	stx $2000
	stx $4015
	bit $2002 ; Clear VBL
vwait1	bit $2002
	bpl vwait1
vwait2	bit $2002
	bpl vwait2
	stx $2000
	stx $2001 ; Disable PPU

	; Initialize RAM
	ldy #csrlin
initram	stx <0,y
	dey
	bpl initram
	lda #216
	sta <scroll2

	; Initialize palette
	lda #$3F
	sta $2006
	stx $2006
	ldy #$0A
initpal	sta $2007
	stx $2007
	dey
	bne initpal

	; Clear screen
	lda #$20
	sta $2006
	stx $2006
	lda #$0F
clrscr	sta $2007
	sta $2007
	sta $2007
	sta $2007
	dex
	bne clrscr

	; Display prompt
prompt	ldx #$00
	stx $2000
	stx $2001
	jsr newline
	lda #$0A
	sta $2007
	sta $2007
	lda #$0F
	sta $2007
	sta $2007
	sta $2007
	sta $2007
	sta $2007
	sta $2007
	lda #$80
	sta $2000

	; Wait until all keys are not pushed
keywait	lda #8
	sta <csrlin
	ldy #$05
	ldx #$04
	sty $4016
	iny
keyw1	stx $4016
	lda $4017
	and #$1E
	eor #$1E
	bne keywait
	sty $4016
	lda $4017
	and #$1E
	eor #$1E
	bne keywait
	dec <csrlin
	bne keyw1

	; Read keyboard
keyloop ldy #$05
	ldx #$04
	sty $4016
	iny
	stx $4016
	sty $4016
	stx $4016 ; Skip row 0
	sty $4016
	stx $4016 ; Skip row 1
	lda $4017
	and #$04
	beq keyo
	sty $4016
	stx $4016 ; Skip row 2
	lda $4017
	and #$04
	beq keyi
	sty $4016
	stx $4016 ; Skip row 3
	sty $4016
	stx $4016 ; Skip row 4
	lda $4017
	and #$10
	beq keyd
	sty $4016
	stx $4016 ; Skip row 5
	lda $4017
	and #$08
	beq keys
	jmp keyloop

keyo	lda #$0E
	jsr letter
	jmp cmdo

keyi	lda #$0B
	jsr letter
	jmp cmdi

keyd	lda #$0C
	jsr letter
	jmp cmdd

keys	lda #$0D
	jsr letter
	jmp cmds

	; Output
cmdo	jsr newline
	lda #$0F
	sta <csrlin
	ldy #7
out1	lda 0,y
	cpy #0
	beq out2
	cmp #0
	beq out3
out2	stx <csrlin
out3	eor <csrlin
	sta $2007 
	dey
	bpl out1
	jmp prompt

	; Increment
cmdi	stx <spare ; Clear guard digit
incr1	inc <0,x
	lda <0,x
	cmp #10
	bne chk256
	lda #0
	sta <0,x
	inx
	bne incr1
chk256	ldx #0
incr2	lda <0,x
	cmp eq256,x
	bne incr3 ; It isn't "256"
	inx
	cpx #8
	bne incr2
	sta <0
	sta <1
	sta <2
incr3	jmp prompt

	; Decrement
cmdd	lda <0,x
	bne decr1
	inx
	cpx #$08
	bne cmdd
	jmp prompt ; It is already zero
decr1	ldx #$00
decr2	lda <0,x
	beq decr3
	dec <0,x
	jmp chk256 ; Now check if equal to 256
decr3	lda #9
	sta <0,x
	inx
	bne decr2

	; Square
cmds	stx <spare ; Clear guard digit
	ldy #16
squ1	stx <multacc,y ; Clear multiplication accumulator memory
	dey
	bpl squ1
	ldy #7
squ2	ldx #7
squ3	lda <0,x
	sta <csrlin
	lda 0,y
	asl a
	asl a
	asl a
	asl a
	eor <csrlin
	sty <csrlin
	tay
	lda muones,y
	sta <temp2 ; Ones digit
	lda mutens,y
	sta <temp4 ; Tens digit
	stx <temp3
	lda <csrlin ; Position of a digit
	clc
	adc <temp3 ; Position of another digit
	tay
	lda <temp2
	adc multacc,y
	sta multacc,y
	lda <temp4
	clc
	adc multacc+1,y
	sta multacc+1,y
	ldy <csrlin
	dex
	bpl squ3
	dey
	bpl squ2
	; Now conversion into base ten proper digits
	inx
	stx <temp2 ; Carry
squ4	lda <multacc,x
	clc
	adc <temp2
	tay
	lda adones,y
	sta <0,x
	lda adtens,y
	sta <temp2
	inx
	cpx #8
	bne squ4
	jmp chk256 ; Check if equal to 256

	; New line routine (expects X=0)
newline	lda <scroll1
	clc
	adc #8
	cmp #240
	bne nscrz1
	txa
nscrz1	sta <scroll1
	lda <scroll2
	clc
	adc #8
	cmp #240
	bne nscrz2
	txa
nscrz2	sta <scroll2
	ldy #$08
	sty <csrlin
	asl a
	rol <csrlin
	asl a
	rol <csrlin
	ldy <csrlin
	sty $2006
	ora #$01
	sta $2006
	rts

	; Write letter to screen (A=letter to write)
letter	pha
	ldx #$00
	stx $2000
	stx $2001
	lda <scroll2
	jsr nscrz2
	lda #$0A
	sta $2007
	sta $2007
	lda #$0F
	sta $2007
	pla
	sta $2007
	rts

	; NMI handler
nmi	pha

	; Reset latch
	bit $2002

	; Cursor blink
	lda #$3F
	sta $2006
	lda #$13
	sta $2006
	inc <blink1
	cmp <blink1
	bne noblink
	lda <blink2
	eor #$1D
	sta $2007
	sta <blink2
	lda #$00
	sta <blink1

	; Scroll
noblink	lda #$00
	sta $2006
	sta $2006
	sta $2005
	lda <scroll1
	sta $2005

	; OAM
	lda #$C0
	sta $4014

	; Enable rendering
	lda #$1E
	sta $2001

	; Done
	pla
	rti

	; Vectors
	org $FFFA
	dw nmi,reset,0

	; Pattern table
	bank 2
	org $0000

	;0
	defchr $00011100,\
	       $00100110,\
	       $01100011,\
	       $01100011,\
	       $01100011,\
	       $00110010,\
	       $00011100,\
	       $00000000

	;1
	defchr $00001100,\
	       $00011100,\
	       $00001100,\
	       $00001100,\
	       $00001100,\
	       $00001100,\
	       $00111111,\
	       $00000000

	;2
	defchr $00111110,\
	       $01100011,\
	       $00000111,\
	       $00011110,\
	       $00111100,\
	       $01110000,\
	       $01111111,\
	       $00000000

	;3
	defchr $00111111,\
	       $00000110,\
	       $00001100,\
	       $00011110,\
	       $00000011,\
	       $01100011,\
	       $00111110,\
	       $00000000

	;4
	defchr $00001110,\
	       $00011110,\
	       $00110110,\
	       $01100110,\
	       $01111111,\
	       $00000110,\
	       $00000110,\
	       $00000000

	;5
	defchr $01111110,\
	       $01100000,\
	       $01111110,\
	       $00000011,\
	       $00000011,\
	       $01100011,\
	       $00111110,\
	       $00000000

	;6
	defchr $00011110,\
	       $00110000,\
	       $01100000,\
	       $01111110,\
	       $01100011,\
	       $01100011,\
	       $00111110,\
	       $00000000

	;7
	defchr $01111111,\
	       $01100011,\
	       $00000110,\
	       $00001100,\
	       $00011000,\
	       $00011000,\
	       $00011000,\
	       $00000000

	;8
	defchr $00111100,\
	       $01100010,\
	       $01110010,\
	       $00111100,\
	       $01001111,\
	       $01000011,\
	       $00111110,\
	       $00000000

	;9
	defchr $00111110,\
	       $01100011,\
	       $01100011,\
	       $00111111,\
	       $00000011,\
	       $00000110,\
	       $00111100,\
	       $00000000

	;>
	defchr $00110000,\
	       $00011000,\
	       $00001100,\
	       $00000110,\
	       $00001100,\
	       $00011000,\
	       $00110000,\
	       $00000000

	;I
	defchr $01111110,\
	       $00011000,\
	       $00011000,\
	       $00011000,\
	       $00011000,\
	       $00011000,\
	       $01111110,\
	       $00000000

	;D
	defchr $01111100,\
	       $01100110,\
	       $01100011,\
	       $01100011,\
	       $01100011,\
	       $01100110,\
	       $01111100,\
	       $00000000

	;S
	defchr $00111110,\
	       $01100011,\
	       $01100000,\
	       $00111110,\
	       $00000011,\
	       $01100011,\
	       $00111110,\
	       $00000000

	;O
	defchr $00111110,\
	       $01100011,\
	       $01100011,\
	       $01100011,\
	       $01100011,\
	       $01100011,\
	       $00111110,\
	       $00000000

	;blank
	defchr $22222222,\
	       $22222222,\
	       $22222222,\
	       $22222222,\
	       $22222222,\
	       $22222222,\
	       $22222222,\
	       $22222222

	;cursor
	defchr $00000000,\
	       $00303030,\
	       $00030300,\
	       $00303030,\
	       $00030300,\
	       $00303030,\
	       $00000000,\
	       $00000000

Uxn

\\ Deadfish in Uxn
\\ (use in non-GUI mode)

|0100
  #0000 STH2k
  [; #10 DEO2 BRK ]@

\\ Change 256 to 0
  DUP2 #0100 NEQ2
  [? POP2 STH2rk ]@

\\ Check input
  #12 DEI
  DUP LIT "i EQU ,i JCN
  DUP LIT "d EQU ,d JCN
  DUP LIT "s EQU ,s JCN
  LIT "o EQU ,o JCN BRK

@i
  POP INC2 BRK

@d
  POP ORAk STHrk NEQk ROT POP SUB2 BRK

@s
  POP DUP2 MUL2 BRK

@o
  DUP2
  [@
    #000a DIV2k STH2k MUL2 SUB2
    STH2 SWP2r STH2r
    NIPr LITr 30 ADDr
  ORAk ]?
  POP2
  [@ LITr 18 DEOr STHrk ]?
  #0a18 DEO BRK

Hex dump:

a0 00 00 af a0 01 0b 80  10 37 00 26 a0 01 00 29
20 00 02 22 ef 80 12 16  06 80 69 08 80 15 0d 06
80 64 08 80 11 0d 06 80  73 08 80 12 0d 80 6f 08
80 10 0d 00 02 21 00 02  9d cf 89 05 02 39 00 02
26 3a 00 26 a0 00 0a bb  af 3a 39 2f 64 6f 43 c0
30 58 9d 20 ff ee 22 c0  18 57 cf 20 ff f9 a0 0a
18 17 00 


Uyjhmn n

DECLARE THE NEW VARIABLE x
OPEN THE VARIABLE x
ASSIGN 0 TO THE OPEN VARIABLE
DECLARE THE NEW VARIABLE i
OPEN THE VARIABLE i
ASSIGN 105 TO THE OPEN VARIABLE
DECLARE THE NEW VARIABLE d
OPEN THE VARIABLE d
ASSIGN 100 TO THE OPEN VARIABLE
DECLARE THE NEW VARIABLE s
OPEN THE VARIABLE s
ASSIGN 115 TO THE OPEN VARIABLE
DECLARE THE NEW VARIABLE o
OPEN THE VARIABLE o
ASSIGN 111 TO THE OPEN VARIABLE
DECLARE THE NEW VARIABLE one
OPEN THE VARIABLE one
ASSIGN 1 TO THE OPEN VARIABLE
DECLARE THE NEW VARIABLE minusone
OPEN THE VARIABLE minusone
ASSIGN -1 TO THE OPEN VARIABLE
DECLARE THE NEW VARIABLE twohundredfiftysix
OPEN THE VARIABLE twohundredfiftysix
ASSIGN 256 TO THE OPEN VARIABLE
DECLARE THE NEW VARIABLE cmd
DEFINE THE NEW LABEL main
OPEN THE VARIABLE x
JUMP TO nottwohundredfiftysix IF x IS GREATER THAN twohundredfiftysix
JUMP TO nottwohundredfiftysix IF x IS LESS THAN twohundredfiftysix
ASSIGN 0 TO THE OPEN VARIABLE
DEFINE THE NEW LABEL nottwohundredfiftysix
JUMP TO notminusone IF x IS GREATER THAN minusone
ASSIGN 0 TO THE OPEN VARIABLE
DEFINE THE NEW LABEL notminusone
PRINT THE CHARACTER WITH THE ASCII VALUE 62
PRINT THE CHARACTER WITH THE ASCII VALUE 62
PRINT THE CHARACTER WITH THE ASCII VALUE 32
OPEN THE VARIABLE cmd
GET INPUT AND STORE INTO OPEN VARIABLE AS A CHARACTER
JUMP TO increment IF cmd IS EQUAL TO i
JUMP TO decrement IF cmd IS EQUAL TO d
JUMP TO square IF cmd IS EQUAL TO s
JUMP TO output IF cmd IS EQUAL TO o
PRINT THE CHARACTER WITH THE ASCII VALUE 10
JUMP TO main if x IS EQUAL TO x
DEFINE THE NEW LABEL increment
OPEN THE VARIABLE x
ADD one TO THE OPEN VARIABLE
JUMP TO main IF x IS EQUAL TO x
DEFINE THE NEW LABEL decrement
OPEN THE VARIABLE x
ADD minusone TO THE OPEN VARIABLE
JUMP TO main IF x IS EQUAL TO x
DEFINE THE NEW LABEL square
OPEN THE VARIABLE x
MULTIPLY THE OPEN VARIABLE BY x
JUMP TO main IF x IS EQUAL TO x
DEFINE THE NEW LABEL output
OPEN THE VARIABLE x
PRINT THE OPEN VARIABLE'S VALUE
PRINT THE CHARACTER WITH THE ASCII VALUE 10
JUMP TO main IF x IS EQUAL TO x

V3i

def x 0;
iloop if input = o;
print x;
else if input = i;
def x x+1;
else if input = d;
def x x-1;
else if input = s;
def x x*x;
else; print "Invalid command";

var'aq

Notes:

Will only allow one command per line

Can only be stopped by killing the process

The way var'aq is currently implemented (interpreter-wise), any program using 'lj will not run correctly unless the code is copied into the command-line directly

(* QopghotI' mughwI' var'aq *)

0 "toD" cher

~ QopghotI'mughwI' {

    ">> " cha'

    'Ij "Doch" cher

    Doch 0 1 tlheghpe' "Doch" cher

    Doch "i" tlheghrap'a' { toD 1 boq "toD" cher } HIja'chugh

    Doch "d" tlheghrap'a' { toD 1 boqHa' "toD" cher } HIja'chugh

    Doch "o" tlheghrap'a' { toD cha' } HIja'chugh

    Doch "s" tlheghrap'a' { toD toD boq'egh "toD" cher } HIja'chugh

    toD -1 rap'a' { 0 "toD" cher } HIja'chugh

    toD 256 rap'a' { 0 "toD" cher } HIja'chugh

    QopghotI'mughwI'

} pong

 QopghotI'mughwI'

WeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeBasic++

WeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeBasic++#Deadfish

Visual Basic .NET

Implementation by User:David.werecat which allows a program file to be specified as a command line parameter.

Option Explicit On
Option Strict On
Module Deadfish
	Dim Val As Integer = 0
	Sub Main()
		Dim ProgCode As String = ""
		Try : ProgCode = My.Computer.FileSystem.ReadAllText(Command().Trim(""""c))
		Catch : End Try
		For Each C As Char In ProgCode
			Interpret(C)
		Next
		While True
			Console.Write(">> ") : Interpret(Console.ReadKey.KeyChar)
		End While
	End Sub
	Sub Interpret(ByVal C As Char)
		Select Case C
			Case "d"c : Val -= 1 : Console.WriteLine()
			Case "i"c : Val += 1 : Console.WriteLine()
			Case "o"c : Console.WriteLine() : Console.WriteLine(Val.ToString())
			Case "s"c : Val = Val ^ 2 : Console.WriteLine()
		End Select
		If (Val < 0) Or (Val = 256) Then Val = 0
	End Sub
End Module

Vorpal

method() {
    acc = 0
    while (1 > 0) {
        input = '>> '.input()
        if ((acc == 256) || (acc < 0)) {
            acc = 0
        }
        if (input == "i") {
            acc = acc + 1
        } else {
            if (input == "d") {
                acc = acc - 1
            } else {
                if (input == "s") {
                    acc = acc * acc
                } else {
                    if (input == "o") { 
                        acc.print()
                    }
                }
            }
        }
    }
}

WARP

+A@s,l=li!:li:0?0?^.p%li@m}pc>pc1^_m|^.s@p=espc=pc0@r{pc=cc!
:"i":cc?0?>xx1:"d":cc?0?<xx1:"s":cc?0?&xxxx:"o":cc?0?)xx
:256:xx?0?=xx0:es:pc?0?^.e>pc1^.r@e

Whitespace

The first is with syntax highlighting, the second is a hexdump for recreating as the wiki software really can't cope.

    

   
         
 
  
   
           
 
   
             
    
    
 
     
    
    

    
    
 
      
    
           
    
     
 
           
    
     
 
           
    
     
 
           
    
      
 

       
 
  
 
 

    
 

    

 
  

     
 

    
    
 
 

     
 

    
    
 
 

     
 

 
    

 
 

      
 

 
  
         
 
  
 
 



000000: 20 20 20 20 0a 0a 20 20  09 0a 20 20 20 09 09 09      ␊␊  ␉␊   ␉␉␉
000010: 09 09 20 0a 20 0a 20 09  0a 20 20 09 0a 20 20 20  ␉␉ ␊ ␊ ␉␊  ␉␊
000020: 20 20 09 20 20 20 20 20  0a 09 0a 20 20 20 0a 20    ␉     ␊␉␊   ␊
000030: 20 20 20 09 20 20 20 20  20 20 20 20 0a 09 20 20     ␉        ␊␉
000040: 09 0a 09 20 09 20 0a 20  0a 20 20 20 09 09 0a 09  ␉␊␉ ␉ ␊ ␊   ␉␉␊␉
000050: 20 20 09 0a 09 20 09 20  0a 0a 20 20 09 09 0a 20    ␉␊␉ ␉ ␊␊  ␉␉␊
000060: 20 20 20 0a 09 0a 09 20  20 20 20 20 0a 09 09 09     ␊␉␊␉     ␊␉␉␉
000070: 20 0a 20 20 20 20 09 09  20 09 20 20 09 0a 09 20   ␊    ␉␉ ␉  ␉␊␉
000080: 20 09 0a 09 20 09 20 09  0a 20 0a 20 20 20 20 09   ␉␊␉ ␉ ␉␊ ␊    ␉
000090: 09 20 20 09 20 20 0a 09  20 20 09 0a 09 20 09 09  ␉  ␉  ␊␉  ␉␊␉ ␉␉
0000a0: 20 0a 20 0a 20 20 20 20  09 09 09 20 20 09 09 0a   ␊ ␊    ␉␉␉  ␉␉␊
0000b0: 09 20 20 09 0a 09 20 09  09 09 0a 20 0a 20 20 20  ␉  ␉␊␉ ␉␉␉␊ ␊
0000c0: 20 09 09 20 09 09 09 09  0a 09 20 20 09 0a 09 20   ␉␉ ␉␉␉␉␊␉  ␉␊␉
0000d0: 09 20 20 20 0a 20 0a 0a  20 20 20 09 20 09 20 0a  ␉   ␊ ␊␊   ␉ ␉ ␊
0000e0: 09 0a 20 20 0a 20 0a 09  0a 0a 20 20 09 20 0a 20  ␉␊  ␊ ␊␉␊␊  ␉ ␊
0000f0: 0a 0a 20 20 20 20 0a 0a  20 0a 09 09 0a 0a 20 20  ␊␊    ␊␊ ␊␉␉␊␊
000100: 09 20 09 0a 20 0a 0a 20  20 20 09 0a 09 20 20 20  ␉ ␉␊ ␊␊   ␉␊␉
000110: 0a 20 0a 09 0a 0a 20 20  09 09 20 0a 20 0a 0a 20  ␊ ␊␉␊␊  ␉␉ ␊ ␊␊
000120: 20 09 09 0a 09 20 20 20  0a 20 0a 09 0a 0a 20 20   ␉␉␊␉   ␊ ␊␉␊␊
000130: 09 09 09 0a 20 0a 0a 20  0a 20 09 20 20 0a 0a 20  ␉␉␉␊ ␊␊ ␊ ␉  ␊␊
000140: 0a 09 0a 0a 20 20 09 20  20 20 0a 20 0a 0a 20 0a  ␊␉␊␊  ␉   ␊ ␊␊ ␊
000150: 20 09 0a 20 09 20 20 20  09 20 09 20 0a 09 0a 20   ␉␊ ␉   ␉ ␉ ␊␉␊
000160: 20 0a 20 0a 09 0a 0a 0a  0a                        ␊ ␊␉␊␊␊␊


WTFZOMFG

'>> "
_2 + 
( 
_0 %4 _4 ~-256 | { _0 =0 } _3
> +
> > ^
& > @i | { _0 + _3 } <
& > @d | { _0 - _3 } <
& > @s | { _0 & m _3 } < 
& > @o | { _0 \ '\n" _3 } <
& > ~-10 | { '>> " } <
+
)

XPL0

Tested and works with EXPL (a.k.a. EXPL-32) on Windows, "legacy" 16-bit integer XPL0 on DOS (DOSBox), and 32-bit integer XPL0 (with XPLPX optimizing compiler) on DOS (DOSBox). Not yet tested with the 32-bit XPL0 versions on Raspberry Pi (XPLR/XPL0).

\ Deadfish in XPL0, version 2 -- dnm 2022-04-05, 2022-04-11, 2022-04-12
\ Thanks & greetz to: Loren Blaney (Boreal/6502) and Larry Fish

\ Uncomment the next line if using 16-bit XPL0 (not XPLPX/XPLP, EXPL, XPLR/XPL0)
\\include C:\CXPL\CODESI.XPL;

int Acc, Cmd;
[
    Acc:= 0;
    loop
    [
        Text(0, ">> ");
        Cmd:= ChIn(1);
        ChOut(0, Cmd);
        case Cmd of
            ^i: Acc:= Acc + 1;
            ^d: Acc:= Acc - 1;
            ^s: Acc:= Acc * Acc;
            ^o: [CrLf(0); IntOut(0, Acc)]
        other [CrLf(0); Text(0, "Unrecognized command")];
        CrLf(0);
        if Acc = 256 ! Acc < 0 then
            Acc:= 0;
    ]
]

Zeno

% Deadfish in Zeno (nearly a copy of Deadfish in Turing) -- dnm 2021-05-08
var accumulator : int := 0
var command : string

program
while true
        if (accumulator = 256) or (accumulator < 0) then
                accumulator := 0
        end if
        get command    % Uses Zeno's default Output window "? " prompt vs. ">> "
        if command = "i" then
                accumulator := accumulator + 1
        elsif command = "d" then
                accumulator := accumulator -1
        elsif command = "s" then
                accumulator := accumulator * accumulator
        elsif command = "o" then
                put accumulator
        else
                put "Unrecognized command."
        end if
end while
end program

ZiziQue

[Start]
!i^inc"Increment
!d^dec"Decrement
!s^sqr"Square
!o^out"Output
.
[out]
"{number}
^Start
[inc]
+number
^Start
[dec]
-number
^Start
[sqr]
=number,{{number}*{number}}
^Start

ZZ Zero

* Deadfish in ZZ Zero

        !INIT G,0
        !INIT H,0

        !KIND $00
        !NAME EMPTY
        !FLAG $0000
        !APP $020

        !KIND $01
        !NAME MAIN
        !FLAG $0020
        !APP \>

        !UPD @
        EQ H,256
        TLET H,G
        JZ D,-1
        TONE A,-200
        EQ D,\I
        JT D,II
        EQ D,\D
        JT D,DD
        EQ D,\S
        JT D,SS
        EQ D,\O
        JT D,OO
        END A,A

II      INC H,H
        END H,H

DD      JZ H,-1
        DEC H,H
        END H,H

SS      MUL H,H
        END H,H

OO      TEXT A,G
        APND A,H
        END H,H

        !END

Create a board containing a single piece of kind MAIN with speed 1.

Юᓂ곧⎔

Implementation in the non-ASCII language Юᓂ곧⎔. Accepts the standard `idso` inputs.

⌂ «»
☹
  ❝Δις Юᓂ곧⎔ κοδε μπασεδ ον α Δεαδφις Ϲ ιντερπρετερ μπι Ασδφ
   κονβερτεδ αντ τεστεδ μπι Σάλπιγξ❞
  ℤ 事 ← ☰।
  писать «“⁌☷☶⁍⁌☷☶⁍”»।
  ∀«।।»
  ☹
    ቁምፊ 工।
    工← получатзнак «»।
    ¿ «事⇔᠒᠕᠖∨事⇔−☱» 事←☰।
    ¿ «工⇔‘⁌☱☵☱⁍’» ∆事।
    ¬¿«工⇔‘⁌☱☴☴⁍’» ∇事।
    ¬¿«工⇔‘⁌☱☵☷⁍’» писать «“﹪ℤ␊” ¦ 事»।
    ¬¿«工⇔‘⁌☱☶☳⁍’» 事×←事।
    ¬писать «“⁌☷☶⁍⁌☷☶⁍”»।
  ☺
☺

ثلاثي

ﻮﻨﻴﺳﺎﻃ  ﺭﺩ ﺫ ﻦﺴﻃﺮﺤﻃﺫ ﻲﺼﻃ ﺎﻧﺎﺴﻃ ﻮﻃﺎﺳﺎﻃ ﺎﻘﻃﺭ ﻖﻘﻗ ﻲﻘﻃﺭ ﺎﻃﻮﺴﻃ ﺎﻄﻴﺴﻃ ﻞﻃ ﻁ ﻑ ﻲﺼﻃ ﺎﻧﺎﺴﻃ ﺎﻘﻃﺭ ﻖﺒﺟ ﻲﻘﻃﺭ ﻲﺻﺎﻃ ﺎﻄﻴﺴﻃ ﺩﺍﺩﺎﻓ ﻑ ﻦﺴﻃﺮﺤﻃﺫ ﻖﻠﺳ  ﺲﺳ  ﻦﺣﺮﻤﻨﻃ  ﻁ  ﺢﺤﻤﻠﻃﺭ  ﻲﺼﻃ ﺎﻧﺎﺴﻃ ﺎﻘﻃﺭ ﻕ ﻲﻘﻃﺭ ﻲﺻﺎﻃ ﺎﻄﻴﺴﻃ ﺍﺩﺍﺩﺎﻓ ﻑ ﻦﺴﻃﺮﺤﻃﺫ ﻖﻠﺳ ﺱﺪﺳ ﺪﺣﺮﻤﻨﻃ ﻁ ﺢﺤﻤﻠﻃﺭ ﻲﺼﻃ ﺎﻧﺎﺴﻃ ﺎﻘﻃﺭ ﻖﻴﺒﺟ
ﻲﻘﻃﺭ  ﻲﺻﺎﻃ  ﺎﻄﻴﺴﻃ  ﺍﺩﻭﺪﻓ  ﻑ ﻦﺴﻃﺮﺤﻃﺫ ﻖﻠﺳ ﺲﺴﺳ ﺲﻗﺭ ﻁ ﺢﺤﻤﻠﻃﺭ ﻲﺼﻃ ﺎﻧﺎﺴﻃ ﺎﻘﻃﺭ ﺎﻘﻳ ﻲﻘﻃﺭ ﻲﺻﺎﻃ ﺎﻄﻴﺴﻃ ﻱﺩﻭﺩﺎﻓ ﻑ ﻦﺴﻃﺮﺤﻃﺫ ﻖﻠﺳ ﺲﺳ ﻂﻔﻃ ﻁ ﺢﺤﻤﻠﻃﺭ ﻲﺼﻃ ﺍﺩﺍﺪﻓ ﺎﻘﻃﺭ ﻮﻧﺭ ﻲﻘﻃﺭ ﻲﺻﺎﻃ ﺎﻄﻴﺴﻃ ﻭﺩﺪﻓ ﻑ ﺢﺤﻤﻠﻃﺭ ﻖﻠﺳ  ﺲﻃ ﺢﺤﻤﻠﻃﺭ ﻁ ﺯﺭ ﻭﺰﻳﺯﺯ ﻢﺿ ﺐﺤﺛ ﻁ ﺲﻃﺮﻃ

One- sixth of the line is dripping. It is dripping. It's dripping. It's dripping . Speechless regurgitation in the line -- Google Translate

תלת

וניסאט  רד ן נסטרחטן יצט אנאסט וטאסאט אקטר קקק יקטר אטוסט אטיסט לט ט פ יצט אנאסט אקטר קבג יקטר יצאט אטיסט דאדאפ פ נסטרחטן קלס  סס  נחרמנט  ט  חחמלטר  יצט אנאסט אקטר ק יקטר יצאט אטיסט אדאדאפ פ נסטרחטן קלס סדס דחרמנט ט חחמלטר יצט אנאסט אקטר קיבג
יקטר  יצאט  אטיסט  אדודפ  פ נסטרחטן קלס ססס סקר ט חחמלטר יצט אנאסט אקטר אקי יקטר יצאט אטיסט ידודאפ פ נסטרחטן קלס סס טפט ט חחמלטר יצט אדאדפ אקטר ונר יקטר יצאט אטיסט ודדפ פ חחמלטר קלס  סט חחמלטר ט זר וזיזז מף בחך ט סטרט

Variants of deadfish

  • Deadfish i object oriented
  • Deadfish~ superset
  • FISHQ9+ — deadfish merged with HQ9+
  • Deadfish x — xkcd variant with extra commands
  • Print "deadfish" includes termination, and character printing.
  • Deadfish 2 is another superset.
  • Functional deadfish adds "functions"
  • ΙΧΘΥΣ ancient Greek themed, with Unicode output, statement definitions, and Turing-complete via Deadfish-overflow side-effects.
  • Livefish Input only variant
  • CARfish tries to make programming in Deadfish even more horrible.
  • Deadfish "self-interpreter" is a Deadfish superset that is capable of implementing Deadfish without explicit Deadfish-implementing commands.
  • BrainfisHQ9+ merges deadfish with Brainfuck and HQ9+
  • 2Deadfish makes each command in Deadfish change the direction of the pointer by some multiple of 90 degrees.
  • Catshark, which also has 4 instructions, but are modified to support 2 accumulators.
  • Deadsocket has the s instruction modified to open a socket.
  • Deadfish++ with more commands and custom functions. Turing-complete.

See also

External resources