planckforth:从手写的微型 ELF 二进制自举 Forth 解释器

发布: (2026年2月16日 GMT+8 19:44)
2 分钟阅读

Source: Hacker News

PlanckForth:从手写 1KB 二进制启动解释器

构建方法

只需要 xxd 就可以构建 PlanckForth。

git clone https://github.com/nineties/planckforth.git
cd planckforth
make
# Makefile 会执行:
# xxd -r -c 8 planck.xxd > planck
chmod +x planck

其他语言的实现位于 others 目录。

Hello World

直接运行这个小二进制:

./planck
kHtketkltkltkotk tkWtkotkrtkltkdtk!tk:k0-tk0k0-Q

使用 bootstrap.fs 引导后:

./planck  b)

内置词

Word含义栈效应描述
=等于( a b — c )c = (a == b)
(左移( a b — c )c = a > b(逻辑)
%算术右移( a b — c )c = a >> b(算术)
v参数向量( — a‑addr u )参数向量及计数
V版本( — c‑addr )运行时信息字符串

二进制布局

binary layout

实现方式

实现方式构建命令测试状态
手写 ELF 二进制(i386‑linux)maketesting i386-linux-handwritten
Cmake ctesting c
Python 3.xmake pythontesting python

基准测试

请参阅 wiki 上的 Benchmarks 页面

0 浏览
Back to Blog

相关文章

阅读更多 »