22.10.2019

Hi Tech C Compiler

10
  1. Hi-tech C Compiler User Guide

It may not be news for anyone but me, but I've put the Hi-Tech C v3.09 Libraries Source Code in my YAZ180 repository.It was quite a bit of work to get them into the modern world, via both a DOSBOX and CP/M DEHUFF tools, and I haven't seen these files elsewhere, so I thought it worthwhile to post them.Why are they interesting?There is a implementation, with complete.The fast (but inaccurate) implementation.And, and what the C compiler expects.I've also, in case there is interest to store them here in the docs section too. I understand that the library source, including the source for the tool, was distributed when the Hi-Tech C compiler was put into the public domain. The HI-TECH Z80 CP/M C compiler V3.09 is provided free of charge for anyuse, private or commercial, strictly as-is.

HI-TECH C Compiler for PIC10/12/16 MCUs - PRO fully implements the optimizations of Omniscient Code Generation™ - a whole-program compilation technology - to provide denser code and better performance on PIC MCUs. This ANSI C compiler integrates into Microchips MPLAB(R) IDE and is compatible with Microchip debuggers and emulators.

No warranty or productsupport is offered or implied.You may use this software for whatever you like, providing you acknowledgethat the copyright to this software remains with HI-TECH Software.The file I started with was. The annoying thing about the file is that it is a DOS self expanding archive. The expanded archive then needs to be DEHUFFed using the tool in the Z80V309.EXE file, on a CP/M machine. So there's a bit of shuffling back and forward.

Also of note I changed the file extension of the asm files from.as to.asm, and copied the C header files into the directories from the compiler executable directory for easy reference.Yes. I hope that some use can be made the source code, particularly of the CP/M stdio library. The only reason I am looking at the Hi-Tech C compiler is that it can read and write CP/M files from C. It would be great to have that capability in the z88dk CP/M new library.But as you say, there's a lot that can be done with this source. Hi-Tech C - Runtime OrganizationThe runtime environment of HI-TECH C is quite straightforward; this is to a large degree due to the C language itself. C does not rely on a large runtime support module, rather there are a few library routines which are basic to the language, while all other runtime support is via specific library packages, e.g. The STDIO library.

Runtime StartupThe starting address of a C program is always the lowest code address; for CP/M this is the base of the TPA, 0100h. The global symbol start is at this address. The code located at the start address performs some initialization, notably clearing of the bss (uninitialized data) segment. In the case of CP/M it also calls a routine to set up the argv, argc values. Depending on compile-time options, this routine may or may not expand wild cards in file names (? And a) and perform I/O redirection.Having set up the argument list, the startup code calls the function main.

Hi Tech C Compiler

Note the underscore ( ) prepended to the function name. All symbols derived from external names in a C program have this character prepended by the compiler. This helps prevent conflict with assembler names.

The function main is, by definition of the C language, the 'main program'. Stack Frame OrganisationOn entry to main, and all other C functions, some code is executed to set up the local stack frame. This involves saving non-temporary registers ( ix and iy for the Z80) and setting up the base pointer ( ix) to point to the base of the new stack frame. This is handled by a routine csv (or ncsv).

Then the stack pointer is adjusted to allow the necessary space for local variables. Typical code on entry to a function would be: call csvld hl,-10add hl,spld sp,hlThis will allocate 10 bytes of stack space for local variables. The stack frame after this code will look something like this:. arguments.

to. function.-. return. address.-. saved.

iy.-. saved. ix. C functions are initialised with ncsv and returned from with cret, which implements the previous description of the stack frame.;New csv: allocates space for stack based on word following;call ncsvncsv:pophlpushiypushixldix,0addix,splde,(hl)inchlldd,(hl)inchlexde,hladdhl,spldsp,hlexde,hljp(hl)cret:ld sp,ixpop ixpop iyretIf the optimiser is invoked ( -O or -OF) then, when the number of parameters is small, the csv function, followed by push hl operations to make space for function parameters, replaces the ncsv function, and the return code flow is also simplified.

Hi-tech C Compiler User Guide

Csv:pophl;return addresspushiypushixldix,0addix,sp;new frame pointerjp(hl).