We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

emd

From Esolang
Jump to navigation Jump to search
emd
Paradigm(s) imperative
Designed by User:Lupodevelop
Appeared in 2026
Memory system stack-based, with memory cells
Dimensions one-dimensional
Computational class Turing complete
Reference implementation emd (Rust)
File extension(s) .emd

emd (short for em dash, also known as Emotional damage) is a stack-based language written only in eight Unicode dashes. Each pair of dashes is one instruction. In most fonts the dashes look alike, so a program reads as one long line of dashes.

Syntax

Index Symbol Code point Name
0 - U+002D HYPHEN-MINUS
1 ‐ U+2010 HYPHEN
2 ‑ U+2011 NON-BREAKING HYPHEN
3 ‒ U+2012 FIGURE DASH
4 – U+2013 EN DASH
5 — U+2014 EM DASH
6 ― U+2015 HORIZONTAL BAR
7 − U+2212 MINUS SIGN

A source holds only these eight symbols and newlines. A line holds at most 32 symbols. Newlines are removed before decoding, so a break can fall anywhere, even inside an instruction. Any other character, including a look-alike dash, is an error.

An instruction is a pair: the first symbol picks the family, the second the operation. 32 of the 64 pairs are assigned; the others are decoding errors, not no-ops.

Instructions

b is the top of the stack, a the value below it.

Code Name Effect
- + symbol n PUSH n → n, for n from 0 to 7
‐- DUP a → a a
‐‐ DROP a →
‐‑ SWAP a b → b a
‐‒ OVER a b → a b a
‐– ROT a b c → b c a
‑- ADD a b → a+b
‑‐ SUB a b → a−b
‑‑ MUL a b → a·b
‑‒ DIV a b → a/b truncated; fault if b=0
‑– MOD a b → remainder with the sign of a; fault if b=0
‒- LOAD a → M[a]
‒‐ STORE v a →, M[a] := v
–- JMP off →, pc += off
–‐ JZ c off →, jump if c=0
–‑ JNZ c off →, jump if c≠0
–‒ HALT stop
–– CALL off → pc+1, pc += off
–— RET a →, pc := a
—- READ → byte, or −1 at end of input
—‐ WRITE v →, output byte v (0–255)
―- EQ a b → 1 if a=b, else 0
―‐ LT a b → 1 if a < b, else 0
―‑ GT a b → 1 if a > b, else 0
―‒ NOT a → 1 if a=0, else 0
  • There are no constants above 7; larger numbers are built with arithmetic (104 = 7·7·2+6).
  • Jump offsets count instructions, relative to the jump itself. RET takes an absolute address, the one CALL pushed.
  • Memory cells are indexed by naturals and start at 0. A negative address is a fault.
  • Running past the end is a fault: programs end with HALT.
  • The implementation uses 64-bit integers; overflow is a fault.

Examples

Print h (PUSH 7, DUP, MUL, PUSH 2, MUL, PUSH 6, ADD, WRITE, HALT):

-−‐-‑‑-‑‑‑-―‑-—‐–‒

Cat program:

—-‐---―‐-‐-−‑‑-‒‑-–‑—‐---‑-−‑‑-–
‑-‑‐–-–‒

Truth-machine:

—-‐--‐‑--‐-−‑‑-‒‑-–‐‐-—‐‐--−-−‑‑
―--‑–‑–‒‐-—‐---—‑‐–-

Hello, world!:

-‐-−‑‑-‒‑--−‑‑-‑‑-—‐-‑-−‑‑-−‑‑-‒
‑-—‐-‑-−‑‑-‐‑--−‑‑-‒‑-—‐-‑-−‑‑-‐
‑--−‑‑-‒‑-—‐-‑-−‑‑-‐‑--−‑‑-―‑-—‐
-―-−‑‑-‑‑-—‐-–-−‑‑-–‑-—‐-‑-−‑‑-‒
‑--−‑‑—‐-‑-−‑‑-‐‑--−‑‑-―‑-—‐-‑-−
‑‑-‑‑--−‑‑-‑‑-—‐-‑-−‑‑-‐‑--−‑‑-‒
‑-—‐-‑-−‑‑-−‑‑-‑‑-—‐-–-−‑‑-—‑-—‐
-‐-−‑‑-‒‑-—‐–‒

Computational class

emd is Turing complete. A direct simulation of Turing machines using 11 of the instructions is proved in Lean 4 and Rocq, with unbounded integers and memory.

emd can also be translated to 3-cell brainfuck:

brainfuck emd
Start of program ------
+ -‐‑-
- -‐‑‐
> ‐–
< ‐–‐–
[ ‐-e–‐, where e is a construction for the amount of instructions in the loop plus two.
] ‐-e–‑, where e is a construction for the amount of instructions in the loop.

Implementations

The reference implementation, in Rust, has an interpreter, a readable assembler, a reversible debugger, a static analyzer and a C backend. The assembler is also written in emd and compiles itself to the same bytes as the Rust one.

External resources