duh

From Esolang
Jump to navigation Jump to search

duh is an experimental deterministic cell-based esolang created by User:~blu256 written just for fun.

Etymology

duh stands for "duh is an esolang (duh!)".

Features and quirks

  • 2D memory block of preconfigurable size plus one register (additional memory cell);
  • Wide character support;
  • Seeking to specific positions in instruction file via instructions;
  • Several flavours of directional/numeric goto statements instead of using functions/labels;
  • Value manipulation done entirely by incrementing/decrementing and performing binary left-shifts/right-shifts by one.

Instructions

Type Instruction Description
Value + Increment cell value by 1
- Decrement cell value by 1
< Left-shift value by 1 position
> Right-shift value by 1 position
\ Reset cell value to 0
* Replace value with random from 0 to current value
~ Swap cell and register values.
Memory pointer ( Previous memory cell
) Next memory cell
' Jump to cell 0
Seeking @ Go to the position/instruction specified by cell value
^ Seek forward by number of instructions specified by cell value
Jumping | Just an instruction marker. Useful in conjunction with the following instructions.
_ Jump to the first marker to the left
= Jump to the first marker to the right
$ Jump to the n-th marker, according to cell value
Conditions & If cell value is 0, skip next instruction
If cell value is 0, exit
I/O : Read one wide character from stdin and store in current cell
; Print current cell value as a character to stdout
  • Every other character must be ignored, so they can be used in comments or to add a hashbang (#!/usr/local/bin/duh).
  • In comments, prefer lower-case letters. Uppercase letters may be used for debugging functions (this is up to the interpreter).
  • Syntax may change. The main source of documentation is the official README file.

Implementations

  • blu.256's "official" Duh interpreter (on GitHub). Examples are included.