LLvlN

From Esolang
(Redirected from Llvln)
Jump to navigation Jump to search

LLvlN or Low-Level Nonsense is an esoteric programming language created in 2025 by Comet AI Browser. It simulates assembly-like operations but with deliberately confusing mnemonics and nonsensical register names based on food and cooking metaphors. The language combines the low-level nature of assembly with the absurdity typical of esoteric languages.

Overview

LLvlN is designed to make programming feel like following a recipe written by someone who confused their cookbook with their computer science textbook. The language features food-themed register names and uses cooking verbs for stack operations, creating a unique programming experience that is both frustrating and amusing. The language is Turing-complete and features:

  • 8 food-themed registers
  • Stack-based operations using cooking terminology
  • Assembly-like syntax with culinary flair
  • Case-insensitive instruction set
  • Support for labels and conditional/unconditional jumps

Language Specification

Registers

LLvlN provides 8 general-purpose registers, each named after a food item:

  • SOUP - The soup register (typically used for accumulation)
  • CAKE - The cake register (often used for sweet results)
  • MEAT - The meat register (substantial computations)
  • FISH - The fish register (slippery values)
  • RICE - The rice register (grain-by-grain counting)
  • BEAN - The bean register (boolean operations)
  • NUTS - The nuts register (bit operations)
  • MILK - The milk register (flowing data)

All registers are initialized to 0 at program start and can hold signed integers (implementation-defined size, typically 32-bit or 64-bit).

Instructions

Program Structure

  • RECIPE - Marks the beginning of a program (must be first instruction)
  • DONE - Marks the end of a program (terminates execution)

Data Movement

  • SET <value> - Sets a register to a literal value
  • COPY <source> - Copies value from source register to destination register

Arithmetic Operations

All arithmetic operations work on "ingredients":

  • ADD <source> - Adds source register to destination register
  • SUB <source> - Subtracts source register from destination register
  • MUL <source> - Multiplies destination register by source register
  • DIV <source> - Divides destination register by source register (integer division)
  • MOD <source> - Destination register becomes destination modulo source

Stack Operations

The stack uses cooking verbs:

  • BAKE <register> - Pushes register value onto the stack
  • BOIL - Pops top value from stack and discards it
  • CHOP <register> - Pops top value from stack into register
  • DICE - Duplicates top value on stack
  • FLIP - Swaps top two values on stack
  • STIR - Rotates top three stack values (top → third, second → top, third → second)

Input/Output

  • SERVE <register> - Outputs the value in register as a number
  • SERVE <register> CHAR - Outputs the value in register as an ASCII character
  • TASTE <register> - Reads a number from input into register
  • TASTE <register> CHAR - Reads a character from input into register as ASCII value

Control Flow

  • LABEL: - Defines a label (any alphanumeric identifier followed by colon)
  • SALT <label> - Unconditional jump to label
  • SPICE <label> - Conditional jump: jumps to label if register is non-zero
  • BLAND <label> - Conditional jump: jumps to label if register is zero

Comparison

  • CMP <reg2> - Compares two registers, sets BEAN register to:
    • 1 if reg1 > reg2
    • 0 if reg1 == reg2
    • -1 if reg1 < reg2

Syntax Rules

  • Instructions are case-insensitive (RECIPE, Recipe, and recipe are all valid)
  • One instruction per line
  • Comments begin with # and extend to end of line
  • Labels must be unique and consist of alphanumeric characters followed by a colon
  • Whitespace between tokens is flexible
  • Empty lines are ignored

Computational Class

LLvlN should be Turing-complete by the structured program theorem, since the language provides:

  • Unbounded memory (through the stack)
  • Conditional branching
  • Potentially-infinite looping

A proof of Turing completeness could be constructed by implementing a Minsky machine or by demonstrating that LLvlN can simulate brainfuck.

Examples

Hello, World!

RECIPE
# Print "Hello, World!"
SET SOUP 72      # H
SERVE SOUP CHAR
SET SOUP 101     # e
SERVE SOUP CHAR
SET SOUP 108     # l
SERVE SOUP CHAR
SERVE SOUP CHAR  # l
SET SOUP 111     # o
SERVE SOUP CHAR
SET SOUP 44      # ,
SERVE SOUP CHAR
SET SOUP 32      # space
SERVE SOUP CHAR
SET SOUP 87      # W
SERVE SOUP CHAR
SET SOUP 111     # o
SERVE SOUP CHAR
SET SOUP 114     # r
SERVE SOUP CHAR
SET SOUP 108     # l
SERVE SOUP CHAR
SET SOUP 100     # d
SERVE SOUP CHAR
SET SOUP 33      # !
SERVE SOUP CHAR
DONE

Truth Machine

RECIPE
# Read input and output 1 forever if 1, or output 0 once if 0
TASTE SOUP       # Read input
SERVE SOUP       # Output the number
SPICE SOUP LOOP  # If non-zero, jump to LOOP
DONE             # If zero, end
LOOP:
SERVE SOUP       # Output the number
SALT LOOP        # Infinite loop outputting 1

Cat Program

RECIPE
# Echo input characters until EOF
LOOP:
TASTE SOUP CHAR  # Read character
CMP SOUP FISH    # Compare with FISH (0)
BLAND BEAN END   # If equal (EOF), exit
SERVE SOUP CHAR  # Output character
SALT LOOP        # Continue loop
END:
DONE

Fibonacci Sequence

RECIPE
# Generate first 10 Fibonacci numbers
SET SOUP 0       # F(0)
SET CAKE 1       # F(1)
SET RICE 10      # Counter
SERVE SOUP       # Print F(0)
LOOP:
SERVE CAKE       # Print current Fibonacci number
COPY MEAT SOUP   # Save F(n-2)
COPY SOUP CAKE   # F(n-2) = F(n-1)
ADD CAKE MEAT    # F(n-1) = F(n-1) + F(n-2)
SET MEAT 1       # Decrement counter
SUB RICE MEAT
SPICE RICE LOOP  # Continue if counter > 0
DONE

Stack Demonstration

RECIPE
# Demonstrate stack operations
SET SOUP 5
SET CAKE 10
SET MEAT 15
BAKE SOUP        # Stack: [5]
BAKE CAKE        # Stack: [5, 10]
BAKE MEAT        # Stack: [5, 10, 15]
STIR             # Stack: [10, 15, 5]
FLIP             # Stack: [10, 5, 15]
DICE             # Stack: [10, 5, 15, 15]
CHOP FISH        # FISH = 15, Stack: [10, 5, 15]
CHOP RICE        # RICE = 15, Stack: [10, 5]
CHOP BEAN        # BEAN = 5, Stack: [10]
SERVE FISH       # Output: 15
SERVE RICE       # Output: 15
SERVE BEAN       # Output: 5
DONE

Factorial Calculator

RECIPE
# Calculate factorial of input number
TASTE SOUP       # Read number
COPY CAKE SOUP   # Copy to CAKE for output later
SET MEAT 1       # MEAT will hold result
FACT_LOOP:
BLAND SOUP FACT_END  # If SOUP is 0, done
MUL MEAT SOUP    # result *= n
SET FISH 1
SUB SOUP FISH    # n--
SALT FACT_LOOP
FACT_END:
SERVE MEAT       # Output factorial
DONE

Implementation Notes

Memory Model

An implementation should provide:

  • 8 registers (signed integers)
  • An unbounded stack (or as large as memory permits)
  • Standard input/output streams

Error Handling

Implementations should handle:

  • Division by zero (recommended: terminate with error)
  • Stack underflow (recommended: terminate with error)
  • Invalid labels (compile-time error)
  • Invalid register names (compile-time error)
  • Input/output errors (implementation-defined)

Interpreter Implementation

A basic interpreter should:

  1. Parse the program and validate syntax
  2. Build a label table for jumps
  3. Initialize all registers to 0
  4. Execute instructions sequentially
  5. Handle control flow via label jumps
  6. Maintain a stack for BAKE/CHOP operations

Optimizations

Possible optimizations include:

  • Constant folding for SET operations
  • Dead code elimination after unconditional jumps
  • Register allocation analysis
  • Stack operation coalescing

Variants

  • LLvlN++ - Adding functions and procedure calls
  • LLvlN-FLOAT - Official floating-point extension with 4 "spice" registers and floating-point arithmetic
  • Quantum-LLvlN - Superposition of ingredients

See Also

External Resources