Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HiSoft C 1.3 source resurrection

This repository is centered on the reconstructed and heavily documented Z80 assembler source of HiSoft C 1.3 for the ZX Spectrum:

src/cc.asm

The source assembles to the exact 25,600-byte compiler image contained in the original tape. Semantic labels, dot-prefixed local labels, routine contracts, record-layout explanations, pseudocode, and selective instruction comments are kept directly in the assembler source so it can be read as a literate program.

HiSoft C

Primary source and exactness

origin:                 25200 / $6270
length:                 25600 / $6400
exclusive end:          50800 / $C670
compiler SHA-256:       ac32d47e54198f2c2fd0995d55eb23e5d161908041cf72562f0293a062bd42a3
complete TAP SHA-256:   0d2cfbc1d07a4b7959fc1eb8b7a3d2f7d3f4112d92076a07c6bd41e43dc81c75

make verify assembles src/cc.asm, rebuilds the complete tape while preserving its original loader blocks, and checks byte-for-byte parity with original/code.bin and original/code.tap.

Build and verification

Requirements:

  • GNU Make
  • Python 3
  • z80asm 1.8-compatible assembler
  • a C99 compiler for the optional explanatory model

Run the complete verification suite:

make verify

Other useful commands:

make                 # same as make verify
make info            # list the blocks and headers in the reference TAP
make extract         # extract its compiler payload into build/original-cc.bin
make clean

A container build is also provided:

docker build -t hisoft-c .
docker run --rm hisoft-c

Source verification

The scripts in tools/ protect properties established during the resurrection:

  • exact compiler-image and full-TAP parity;
  • semantic, globally unique labels;
  • dot-prefixed labels for proven local control-flow targets;
  • routine-level literate headers across all callable entries;
  • stable chapter and record-layout introductions;
  • absence of mechanical disassembly address/byte trailers;
  • preservation of selected useful end-of-line comments.

The TAP helper replaces only the final 25,600-byte compiler block. All preceding loader and bootstrap blocks are copied unchanged from the original tape.

Explanatory C model

explanatory-c/ is a secondary tool for understanding src/cc.asm. It is a heavily commented, buildable C model of the compiler core, not the central source and not a byte-exact replacement.

It preserves the recovered architecture—four-byte token cache, fixed-width names, canonical type records, direct code generation, five-byte expression descriptors, operator-precedence stack, embedded branch patch chains, two-ended initializer staging, and dual output cursors—in a form that is easier to read. It deliberately omits the integrated editor, media/UI infrastructure, and the resident runtime linked into generated programs.

Build it independently with:

make -C explanatory-c check

See explanatory-c/README.md and explanatory-c/assembler-map.md for scope and correspondence with assembler labels.

Repository contents

src/cc.asm              primary resurrected compiler/editor/runtime source
Makefile                exact assembly, TAP rebuilding, and verification
tools/                  source and TAP verification tools
explanatory-c/           secondary compiler-only explanatory C model
original/                original compiler binary, TAP, screen and loader data
documentation/           manuals and historical articles
libs/                    original/example HiSoft C libraries and TAP files
extender/                historical extensions and disk images
c2tap/                   source-to-TAP utility

The obsolete mechanical disassembly sources formerly stored as root cc.asm and original/code.asm, together with original/blocks.txt, are intentionally removed. src/cc.asm is the maintained source.

Historical notes

HiSoft C uses the older K&R C dialect. The repository retains the original manuals, libraries, examples, extension media, and conversion utilities for historical study and experimentation on ZX Spectrum emulators or hardware.

About

Disassembled code of HiSoft C compiler for ZX Spectrum

Topics

Resources

Stars

33 stars

Watchers

6 watching

Forks

Releases

Packages

Contributors

Languages