!Frontal Lobe Lobotomy

From Esolang
Jump to navigation Jump to search

Frontal Lobe Lobotomy (FLL)

Frontal Lobe Lobotomy (1.1.0 COMPILER / 1.2.0 VM => FLL 1.1.0) is a x86-64 esoteric programming language inspired by brain surgery metaphors 'Lobotomy'. It uses pointer-addressable neurons and suture levels to represent stateful, context-sensitive operations. It was designed to feel like doing live neurosurgery on a floating-point brain, where execution is done line-by-line with surgical "masks" that manipulate the brain tape.
Developed by User:Creepy : “FLL doesn't just manipulate memory — it performs psychological operations.”

Design Goals

  • To create a compact yet Turing-complete language
  • To blend dark humor with real computation in a small binary

Frontal Lobe Lobotomy Components

  • Brain Tape: A contiguous block of 65536 memory cells, indexed from 0 to 65535. Each cell holds a 32-bit floating-point number (float32) and is initialized to 0.0.
  • Brain Pointer (BP): An unsigned integer that holds the index of the currently active cell on the Brain Tape. It is initialized to 0. Its value can range from 0 to 65535.
  • Suture Lever 1 (SL1): An integer state variable that modifies the function of many mask symbols. It is initialized to 0. SL1 cycles through the values 0, 1, 2, 3. Incrementing SL1 from 3 resets it to 0.
  • Line Pointer (LP): An unsigned integer that points to the current line of code to be executed. It is initialized to 0 and increments by one after each instruction, unless a jump occurs.
  • RAM: A single float32 memory slot used for temporary storage. It is initialized to 0.0.

Language Overview

  • Memory Model: One brain, 65,536 neurons (cells). Each cell holds a float32, initialized to 0.0.
  • Instruction Model: Fixed 3-part line: [line][dir][mask]
  • SL1 State: Stateful modifier that alters the meaning of mask symbols
  • Execution: Sequential per line, unless jumped via J
  • Output: Values are “cast” to cast.bin, one line per call.
  • One RAM State: Stores a float32 that is initialized to 0.0.
  • Uses .fll as the native FLL Program Filetype.
  • Has an output system (outputs to cast.bin)

Comments

A comment is denoted by `//`. All text from `//` to the end of the line is ignored by the interpreter.

Instructions

[dir] Commands

dir Name Description
= Operate Executes the [mask] surgery on the cell at the current Brain Pointer (Tape[BP]).
< Decrement and Operate Decrements BP by 1, then executes the [mask] surgery on the new Tape[BP].
> Increment and Operate Increments BP by 1, then executes the [mask] surgery on the new Tape[BP].
$ Cast Outputs the value of Tape[BP] to an external file named cast.bin. The [mask] is not executed. The output format is: [BP] [Tape[BP]]\n. File is created/truncated on first cast, then appended.
# Operate and Reset Executes the [mask] surgery on Tape[BP], then immediately resets Tape[BP] to 0.0.
J Operate and Jump Executes the [mask] surgery on Tape[BP]. Then checks if Tape[BP] is exactly 1.0. If true, sets LP to this line number, creating a loop.
! Mask Modifier Replaces the [mask] in Program[LP] with the current one from this instruction. Does not execute the mask.

`LP` is set to the `[line]` number of the current instruction, causing an effective loop or jump to the same line (for [dir] J). If false, execution proceeds to the next line as normal.

[mask] Symbols

The `mask` contains a sequence of 16 symbols that are executed from left to right. Many symbols are context-sensitive and change their behavior based on the current value of `SL1`.

Symbol Name SL1=0 SL1=1 SL1=2 SL1=3
~ N-OP No operation. (Same) (Same) (Same)
@ Swapper Increments SL1 by 1. Resets to 0 after 3. (Same) (Same) (Same)
+ Increment Tape[BP] += 1.0 Tape[BP] += 0.1 Tape[BP] += 0.01 Tape[BP] += 0.001
- Decrement Tape[BP] -= 1.0 Tape[BP] -= 0.1 Tape[BP] -= 0.01 Tape[BP] -= 0.001
* Multiply Tape[BP] *= Tape[BP-1] Tape[BP] *= Tape[BP+1] (Undefined) (Undefined)
A Add Tape[BP] += Tape[BP-1] Tape[BP] += Tape[BP+1] (Undefined) (Undefined)
D Divide Tape[BP] /= Tape[BP-1] Tape[BP] /= Tape[BP+1] (Undefined) (Undefined)
S Subtract Tape[BP] -= Tape[BP-1] Tape[BP] -= Tape[BP+1] (Undefined) (Undefined)
& Get Tape[BP] = Tape[BP-1] Tape[BP] = Tape[BP+1] Tape[BP] = Tape[BP-2] Tape[BP] = Tape[BP+2]
= Equals Tape[BP] = (Tape[BP] == Tape[BP-1]) ? 1.0 : 0.0 Tape[BP] = (Tape[BP] == Tape[BP+1]) ? 1.0 : 0.0 (Undefined) (Undefined)
> Compare Tape[BP] = (Tape[BP] > Tape[BP-1]) ? 1.0 : 0.0 Tape[BP] = (Tape[BP] > Tape[BP+1]) ? 1.0 : 0.0 Tape[BP] = (Tape[BP] < Tape[BP-1]) ? 1.0 : 0.0 Tape[BP] = (Tape[BP] < Tape[BP+1]) ? 1.0 : 0.0
^ LP Control LP += 1 LP -= 1 LP += 2 LP -= 2
; RAM Store/Load RAM = Tape[BP] RAM = Tape[BP-1] RAM = Tape[BP+2] Tape[BP] = RAM
: RAM Set/Clear Tape[BP-1] = RAM Tape[BP+1] = RAM RAM = 0.0 RAM = 1.0
% Copy Tape[BP-1] = Tape[BP] Tape[BP-1] = Tape[BP] Tape[BP-2] = Tape[BP] Tape[BP+2] = Tape[BP]

*Note: Operations that reference adjacent tape cells (e.g., `Tape[BP-1]`) are subject to boundary conditions. For instance, `Tape[BP-1]` is only valid if `BP > 0`.*

Execution Flow

  1. Initialize Brain Tape, BP, SL1, LP, and RAM to their default starting values.
  2. The interpreter begins at the instruction specified by the Line Pointer (`LP=0`).
  3. The `dir` command of the current instruction is evaluated. This may involve pre-operation modifications to `BP`.
  4. If the `dir` command requires it, the 16 `mask` symbols are executed sequentially from left to right.
  5. After the `dir` and `mask` operations are complete, post-operation actions (like value resets or conditional jumps) are performed.
  6. Unless a jump occurred (`J`), the `LP` is incremented by 1.
  7. The process repeats from step 3 with the new `LP`.
  8. The program halts when the `LP` points to a line number that does not exist in the program source.

Example

// prog.fll - A Small Value Decay Calculation Program
[0][>][+@+++++~~~~~~@@@]
[1][>][+@@@-~~~~~~~~~~@]
[2][<][@*~~~~~~~~~~~@@@]
[3][$][~~~~~~~~~~~~~~~~]

Explanation

We move the pointer from N[0] to N[1] with [>], then Add 1.0 (SL1-0) to it. Then Increment to SL1-1, then repeat 5 times of Add (which since its SL1-1 = 0.1). Then reset SL1 at the end for cleanliness. N[1] = 1.5. Then, move the pointer to N[2], Add 1.0, Increment to SL1-3, then minus (since its SL1-3 then -0.001). So the value of N[2] is 0.999.

Compute Step:
Move back to N[1], Now Increment to SL1-1 (Ahead-Multiply), do '*', so this is basically N[1]=N[1]*N[2].
If you did not increment SL1 to SL1-1 (example like SL1-0) - this will multiply the previous neuron which is,
N[1] = N[1] * N[0]. Now, we output by using "$".

Saving: This Saves N[1] with the value of 1.4985.
Expected Output: N[1] = 1.4985

Expected Output as cast.bin


1 1.4985


Note, cast.bin outputs with a structure of [Neuron ID] [Neuron Value].

Download Tooling


Tooling for FLL 1.1.0 (123kb, Queued to be Reviewed by Google)

Tooling for FLL 1.1.0 (123kb, Alternative Download)

C++ Source Code for FLL-VM

  • fllc.exe converts your .fll programs into a .cpp file. You can follow the instructions given by fllc.exe and compile it with g++ (mingw64 needed!)
  • fllcvm.exe runs your .fll programs instantly (act as an interpreter)
  • fllcvm.cpp can be compiled into fllcvm.exe using g++ (mingw64).

Frontal Lobe Lobotomy Versions

  • FLL 1.0.0 (unstable) - Initial Release
  • FLL 1.1.0 (stable) - Added new [dir] command !. Added % as the copy symbol.

Future Ideas

  • Supporting x86-based machines.
  • Adding the Brainstem Surgery, harder than normal frontal lobe lobotomy surgery but harder to be reverse-engineered.
  • Adding Input system (uncast.bin)