Image Map Image Map
Results 1 to 5 of 5

Thread: Programming in C with Mike Stump's ZC 2.0

  1. #1

    Default Programming in C with Mike Stump's ZC 2.0

    While this may be more of a programming question, it's specific to the TRS-80 so this seems to be the place to ask.

    Has anyone here every used Mike Stump's shareware ZC from 1987 for C programming?

    Aside from being in disk collections, I can't find any mention of it anywhere: not on comp.sys.tandy, and not here. The only other versions of C for the TRS-80 are Alcor C, which creates p-code (!), and Misosys LC, which requires LDOS.

    Anyway, I downloaded it and have been playing with it on an emulator, and I think it's a really interesting system, especially for a shareware one. It consists of zc, the K&R C compiler, zas, a very simple assembler, zlink the linker, and a bunch of /lnk library files.

    Some notes:

    Most of the instructions are spent explaining what it can't do rather than what it can. But I found that actually it's reasonably complete, and find it easy to write file-based programs that run on any DOS without much problems. A sample program is included, and that program (a RS-232 terminal) is sophisticated enough to show off its capabilities. (And that source is the ONLY clue to some of them.) All the C file redirection of standard i/o seems to work. No direct float support, but there are libraries that use the ROM's.

    Mike Stump clearly wrote it on a Model III: not only does it come on a TRSDOS 1.3 disk, but all executables use many Model III-specific RAM addresses like the top-of-memory and the command line. But I was able to make a Model I version by patching all "4411" bytes to "4049" and "4225" to "4318" (in zc/cmd, zas/cmd, zlink/cmd, and stdio/lnk, which is the C runtime.)

    The linker is hilarious: whenever it hits an external function, it just asks YOU what the name of the library file is! The whereisz/doc file lists where each function is in which library. Note that some functions are in multiple libraries--you have alternates to choose from. And even then it expects you to PATCH (or SUPERZAP) in the end-of-program address.

    But anyway it's a really neat system to make TRS-80 programs with C. For instance, I used ZC to write TRS-80 version of tenox's "aclock" program, which draws a live clock in text mode. I submitted it, and tenox accepted it!

    You can find the source here:
    https://github.com/tenox7/aclock/blo...trs80-model1.c
    https://github.com/tenox7/aclock/blo...trs80-model3.c

    And cmd files here:
    https://github.com/tenox7/aclock/blo...s80-model1.cmd
    https://github.com/tenox7/aclock/blo...s80-model3.cmd

    One thing I would love to see would be the original source of the compiler, since it was clearly self-hosted. I wonder if anyone knows Mr. Stump and can ask him?

    John D.

  2. #2
    Join Date
    Jun 2010
    Location
    Vancouver, BC, Canada
    Posts
    363

    Default

    I haven't heard of ZC before -- quite interesting.

    Being curious about the code generation I did a quick disassembly of the Model III aclock. Some of the small subroutines jumped out at me, especially this one:

    Code:
    _595b:		ld	a,e	
    		rla			
    		ld	e,a			
    		ld	a,d			
    		rla			
    		ld	d,a			
    		or	e		
    		ret
    The Z-80 can do it a little better (rl e; rl d; ld a,d; or e; ret) but mostly because it is the same subroutine I saw diassembling a Model II program called diag68. There were two little subroutines just before it that are identical. Could be just a coincidence, but I do wonder if the Model II program was built with ZC or if they share some common heritage. Which might only be a set of 8080 subroutines from CP/M or something.

    Except for the pain of pointing things out to the linker it looks to be a lighter-weight alternative to the larger C compilers.

  3. #3

    Default

    First I've heard of ZC myself, thanks for the post!

  4. #4

    Default

    no I could not find any references aside software deposit (online & mine) about the C program for TRS-80, I wonder if I could use it to rework a source code I have for a BBS.. humm thanks for the heads up
    Gaming: i7-8700K, 16GB, 1TB SSD, RTX 2060, Dual 27" LG IPS Monitors.
    Vintage: TRS-80 MODEL 4, 128K RAM, 360K FDD, Gotek USB FDD, FreHD HDD, RS232-WIFI MODEM, DWP-510.
    Programmer: Dell Inspiron 660S i3-3220 with 16GB Ram, running a BK-844USB & EP-2A-88.
    Web Site: https://texastandyrestoration.com/
    Facebook Page: https://www.facebook.com/TexasTandyRestorations/

  5. #5

    Default

    In case this is the only place on the entire web that mentions ZC, I should mention this here.

    ZC has at least one serious bug: the pre- and post-increment/decrement operators, ++a / a--, do not work on global variables. They do work on function parameters and local variables, but not global.

    I found this as I've tried more C source in it. On looking at the assembly output, I can see what's happening, but the issue is a missing instruction, so it's not easy to patch the compiler. Without the source it can't be fixed. So you have to work around it and insert an extra a=+1; before or after instead.

    But the rest of it continues to work. Got the AES256 Encryption and Decryption from http://www.z80.eu/c-compiler.html and many other things working. With luck I can build a TRS-80 version of rswier's C4 C compiler and make C in C.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •