Morse-Assembly-Language

From Esolang
Jump to navigation Jump to search

Morse Assembly Language (MAL) is an esoteric programming language created by User:Camolover that combines assembly-like programming with Morse code. Every instruction, register, and value in the language is encoded entirely in Morse code, making it both an homage to Morse code's historical significance in telecommunications and an exercise in code obfuscation.

Overview

Morse Assembly Language transforms assembly language syntax into Morse code representations. Programs are written as sequences of dots, dashes, spaces, and forward slashes, where individual Morse characters are separated by spaces, words/tokens by " / " (space-slash-space), and lines by newlines.

The language was designed for fun and to honor the legacy of Morse code, creating a unique fusion of low-level programming concepts with historical telecommunications encoding.

Syntax

The syntax follows a specific encoding scheme:

  • Individual Morse characters are separated by single spaces
  • Words/tokens are separated by " / " (space-slash-space)
  • Lines are separated by newlines
  • Standard Morse code mappings are used for letters, numbers, and punctuation

Example

Regular Assembly:  MOV AX, 72
Morse Assembly:    -- --- ...- / .- -..- / --..-- / --... ..---

Language Features

Morse Assembly Language includes a complete set of assembly-like instructions:

Registers

  • AX, BX, CX, DX - General-purpose registers
  • SP - Stack pointer
  • IP - Instruction pointer

Instruction Set

Data Movement:

  • MOV dest, src - Move value from source to destination
  • PUSH value - Push value onto stack
  • POP dest - Pop value from stack to destination

Arithmetic:

  • ADD dest, src - Add source to destination
  • SUB dest, src - Subtract source from destination
  • MUL value - Multiply AX by value
  • DIV value - Divide AX by value
  • INC dest - Increment destination
  • DEC dest - Decrement destination

Logic:

  • AND dest, src - Bitwise AND
  • OR dest, src - Bitwise OR
  • XOR dest, src - Bitwise XOR
  • NOT dest - Bitwise NOT

Comparison and Jumps:

  • CMP a, b - Compare two values
  • JMP label - Unconditional jump
  • JE label - Jump if equal (zero flag set)
  • JNE label - Jump if not equal
  • JG label - Jump if greater
  • JL label - Jump if less

I/O:

  • OUT value - Output value (as ASCII if 0-127)
  • IN dest - Read input to destination

Control:

  • HLT - Halt execution

Example Programs

Hello World

Regular Assembly:

MOV AX, 72     ; H
OUT AX
MOV AX, 101    ; e
OUT AX
MOV AX, 108    ; l
OUT AX
OUT AX         ; l
MOV AX, 111    ; o
OUT AX
HLT

Morse Assembly equivalent:

-- --- ...- / .- -..- --..-- / --... ..---
--- ..- - / .- -..-
-- --- ...- / .- -..- --..-- / .---- ----- .----
--- ..- - / .- -..-
-- --- ...- / .- -..- --..-- / .---- ----- ---..
--- ..- - / .- -..-
--- ..- - / .- -..-
-- --- ...- / .- -..- --..-- / .---- .---- .----
--- ..- - / .- -..-
.... .-.. -

Architecture

The Morse Assembly Language Virtual Machine provides:

  • 6 registers (AX, BX, CX, DX, SP, IP)
  • 1024 cells of memory
  • Stack operations
  • CPU flags (Zero, Sign, Carry)
  • Label resolution for control flow
  • Simple I/O operations

Implementation

The language is implemented in Python with two main components:

  • morse_interpreter.py - Virtual machine that executes .morse files
  • morse_assembler.py - Converts regular assembly to Morse assembly

The interpreter includes a complete Morse code encoder/decoder and can also be used as a standalone Morse code conversion utility.

Usage

Programs are saved with the .morse extension and executed using:

python morse_interpreter.py program.morse

The interpreter also supports encoding and decoding text:

python morse_interpreter.py --encode "Hello World"
python morse_interpreter.py --decode ".... . .-.. .-.. --- / .-- --- .-. .-.. -.."

Computational Class

Morse Assembly Language is Turing complete, as it provides:

  • Conditional and unconditional jumps
  • Arithmetic and logical operations
  • Memory access through registers
  • Stack operations
  • Input/output capabilities

Cultural Impact

The language serves as both a programming challenge and a tribute to Morse code, demonstrating how historical communication methods can be repurposed for modern computational tasks. It exemplifies the esoteric programming community's interest in exploring unconventional ways to express computational concepts.

External Links