turbotools 1.4 -- native tools for TurboDOS object code
=======================================================

Three programs for working with TurboDOS systems and the object code they
are built from, without a CP/M emulator:

    gen         link a TurboDOS system, as Software 2000's GEN does
    disasm      relocation-aware Z80 disassembler
    serial      stamp serial numbers and absolute symbols into REL files

These are the tools that have to know something about TurboDOS.  The
format-generic ones -- an assembler, a linker, a librarian, and the
utilities that inspect and compare REL files -- are a separate package,
REL_tools, which this one depends on.


Why they are separate from REL_tools
------------------------------------

The test is what a program has to know.

mz80 and mlink need to know the REL object format and nothing else; they
work on anybody's object files.  gen needs to know that TurboDOS has six
segment classes of its own invention and that a .PAR file may patch any
symbol by name after the link.  disasm carries TurboDOS's inline message
convention, its string idioms, and the shape of its drive specification
modules.  serial knows that a serialised module carries ?ORIG? and ?UNIT?
as absolute publics.

None of that belongs in a general REL toolkit, and a general REL toolkit
is no use without it if TurboDOS is what you have.  Hence two packages.


What they are for
-----------------

**gen** links a system: it reads a .GEN configuration file, the modules
that file names, and a .PAR file of symbolic patches, and writes a .COM,
a .SYS or an Intel HEX image.  It is checked against the original the
only way that settles anything -- seven shipped configurations linked
both ways and compared byte for byte.

**disasm** is not built on a conventional disassembler, and that is the
point.  A disassembler working from a flat binary has to guess which
words are addresses and which are constants, and it guesses wrong often
enough to matter.  A relocatable object does not require the guess: the
file says which words are relocated, a relocated word is a pointer and
never an immediate, and its target is a label site.  The relocation map
is the code/data oracle.  Disassembly is recursive descent from every
public and every relocated word, then a linear sweep over the remainder,
with a coverage report saying how much each pass accounted for.

**serial** adds, changes and removes absolute public symbols.  This is
how a module can both define and reference a symbol -- something no
MACRO-80 source file can express, since a symbol is EXTRN or PUBLIC and
never both.  Anyone reconstructing such a module needs to know that, or
they will write EQU/PUBLIC into the source and be unable to reproduce
the two modules that need it most.


What changed in 1.4
-------------------

A documentation release, paired with REL_tools 1.7.  A comment in
disasm.c no longer names a particular vendor's boards.  gen, disasm and
serial produce what they produced; the only difference in disasm's
output is the version, 1.4, in each generated file's header.


What changed in 1.3
-------------------

A hardening release, paired with REL_tools 1.6 and its TESTPLAN.md.
gen and disasm produce what they produced; what changes is what the
three programs refuse and what they survive.

serial refuses a value that is not a number in range: -s x/y stamped
origin 0 unit 0 and -D X=ZZ defined X as 0, without a word.  disasm no
longer writes past its label and reference arrays when an object's
entry point or a relocated operand points beyond the segment, which
20,000 mutated objects under AddressSanitizer found 447 ways to make it
do.  gen closes the streams it opens to probe for SRC.GEN and SRC.PAR
and frees the module paths it reads.  All three read their files
through librel's rel_slurp(), which refuses a directory and an empty
file, and inherit librel's new rejection of a COMMON-typed item in a
module with no COMMON block, which gen used to dereference as a null
pointer.  tests/cli.sh, run by "make test", holds the command-line
contract: usage, unknown options, bad files, every numeric option
against every malformed value.


What changed in 1.2
-------------------

No change to the programs' sources.  Two things change what you get:

gen links against REL_tools 1.5's librel, which fixes a loader bug gen
inherited: a word in one COMMON block naming a label in another was
deposited into the other block, silently.  No shipped TurboDOS module
does this and every image relinks byte-identically; a new driver might.

The Makefile stamps the compiler's target and makes every object depend
on it, so a native make in a tree last built for another CPU rebuilds
the tree instead of linking objects of two architectures together.


Building
--------

    make ; sudo make install

Needs REL_tools.  If a REL_tools source tree sits beside this one the
build uses it directly; otherwise it builds against an installed copy:

    make RELPREFIX=/usr/local

No configure script.  Builds with gcc 13 on Linux and clang 19 on
FreeBSD, -std=c2x, warning-free.  PREFIX, DESTDIR, CC and CFLAGS are
honoured.  Other targets: test, sanitize-test, manual, dist.

The comparison against the original GEN needs the TurboDOS
reconstruction's sources and a CP/M emulator; it is skipped with a note
when they are absent.  The behavioural tests run anywhere.


Platforms
---------

    x86-64 Linux     gcc 13, glibc
    x86-64 FreeBSD   clang 19, LLD
    riscv64 Linux    gcc 13, cross-compiled and run under qemu-user, and
                     again with a native riscv64 gcc in a container

The RISC-V build is not a formality.  RISC-V makes plain char UNSIGNED,
where both x86 platforms make it signed, and these programs read a bit
stream a byte at a time.  What was measured there is the whole job, not
just the suite: gen linked the 193-module TurboDOS reconstruction into a
system image identical to the 22,272 bytes Software 2000 shipped, and
every one of the 199 objects assembled to the same bytes as on x86-64.

AddressSanitizer and valgrind do not work usefully under emulation and
were not run there; UndefinedBehaviorSanitizer does, and is clean over
the suite and the whole corpus.


Documentation
-------------

    turbotools_manual.pdf           the manual
    gen(1), disasm(1), serial(1)    man pages

For the object format itself, and for the assembler and linker, see
REL_tools -- its manual documents the REL bit stream in full.


Licence
-------

Two-clause BSD.  Copyright 2026 Robert Cousins.

Robert Cousins <rec@rcousins.com>
https://rcousins.com/pub/
