Hasty Briefsbeta

Bilingual

Making portable my unportable transputer C compiler

2 days ago
  • The author found a floppy disk with a C compiler for transputer from 1998, which was compiled with DJGPP on a 32-bit system.
  • Attempting to compile the 1998 compiler on a modern 64-bit Macbook Air M1 revealed numerous portability issues due to 32-bit pointer and integer assumptions.
  • Key problems included interchangeable use of int and pointers, lack of function prototypes, and use of byte pools for structures instead of struct types.
  • The author rewrote the code using structs for include files, type copying, structure definitions, and variable definitions to fix pointer size issues.
  • A backport from the Am29000 C compiler replaced hard-coded byte offsets with proper structs, improving readability and portability.
  • The author fixed 25 errors related to pointer/int misuse, added fields to expression nodes, and replaced global/local variable arrays with structs.
  • After compilation succeeded on macOS, testing on a transputer emulator revealed bugs including an infinite loop from a faulty malloc implementation, fixed by adding RAM.
  • The final compiler generated identical assembler code on both macOS and the transputer emulator, proving successful portability.
  • The entire process took three days, and the repository shows commits from the original to the final portable version.