Zip

From Esolang
Jump to navigation Jump to search
Zip
Designed by User:KamilMalicki
Appeared in 2024
Computational class Turing-complete
Reference implementation https://github.com/KamilMalicki/Zip

Zip (or zipcc) is a minimalist AOT-compiled language created by Kamil Malicki. It bypasses the entire modern toolchain—no LLVM, no GNU Assembler, and no linker. The compiler (written in Node.js) directly emits raw x86_64 opcodes and manually constructs binary headers (ELF/PE).

Hardcore Specs

Raw Byte Emission

The compiler acts as a hex-emitter. It doesn't generate .s files; it pushes raw bytes into a buffer:

  • Arithmetic: Maps directly to 64-bit REX.W prefixed opcodes.
  • Registers:
    • r12: Hardcoded as the Base Pointer for the cell-array.
    • rax / rbx: Used for intermediate calculations and syscall arguments.

Binary Surgery

Zip is one of the few esolangs that handles OS-level ABI from scratch:

  • Linux Backend: Manually builds an ELF64 structure. It uses sys_mmap (syscall 9) to grab a 64KB page with PROT_READ | PROT_WRITE and executes a sys_exit (syscall 60) to clean up.
  • Windows Backend: Forges a Portable Executable (PE) header with a .text section. It relies on a ret (0xC3) convention to return control to the OS loader, avoiding the bloat of MSVC runtimes.

Memory Model

Each cell is a strict 64-bit word. Pointer indirection is handled via nested memory syntax $[ $[idx] ], which the compiler resolves into mov instructions with displacement.

Instruction Set

Syntax Machine Code (Example) Technical Effect
(= $[0] 1) 49 C7 04 24 01 00 00 00 MOV QWORD [R12], 1
(+ a b) 48 01 D8 ADD RAX, RBX
(in) 0F 05 (Linux) syscall for sys_read
(repeat) E9 [rel32] Native near jump for looping

Computational Class

Zip is Turing complete. The combination of an arbitrary-access cell array (infinite tape emulation) and repeat blocks with comparison flags (-e, -ne, -l, -g) satisfies the requirements for a Universal Turing Machine.

Examples

Self-Incrementing Pointer

(= $[0] 0)
(repeat (-e $[0] 100) (
  (= $[ $[0] ] 255)
  (= $[0] (+ $[0] 1))
))

Implementation

Created by Kamil Malicki. The toolchain is self-contained:

  • zipcc.js: The core logic (Lexer -> AST -> Bytecode Emitter).
  • No external dependencies: You only need node to compile; the resulting binary is 100% standalone.

External links