https://github.com/ibara/l80
CP/M and MS-DOS COM executable linker written in D.
https://github.com/ibara/l80
8080 8086 8088 coding cp-m cpm d dlang i80 i8080 intel linker loader ms-dos msdos programming retro x86 z80 zilog
Last synced: 9 months ago
JSON representation
CP/M and MS-DOS COM executable linker written in D.
- Host: GitHub
- URL: https://github.com/ibara/l80
- Owner: ibara
- License: isc
- Created: 2021-06-08T23:06:56.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-06-27T20:07:32.000Z (over 4 years ago)
- Last Synced: 2025-02-05T01:44:58.857Z (11 months ago)
- Topics: 8080, 8086, 8088, coding, cp-m, cpm, d, dlang, i80, i8080, intel, linker, loader, ms-dos, msdos, programming, retro, x86, z80, zilog
- Language: D
- Homepage: https://briancallahan.net/blog/20210609.html
- Size: 14.6 KB
- Stars: 40
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
l80
===
`l80` is a linker for CP/M and MS-DOS `COM` executables.
It reads in object files and libraries created by
[`a80`](https://github.com/ibara/a80)
and produces executable CP/M-80 binaries from them.
There are not (yet) any assemblers or compilers that
produce 8086 object code for `l80`. But when such programs
appear, `l80` will already be able to handle them.
You can read an in-depth explanation of how the linker and
object file format work
[here](https://briancallahan.net/blog/20210609.html).
Building
--------
`l80` should build with any
[D](https://dlang.org/)
compiler for any supported platform. I use
[GDC](https://gdcproject.org/)
on
[OpenBSD](https://www.openbsd.org/)
and that works well.
There is a port of `l80` to C that can be compiled for
CP/M, MS-DOS, and Unix. The C port has the following
differences:
* Only the first 15 characters of symbol names are unique.
* On CP/M, the binary is named `ld` to avoid conflict with
[Microsoft L80](https://altairclone.com/downloads/manuals/Microsoft%20L80%20Linker.pdf).
You can build this C version for CP/M with:
```
$ make cpm
```
For MS-DOS with:
```
$ make dos
```
And for Unix with:
```
$ make c
```
Running
-------
`usage: l80 binary file1.obj [file2.obj ...]`
All object files must end in `.obj` or `.lib`.
The `.com` extension will automatically be appended to
`binary`.
Object format
-------------
`l80` uses the most simple object format I could devise.
Object files are comprised of control codes and data. There
are three control codes:
* `00`: The following byte is literal data.
* `01`: The following bytes are a symbol declaration.
* `02`: The following bytes are a symbol reference.
`l80` uses two passes to generate the final execuatable
binary. The first pass writes all object files and libraries
into a single buffer and then collects all the symbol
declarations and calculates the address of each symbol. The
second pass writes out the executable, replacing references
with the addresses calculated during the first pass.
Libraries are simply collections of object files. They can
be created with the
[ar80](https://github.com/ibara/ar80)
utility.
Caveats
-------
`l80` does not recognize nor remove the code of unused
symbols. Doing so is planned.
The order of the object files and libraries can be very
important.
Compilers should implement name mangling for symbols not
destined to be globals to prevent spurious duplicate symbol
errors.
Bugs
----
Probably lots. Test and let me know.
License
-------
ISC License. See `LICENSE` for details.
Note
----
This `l80` is in no way related to the linker of the same
name produced by Microsoft, also targeting CP/M-80.
That one uses a very different file format.