Closed Fabrizio-Caruso closed 5 years ago
You can build plain binaries, but it's intrinsically problematic and so is undocumented.
Try building something with ack -mcpm -v -v
. You'll see the raw commands used to do the compilation. Run these commands directly from your build script, rather than calling ack
, but change the linker arguments to match the layout of your platform, and swap out references to libsys (both in the linker and in the #include paths) with one of your own --- see plat/cpm/libsys
.
The reason why it's problematic is that there's really no such thing as platform-independent compiled C, which means that no matter what you do you're still linking against the CP/M libc, which may not be configured for your platform. If the assumptions in the configuration don't match your platform, bad things happen. But you can make it work, provided you're careful about which libc functions you call.
In the future, could you please provide a command to just build plain 8080 with no lib support? I mean no support for any libc function (no printf, no getchar, etc. just ANSI C keywords). Just a plain ANSI C compiler with 8080 as target. That alone, would help a lot.
SDCC provides platform-independent libraries written in plain ANSI C. I wonder whether one could copy them (legally) and then adapt them to other 8080/68000/386-based platforms.
We would also need a compilation option to let the coder select the start address of the binary (which can be different on each 8080 target).
@davidgiven I am closing this because it is already tracked in #82.
It seems that ack can build a few targets but I do not see options to build plain raw binaries.
For example, there are maybe 100 different 8080-based non-CP/M different computers, for which ack could build something even if there is no lib support. One could a binary by implementing whatever input/output is required for a specific computer.
Ideally something like SDCC could be the solution. They implement generic standard C libraries with no implementation of getchar, putchar, etc., which has to be provided by the coder.