4 ms·
I've recently been working on a CP/M emulator, and having a lot of fun working with the Aztec C compiler referenced in the list. It's strange to go back to old
by stevekemp 2y ago
I've recently been working on a CP/M emulator, and having a lot of fun working with the Aztec C compiler referenced in the list.
It's strange to go back to old-school function definitions:
main(argc, argv)
int argc;
char *argv[];
{
But a C compiler in only 40k, assembler in 20K, and linker in another 20K is a whole world of tiny software compared to what we use right now.
- pjmlp 2y agoAround 2000 the HP-UX 10 aC compiler that we had available, still wasn't fully ANSI/ISO C89 compliant for function declarations, talk about taking its time.
- nineteen999 2y agoThe Hi-Tech C compiler for CP/M works quite well also, and generates pretty compact code. sdcc can be used to cross-compile for CP/M from a modern PC, if you provide a crt0.rel and libc. I rolled my own and was able to port a few useful programs and utilities with it.
- anthk 2y agoYou might like this: https://t3x.org/t3x/0/index.html https://t3x.org/t3x/0/index.html Pascal like language, compiles at Unix and to DOS and CP/M, it can be run under CP/M too. It can compile both binaries and bytecode. I ran a faithful Ladder port natively under a GNU Unix 386, it's really good: https://t3x.org/t3x/0/programs.html https://t3x.org/t3x/0/programs.html
- nineteen999 2y agoI took a look at T3X a while back, it looked really interesting. Thanks for reminding me. My greatest claim to fame was embedding a Z80 emulator in Unreal Engine, extending it with TCP/IP and VT100 emulation, and being able to connect to BBS's on the internet, and run Rogue, Zork and Wordstar along with most other Z80 CP/M software: https://i.imgur.com/aSc9VGL.png https://i.imgur.com/aSc9VGL.png https://i.imgur.com/dd0Nzo2.png https://i.imgur.com/dd0Nzo2.png https://i.imgur.com/Usjd4Vk.png https://i.imgur.com/Usjd4Vk.png https://i.imgur.com/Y5aIjCi.png https://i.imgur.com/Y5aIjCi.png https://i.imgur.com/rIY1he8.png https://i.imgur.com/rIY1he8.png (yes I know color CP437/ANSI graphics was not a thing on 8080/Z80 CP/M. But it was not difficult to make it work and it looks pretty in Unreal).
- stevekemp 2y agoI haven't gotten round to trying the Hi-Tech compiler yet, primarily because it won't run under my emulator. I just added a couple of missing syscalls but the only output I see is "Out of memory". (Removing the "-v" flag causes it to generate some submit files, with $$$ suffix, but I don't yet support those in my CCP.) I'll try it on real hardware next week and if it works there I guess that'll be another fun bug to hunt down!
- nineteen999 2y agoI didn't bother with emulating CP/M itself, just the Z80 CPU+RAM and disk interface, which I made compatible with Udo Munk's z80pack. I was able to use the stock z80pack BIOS/BDOS so I didn't have any issue getting it to run. You are going deep!
- stevekemp 2y agoYeah I'm doing things the hard way, for sure! But the project grew little by little, and I'm enjoying the process. (And it has to be said one of the reasons I'm interested is because I have a Z80-based single-board computer which runs CP/M natively which helps for testing things.)
- kragen 2y agohave you tried bds c? it's fully free software now, runs under cp/m, and is reputed to be much nicer than aztec c, so i'm curious to hear your point of view fwiw i suspect implementing only ansi c function headers and declarations would result in a slightly smaller c compiler than implementing only the k&r style ones
- stevekemp 2y agoI downloaded it thanks to your comment, from this site: http://www.cpm.z80.de/develop.htm http://www.cpm.z80.de/develop.htm Worked first time to create a simple "Hello World" program, but many of the included examples fail to compile for me, with random errors: RM.C: 20: String too long (or missing quote) CP.C: 56: Curly-braces mismatched somewhere in this definition I'll have to explore more thoroughly later, but thanks for the prod!
- kragen 2y agohmm, that's disappointing! are there in fact missing quotes and mismatched curly braces in those files? i wonder if you got a corrupted copy of the compiler
- stevekemp 2y agoThe code looks good, there seems to be some surprises with files that use "#include <stdio.h>" or similar. The include-lines are the ones the errors refer to - but since those files come with the compiler distribution I'd have expected their contents to be well-formed. I removed the includes from a few files, changed FILEs to ints, and added "#define EOF -1", etc, which let some more simple code compile & link. But it felt like those changes shouldn't have been necessary. I guess the good news is the compiler ran without me having to add any new CP/M syscalls/bdos functions to my emulator - unlike hisoft which required that I implement "T_GET" (Get date and time) and a couple of other functions I'd been missing such as F_SIZE (For getting a file size).
- kragen 2y ago
- fuzztester 2y agoTurbo Pascal 3.x - under 40K, w/ basic text editor built-in. But could only create .COM files, not .EXEs. Lightning-fast DX.
- kragen 2y agothere's no such thing as a .exe file
- cowboylowrez 2y agono, I've seen them, they exist.
- kragen 2y agoyou can't run them on cp/m
- cowboylowrez 2y agoTIL! so if I wanted to save an exe to cpm, would "3x3" as a file extension work instead? are there other prohibitted file name extensions?
- kragen 2y agooh, you can store them on a cp/m disk, you just can't run them under cp/m
- fuzztester 2y agoOf course there was, and is.
- kragen 2y agonope, totally not a thing in cp/m, sorry
- fuzztester 2y ago>It's strange to go back to old-school function definitions: Ha ha, yes. The first edition of The C Programming Language book by Kernighan & Ritchie (the book popularly called just K&R) used those definitions. The second edition (the ANSI C one) used the latter kind of definition, the ANSI kind, with both function arguments and return values having (mandatory?) types. I remember I used to religiously use the latter kind from as soon as the C compilers I used, supported them.