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.

Modiv

From Esolang
Jump to navigation Jump to search
language's logo

Modiv is an esoteric programming language created in 2025. It is based on a simple idea: the only memory provided is a single accumulator.

The name Modiv is a blend of the words mod and div, referencing the CJUMP instruction that used to combine both modulus and division operations.

Language Overview

Modiv programs consist of assembly-like commands, arithmetic expressions, and labels.

Commands

SET X - Sets the accumulator to the value of expression X.

CJUMP L X - If X != 0, it and jumps to label L.

JUMP L - Unconditional jump to label L.

AOUT X - Outputs the value of expression X as an ASCII character.

DOUT X - Outputs the value of expression X as a decimal number.


Expressions

Expressions support:

  • Literals (e.g., 42)
  • Arithmetic operations: +, -, *, ^, /(integer result)
  • Keywords:
  1. acc — the current value of the accumulator
  2. din — read a decimal value from input
  3. ain — read an ASCII character from input
  4. nmod(x) - a the number of times acc can be divided by x without creating a reminder

Labels

A label is defined as:

:labelName

It can be the target of a JUMP or CJUMP.

Example Programs

Echo a single character:

SET ain
AOUT acc

Cat

:cat
SET ain
AOUT acc
JUMP cat

XDC random number

DOUT 4

A + B problem

SET (2^din) * (3^din)
DOUT nmod(2)+nmod(3)

Computational class

Modiv can be easily mapped to The section 14.2 Minsky machine

Minsky machine       Modiv
multiply by a        SET acc*a
check if divisible
by a, else branch    CJUMP L nmod(a)
                     SET acc/a at L

Implementation

An interpreter was made by the creator of the language (User:Krolkrol), you can see it here https://github.com/Dfgsgh/Modiv