hn.today

Turbo Pascal Compiler Written in Turbo Pascal

turbo51.com6 points0 comments
Screenshot of Turbo Pascal Compiler Written in Turbo Pascal

TPC16 is a Turbo Pascal 7 command-line compiler implemented from scratch in Turbo Pascal, not Borland’s original source code. It aims to match Borland’s compiler both in the Pascal programs it accepts and in the Turbo Pascal unit and 16-bit x86 executable files it produces. Its developer presents it as a practical way to study compiler construction through a complete, working implementation: the code demonstrates scanning, parsing, symbol tables, scopes and units, expression processing, error reporting, inline assembly, intermediate code, register-limited code generation, optimization, and linking. Written in Turbo Pascal 7, it can compile itself in principle, though its size and DOS memory limits mean it must be built with the protected-mode BPC.EXE compiler rather than TPC.EXE.

The compiler is a DOS program that uses segment-and-offset addressing; it does not generate executable map files or debug information. A demo executable is available, and many parts of the source are published with explanations, but the complete source package is sold. The developer argues that examining its named data structures and algorithms can help readers build or extend their own compilers, although no detailed textbook is included. TPC32 is offered as a more flexible successor: it compiles with Delphi 7, replaces many 16-bit data-management constraints, supports long filenames, and still generates 16-bit x86 code. It also provides a starting point for Turbo51, a Pascal compiler for 8051 microcontrollers.

Read on turbo51.com0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Aristotle Expands into Rust

Aristotle has expanded its formal verification platform to Rust, allowing developers to prove code meets specifications and contains no undefined behavior, including in unsafe blocks. It can also verify that Rust rewrites behave like their original C code, targeting critical software such as smart contracts and infrastructure. (harmonic.fun)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.