No description
Find a file
Justine Tunney 5a33a6b97a Add garbage collection (now 470 bytes)
This GC wraps Eval() to create a copy of the result, and then
memcpy's it backwards to the position where the g_mem pointer
resided at the beginning of Eval() thereby discarding all the
cons cells that got created which weren't part of the result.
Overlap (or negative GC) isn't possible because we don't copy
cells beneath the low water mark.

As it turns out 44 bytes is all you need to implement garbage
collection when your language guarantees that data structures
can't have cycles, due to the lack of mutability.
2021-11-21 09:21:53 -08:00
bin shave two bytes, fix memory init 2021-11-15 21:05:27 -08:00
test test files added 2021-10-03 17:03:58 +02:00
.gitignore Initial import 2020-10-26 18:21:15 -07:00
bestline.c Improve LISP/C/ASM Rosetta Stone consistency 2021-10-30 00:42:55 -07:00
bestline.h Improve LISP/C/ASM Rosetta Stone consistency 2021-10-30 00:42:55 -07:00
LICENSE Remove old code and update documentation 2021-10-08 21:26:31 -07:00
lisp.c Fix regression in C code for PrintList() 2021-11-16 00:05:30 -08:00
lisp.lisp Fix extra arg in LISP evaluator 2021-11-13 15:16:37 -08:00
Makefile Shave another sixteen bytes (now 426 bytes) 2021-11-17 08:41:36 -08:00
README.md Remove old code and update documentation 2021-10-08 21:26:31 -07:00
sectorlisp.S Add garbage collection (now 470 bytes) 2021-11-21 09:21:53 -08:00

sectorlisp

sectorlisp is a 512-byte implementation of LISP that's able to bootstrap John McCarthy's meta-circular evaluator on bare metal.

Yo dawg, I heard you like LISP so I put a LISP in your LISP so you can eval while you eval

Overview

LISP has been described as the Maxwell's equations of software. Yet there's been very little focus to date on reducing these equations to their simplest possible form. Even the original LISP paper from the 1960's defines LISP with nonessential elements, e.g. LABEL.

This project aims to solve that by doing three things:

  1. We provide a LISP implementation that's written in LISP, as a single pure expression, using only the essential functions of the language. See lisp.lisp. It's the same meta-circular evaluator in John McCarthy's paper from the 1960's, except with its bugs fixed, dependencies included, and syntactic sugar removed.

  2. We provide a readable portable C reference implementation to show how the meta-circular evaluator can be natively bootstrapped on POSIX conforming platforms, with a pleasant readline-like interface. See lisp.c.

  3. We provide a 512-byte i8086 implementation of LISP that boots from BIOS on personal computers. See sectorlisp.S. To the best of our knowledge, this is the tiniest true LISP implementation to date.

Binary Footprint Comparison

Getting Started

See lisp.lisp for code examples that you can copy and paste into your LISP REPL.

You can run the C implementation as follows:

$ make
$ ./lisp

After running make you should see a sectorlisp.bin file, which is a master boot record you can put on a flopy disk and boot from BIOS. If you would prefer to run it in an emulator, we recommend using Das Blinkenlights.

curl --compressed https://justine.lol/blinkenlights/blinkenlights-latest.com >blinkenlights.com
chmod +x blinkenlights.com
./blinkenlights.com -rt sectorlisp.bin

Alternatively you may use QEMU as follows:

qemu-system-i386 -nographic -fda sectorlisp.bin

Further information may be found on our wiki.

Demo

booting sectorlisp in emulator

The video above demonstrates how to boot sectorlisp in the blinkenlights emulator, to bootstrap the meta-circular evaluator, which evaluates a program for finding the first element in a tree.

You can watch the full demo on YouTube.