UCSD p-System、Apple Pascal以及跨平台兼容性的梦想
The UCSD p-System, Apple Pascal, and a dream of cross-platform compatibility

原始链接: https://markbessey.blog/2025/04/14/a-blast-from-the-past/

加州大学圣地亚哥分校的p-系统,开发于1974年至1978年,是一个可移植的操作系统、编译器和工具包,它围绕着一个“p-机器”(一种为Pascal设计的虚拟CPU)构建。它的可移植性源于一个小型、依赖于机器的内核,该内核模拟p-机器,允许整个系统轻松地适应各种平台,例如Apple II、IBM PC等等。虽然它不是第一个字节码解释器,但它是一个成功的早期实现,影响了Java和Infocom的Z-机器。 受到高中时期使用Apple Pascal的经历启发,作者计划重新审视p-系统:在模拟器中设置Apple Pascal,使用Rust开发用于与磁盘镜像之间传输文件的工具,开发一个p-机器模拟器(带反汇编器/汇编器),并可能将模拟器移植到像Arduino这样的微控制器上。这个项目是为了纪念p-系统即将迎来的50周年纪念日,它使用现代工具复兴了这件重要的计算史片段,对抗链接腐烂,并扩展其遗产。进一步探索的资源包括Hans Otten的《Pascal for Small Machines》、The Digital Antiquarian博客和杰斐逊计算机博物馆。

Hacker News 最新 | 往期 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 UCSD p-系统、Apple Pascal 和跨平台兼容性的梦想 (markbessey.blog) 7 分,来自 rbanffy,22 分钟前 | 隐藏 | 往期 | 收藏 | 讨论 加入我们,参加 6 月 16-17 日在旧金山举办的 AI 初创公司学校! 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系我们 搜索:

原文

I’ve been thinking about the UCSD P-System a lot lately, and I thought I’d write about it a bit, and about bytecode systems more-generally. And along the way, I hope to write some interesting code.

What’s the p-System?

Way back in 1974-1978, computer scientists at the University of California, San Diego campus developed a new portable operating system, compiler, and tools to run on both the PDP-11 minicomputers and the increasingly-common microcomputers. They called this UCSD Pascal, and it was available for a wide variety of systems, in just a few years.

The secret to its wide portability was that the system sat “on top of” a very small kernel of machine-dependent code, which implemented a “virtual machine” called the “p-machine”, a kind of imaginary CPU specifically designed to be a good target for a Pascal Compiler. Because this was a relatively-small amount of code, it was possible to port the entire operating environment, including the operating system, the compiler, editor, filesystem and other tools, just by implementing the p-machine emulator for a new machine.

You could get a version of the p-System for a huge variety of computers. Besides DEC’s PDP-11 and Rainbow, there were versions for the Apple II, the IBM PC (one of 3 OS options for it at the start), for HP’s series 80 and series 9000 workstations, Texas Instruments’ TI-99/4a home computer, CPM machines, various mainframes, and on, and on. Western Digital even created a microprocessor that ran p-machine code as its native machine language.

The p-System was not the first portable byte-code interpreter and compiler system – that idea goes very far back, at least to the origins of the Pascal language itself. But it was arguably one of the most-successful early versions of the idea, and served as an inspiration for future portable software systems (including Java’s bytecode, and Infocom’s Z-machine).

Where did I first encounter the p-System?

In 1986, during my Junior year of High School, I took a Computer Programming class. That was primarily taught in BASIC, because of course it was. After completing that class, I was essentially let loose in the computer lab for a period of “Independent study” (thanks, Mr. Carlson!), and that was where I got to use Pascal for the first time. Apple Pascal, running on the Apple IIe. At that point, I was also using Pascal in my first after-school job, using UCSD Pascal on the HP 80 and 9000 series workstations, and also Turbo Pascal on IBM PC-compatibles (not the p-System, but definitely inspired by it).

My “final project” for my Senior year was building a spreadsheet program in Apple Pascal. I managed to get a formula editor, including basic arithmetic functions, the grid display, and printouts all working before I graduated. Unfortunately, that code is lost to time.

What am I going to do with the p-System?

I have a couple of goals I’m hoping to accomplish here over the next few months:

  1. Get Apple Pascal up and running in some kind of emulator on my Mac, so I can experience it again
  2. Build some tools to transfer files to/from disk images for the emulator
    • These already exist, in various forms, but I really want to make my own, partly for the enjoyment of it, partly to have something simple to do in Rust to build familiarity with the language.
  3. Build a p-machine emulator, in Rust
    • and probably a disassembler/assembler, and the rest of the tool chain
    • maybe NOT a Pascal compiler, unless I get ambitious
  4. Port the p-machine emulator to something other than the Mac
    • Ideally, something small – like an Arduino or Raspberry Pi Pico

Why build new tools for such an old system?

Partly because I can, and partly because we’re coming up on the 50th anniversary of the UCSD P-System. Development started around 1974, and UCSD Pascal was first released in 1978. I think it’d be fun to build something new with/for that old system, which was really important to me getting started in my career.

And partly because, while there are tools out there, they’re often badly-documented (see link rot lament, below), and they often were built decades ago, at this point, and require compilation with gcc 2.x, for instance. I think it’d be nice to bring back some old system software, using “new” tooling, to hopefully extend the legacy of this system a bit longer.

Where can you find out more about the p-System?

There is a lot of information available on the Internet, in but it’s scattered everywhere, and a lot of it is suffering link rot these days. One site I found had tantalizing links to a bunch of books, specifications, and historical documents, 80% of which were 404 NOT FOUND. I’m going to add links to other sites to these blog posts as I run across them.

Probably the best place to start digging is Hans Otten’s web site, Pascal for Small Machines, which in addition to p-System information, has a bunch of historical information about other versions of Pascal on “small computers”, meaning mini- and micro-computers.

I found some very interesting historical information about Apple Pascal and the p-machine at The Digital Antiquarian blog. This is part of a series of articles that goes from Pascal, to the p-System, to Sir-tech software and Wizardry, a roleplaying game for the Apple II which was built with Apple Pascal.

The Jefferson Computer Museum has a page about the UCSD p-System, and links to several interesting collections of software.

联系我们 contact @ memedata.com