Deadfish with gotos and input
Deadfish where the one number it has is also where the program goes next.
Fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, 2024 · Turing complete: unknown · ●○○ easy · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
Deadfish has one accumulator and four commands. This version from 2024 adds a halt, a character output, a number input and a jump. The jump . has no label. It goes to the place the accumulator holds, so the same number is the data and the address. The specification puts it under Unusable for programming.
The machine
| Command | Does |
|---|---|
i d | Add or take 1 |
s | Square |
o | Print the number and a line feed |
c | Print it as a character |
. | Jump, the run goes on after place n, n being the accumulator |
, | Read a line as a whole number, a negative one becomes 0 |
h | Halt |
After every instruction an accumulator of -1 or 256 becomes 0, as in Deadfish. Places count from 0. A run that reaches place 256 of a longer program starts over at place 0. Every other character does nothing.
Example
The Hello World from the specification climbs to each letter with i and s and walks down with d.
The Hello World from the specification climbs to each letter with i and s and walks down with d.
The truth machine adds 4 to the input and squares it. A 0 gives 16, and the jump lands on the s at place 17, which squares 16 to 256. That is 0 again, so o prints 0 and h halts. A 1 gives 25, and the jump lands on a loop that counts down to 1, prints it, counts back up to 25 and jumps again, for ever.
Patterns it teaches
- Counter machines: one counter, and a jump that reads its address from that counter.
See also
Deadfish with gotos and input builds on Deadfish~.
Deadfish derivatives
Write your own in Run Convert a program from Deadfish with gotos and input
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: deadfish-with-gotos-and-input.
Command line
shib run deadfish-with-gotos-and-input -e ',iiiis. soh ddddddddddddddddddddddddoiiiiiiiiiiiiiiiiiiiiiiii.' --input '0'shib manual deadfish-with-gotos-and-inputSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/deadfish-with-gotos-and-input.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org