Related ToolsChatgpt

Developer Uses OpenAI Codex to Reverse Engineer a 1975 FORTRAN Compiler

OpenAI
Image: OpenAI

A 50-year-old FORTRAN compiler, written for a processor most people have never heard of, just got a thorough autopsy from an AI.

Developer Joe Allen, who maintains EXORsim (an emulator for Motorola's 1975 EXORciser development system), turned OpenAI's Codex loose on the raw binary of a resident Motorola 6800 FORTRAN compiler. The goal: decompile and comprehend machine code that predates the IBM PC by six years.

What Codex Actually Produced

The results are surprisingly detailed. Working from an S19 binary image (a hex-encoded firmware format from the era), Codex mapped out the compiler's entire architecture across nine major subsystems: startup and device initialization, statement recognition via keyword tables, expression parsing with 3-byte descriptors, symbol table management, diagnostic formatting, and a compact template-based object code emitter.

The AI identified specific memory addresses, traced call chains between routines, and even figured out that the compiler uses table-driven dispatch rather than hand-coded cascades for statement classification. It distinguished between the compiler's own object-record output layer and the source-language I/O handling for FORTRAN READ/WRITE statements, a subtle architectural distinction that requires genuine comprehension of the code's purpose.

Some of its conclusions are hedged with confidence levels. Allen's notes mark certain identifications as "strongest candidate" or "current best read," suggesting Codex provided probabilistic analysis rather than definitive answers. That honesty about uncertainty is arguably more useful than false confidence.

A Niche Use Case With Broad Implications

Reverse engineering old binaries is traditionally brutal work. The Motorola 6800 has a small instruction set (72 opcodes), but the compiler is densely packed with overlapping data tables, fixup chains, and multi-purpose routines. A human doing this manually might spend weeks on a single subsystem.

Codex appears to have produced a usable structural map of the entire compiler in a fraction of that time. It is not perfect - the keyword metadata table structure is still partially understood, and some function names are educated guesses. But as a starting point for further manual analysis, it is dramatically better than staring at raw hex dumps.

This is one of the more creative applications of large language models (LLMs, the AI systems behind tools like ChatGPT and Codex) for code comprehension. Most AI coding demos focus on writing new code. Using these models to read and explain code nobody alive fully understands anymore is a different kind of useful.