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.

DODO

From Esolang
Jump to navigation Jump to search

DODO is a stack based retro-style programming language made by User:QuantumV inspired by FORTH, BASIC, etc.

(Almost) everything in this language is a number on the stack, except minor stuff like labels, variable storage, and DO


DO is used to execute every command because everything just pushes its opcode.

Notes

Strings

Strings work by first pushing 0 and then pushing themselves in reverse for convenient printing and such. So like reversed C Strings.

Buffers

Buffers are multiple ints enclosed by { (80) and } (81). When buffers are pushed by a variable, the brackets are excluded.

Instructions

Misc

Instruction Opcode Description
DO N/A Executes the top instruction on the stack. Technically is not an instruction
@NAME: N/A Creates a label with a name, no name is also valid. This has a separate pass so you can safely jump over it.
IMPORT N/A Replaces itself and the preceding string by the contents of the file pointed to by the string, relative to the location where the command is run. Falls back to the DODO lib folder if it cant find it.
; N/A Initializes a comment from this token to the end of the line, the comment is not tokenized.
VARIABLENAME ~ Pushes the value of the variable named, can push mutliple values.
NOP 0 Does nothing. At all.

Stack Ops

Instruction Opcode Description
DUP 1 Duplicate top value on the stack
POP 2 Discard top value on the stack
SWAP 3 Swap two top values on the stack
OVER 4 Push the value before the top value on the stack

Math Ops

B is the top of the stack, A is the element before the top

Instruction Opcode Description
+ 10 Performs A + B
- 11 Performs A - B
* 12 Performs A * B
/ 13 Performs A / B
% 14 Performs A % B
= 15 Checks if A is equal to B and pushes 1 if it is, and 0 if it isnt.
> 16 Checks if A is more than B and pushes 1 if it is, and 0 if it isnt.
< 17 Checks if A is less than B and pushes 1 if it is, and 0 if it isnt.

Var Ops

Instruction Opcode Description
SET 20 Sets a variable pointed to by the preceding string to a value. E.g.
10 "HI" SET
VAR 21 Initialize a numeric var. E.g.
10 "HI" VAR
ALIAS 22 Initialize a constant numeric var. E.g.
10 "HI" ALIAS
BUF 23 Initialize a buffer var that will push the contents of the buffer on use. E.g.
{ 1 2 3 4 } "HI" VAR
BUFALIAS 24 Initialize a constant buffer var that will push the contents of the buffer on use. E.g.
{ 1 2 3 4 }  "HI" BUFALIAS
SETBUF 25 Sets a buffer variable. E.g.
{ 1 2 3 4 } "HI" SET
DEL 26 Permanently delete a variable or alias. This has no restrictions. E.g.
"HI" DEL
GET 27 Pushes a variable value to the stack by name, useful for getting variables generated at runtime.

Jump Ops

Instruction Opcode Description
GOTO 40 Jumps to the label pointed to by the preceding string. E.g.
"MYLABEL" GOTO
GOSUB 41 Jumps to a label, but also pushes the position to the call stack, so it can be returned to by...
RET 42 Jumps back to the caller
JZ 43 Jumps to a label, but only if the top of the stack is 0, also consumes it.
JNZ 44 Jumps to a label, but only if the top of the stack is 1, also consumes it.

I/O Ops

Instruction Opcode Description
OUTN 50 Output top value as a number
OUTC 51 Output top value as a character
OUTS 52 Output top value as a string
OUTB 53 Output top value as a buffer (
{ 1, 2, 3, }
)
INPUTS 54 Input value as a string
INPUTN 55 Input value as a number
INPUTC 56 Input value as a character

Time Ops

Instruction Opcode Description
SLEEP 60 Sleep for an amount of ms
TIME 61 Get unix time milliseconds

Default Consts

Const Value Description
{ 80 Used for defining buffers
} 81 Ditto

Examples

Hello World

"Hello, World!" OUTS DO

Truth-machine

INPUTN DO
@LOOP:
DUP DO DUP DO
OUTN DO
"LOOP" JNZ DO

Fibonacci sequence

0 "A" VAR
1 "B" VAR
DO DO
@LOOP:
    B OUTN      DO
    A B +       DO
    B "A" SET   DO
      "B" SET   DO
    10 OUTC     DO
    "LOOP" GOTO DO 


Implementations

There is currently only one implementation, that being https://github.com/QuantumV2/dodo or https://codeberg.org/QuantumV/dodo on codeberg