T3X

A Minimal Procedural Language

T3X9 | T3X/Z | T3Xr7 | XT3X | T3Xr8 | T3R3

T3X is a small, portable, procedural, block-structured, recursive, almost typeless, and to some degree object-oriented programming language. Its syntax is similar to Pascal, its semantics resembles BCPL's. The language is described in the book T3X – A Minimal Procedural Language, but here is a shorter introduction. Even more succinctly, here is the most minimal Hello World program:

DO t.write(T3X.SYSOUT, "Hello, World!

", 14); END

In fact T3X is a family of programming languages that share a common syntax, but offer different runtime environments and focus on different aspects of programming. All T3X compilers are small and fast and easily bootstrapped. Some of them support modules and separate compilation, some compile to machine code in a single step. The original compiler was targetted at the 16-bit Tcode machine, but native code backends for various processors exist.

T3X9

T3X9 is the smallest, fastest, and most minimalistic one of the T3X compilers. It self-compiles its own code (about 1600 lines of T3X) in about 0.05 seconds on a 750MHz machine. It runs on FreeBSD and targets the 386 CPU. It is a statement rather than a production tool.

T3X9 is also a good language for a first course in compilers! The book Write Your Own Compiler discusses the full source code of T3X9 on little more than 100 pages!

T3X/Z is a port of the T3X9 compiler for Z80-based computers running CP/M. It is a two-pass compiler that fits in 44KB of memory and self-compiles in about seven minutes on a 4MHz Z80 CPU (when using a RAM disk). No external runtime library is needed, all intrinsic functions are generated by the compiler. The compiler compiles directly from T3X to COM.

t3xz14.zip (65KB) This is the full source code to the compiler and the runtime library (in Z80 assembly language). The archive also includes a short T3X reference manual and a pre-compiled CP/M binary of the compiler. If you just want an executable compiler, have a look at the CP/NC Download Area.

T3X Release 7

Version 7.2.3 of the T3X compiler was the last version targetting the original Tcode machine. It was published in 2003 and never worked on 64-bit platforms except for the DEC Alpha. The 7.x versions offer a cleaned-up package that should compile on modern systems, like the x86-64 (although in 32-bit mode).

The T3Xr7 compiler is an optimizing compiler that targets the Tcode machine, the 8086 processor under DOS, the 386 processor under various Unix systems, as well as the Alpha AXP 21064 CPU under NetBSD. It is self-hosting under all supported systems. The T3Xr7 language supports modules and separate compilation. The compiler package even contains a tiny text-mode IDE.

Hello World The above T3X9 example programs will also run under T3Xr7 when adding the statements MODULE name(t3x); and OBJECT t[t3x]; at the top of the program. There are more examples in the source code archive. Lightweight Compiler Techniques is a book describing the predecssor of T3Xr7. It discusses the language, the compiler, and methods for implementing compilers in low-memory environments in general. The T3X 7.4.1 compiler bootstrapping kit (zip, ~580KB) contains the full compiler sources and all tools that are necessary for bootstrapping the compiler under Unix or DOS. A C compiler is needed on Unix, no additional tools are needed on DOS. The kit also contains the full documentation, example programs, and the book "T3X – A Minimal Procedural Language". The T3X 7.4.1 compiler DOS package (zip, ~470KB) is a set of pre-compiled DOS EXE files generated from the above source code. Extracted size: about 1220K bytes, i.e. it fits on a single 3.5" HD floppy disk, but no longer on a 5.25" HD floppy disk (although when removing the book text, it would fit easily). This package does not contain the compiler source code, but it can be used to re-build the code in the above boostrapping kit.

XT3X

The XT3X compiler is a version of T3X9 that is intended for writing simple, sprite-based video games as they were popular in the 1980's. It targets an extended Tcode9 machine that provides color graphics and sound and runs under X11.

T3X 8.1.7

T3X 8.1.7 (zip, ~500KB) was the last version of the T3X compiler back in the days. It provided support for 32-bit Tcode, thereby removing the 64KB code and 64KB data limits. The ports may suffer from bit rot, though, so you might want to try version 7.x instead.

T3 Release 3

T3r3 (zip, 67KB) was the last T3 compiler before the language was renamed T3X. This is really old and hackish code, but shows nicely where T3X has its roots.

contact | privacy