- Notifications
You must be signed in to change notification settings - Fork0
Hi-Tech C 3.09 Patched and Ready to use
License
tsupplis/zxcc-htc
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Extended htc (c driver + libc + libf). expected to work with zxcc. It is in the processof realigning with the content ofhttps://github.com/agn453/HI-TECH-Z80-C. Differencesand improvements will be submitted up once parity is established.
The HI-TECH Z80 CP/M C compiler V3.09 is provided free of charge for anyuse, private or commercial, strictly as-is. 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.
Current Version zxcc-htc 3.09-P008 includes all the changes of HI-TECH-Z80-C v3.09-6
- Collection of fixes
- Added bootstrap for dos
- Added overlays
- Extended libraries and headers
The sources of the fixes needs to be documented ... It constantly aligns with (https://github.com/agn453/HI-TECH-Z80-C). Still a few differences but they are going to be cleaned out
- Trigonometry Functions Fixed (https://github.com/agn453/HI-TECH-Z80-C v3.09-1)
- Pipe Manager Integration (http://www.seasip.info/Cpm/software/index.html)
- Changes to memset/bdos/bios (https://github.com/agn453/HI-TECH-Z80-C v3.09-2)
- Further Changes from John Elliot/Jon Saxton (https://github.com/agn453/HI-TECH-Z80-C v3.09-3/4/4b) *** Some more changes ar still on going to be fully inline ***
- Addition of Overlays by Ron Murray
- libovl.lib has been added for overlay support
- stdint.h&unistd.h have been added
-AGenerate a self-relocating .COM program.-CGenerate object code only; don't link.-CR Produce a cross-reference listing e.g. -CRfile.crf-DDefine a symbol, e.g. -DDEBUG=1-ESpecify executable output filename, e.g. -Efile.com-FGenerate a symbol file for use with debug.com or overlay build.e.g. -Ffile.sym; default file name is L.SYM.-H Output help (the OPTIONS file) and exit.-ISpecify an include directory, e.g. -I1:B:-LScan a library, e.g. -LF scans the floating point library.-MGenerate a map file, e.g. -Mfile.map-OInvoke the peephole optimizer (reduced code-size)-OFInvoke the optimizer for speed (Fast)-RLink in command line wild card expansion code.-SGenerate assembler code in a .AS file; don't assemble or link.-UUndefine a predefined symbol, e.g. -UDEBUG-VBe verbose during compilation.-WSet warning level, e.g. -w5 or -w-2-XSuppress local symbols in symbol tables.-YGenerate an overlay output file (.OVR file-type)
memset()
The Hi-Tech C implementation of memset() is seriously broken and is almost guaranteed to give trouble in any program which uses it. The implementation simply does not agree with the function declaration.
bios()
The original bios() routine used the function number to construct an offsetinto the BIOS jump vector and from that calculated the address of theappropriate BDOS routine. Except for some character I/O routines, thatmethod of calling the BIOS is guaranteed to crash CP/M 3.A new bios() function has been implemented which checks for CP/M 3 and ifthat is the current operating system then it accesses the BIOS via thesanctioned method, i.e. by invoking bdos(50) with an appropriately filled-out parameter block.The standard bios() routine takes 1, 2 or 3 parameters: short bios(int func, int bc, int de)and that is good enough for CP/M 2.2. However CP/M 3 has functions whichalso take inputs in A and/or HL. The routine is smart enough to figureout where to put the parameters. All the C programmer needs to do is tosupply the requisite arguments in the right order.A bug in the 2.2 bios() routine has been fixed. The original code wouldalways return an 8-bit result even though there are some functions whichreturn 16-bit results.
bdos()
All versions of CP/M 80 return from BDOS calls with BA = HL regardless ofwhether the function is returning an 8-bit or 16-bit result. Hi-Tech Cprovided a bdos() call for 8-bit results and a bdoshl() call for 16-bitresults. John Elliott added a third, bdose(), for disk functions whichcould return extended error codes in H (and B) when running on CP/M 3.There is now a single bdos() function. It always returns a 16-bit resultin HL. The bdoshl() routine still exists for compatibility with oldersource files but it is simply an alias for bdos(). John Elliott'sbdose() routine no longer exists; bdos() also performs its functions.Some BDOS functions return 255 as an error flag. The old bdos() codewould sign-extend that to -1 (16 bit) but that is no longer done. if (bdos(fn, data) == -1) /* This won't work */ if (bdos(fn, data) == 255) /* This works sometimes */ if ((bdos(fn, data) & 0xFF) == 255) /* This always works */Under CP/M 3 several functions return extended error information inthe upper 8 bits of the return value. (Those functions also set thestandard errno global item.) Always use the third form when checkingfor an error result. The compiler is quite clever and doesn't make yourprogram work harder ... it just uses the L register.
Programs compiled with this update get wildcard expansion of the CP/Mcommand line automatically. There is no longer any need to call_getargs() explicitly.Enclosing an argument in quote marks (' or ") supresses expansion.This can be useful for programs like grep which may use ? and/or * intext search patterns or for program options containing a question mark: grep 'a.*end' *.h 2d:*.c grep "-?"The -R option passed to the Hi-Tech C compiler is no longer useful. (Itdidn't work anyway.)Implementing automatic argument expansion meant altering the order ofmodules in LIBC.LIB. That entailed rebuilding the entire library fromscratch. A script to do that is supplied.
The format of file name prefixes indicating drive letter and/or usernumber is now much more liberal. If a file "sample.txt" is on driveE: in user area 12 then depending on the current drive/user the filemay be accessed as: sample.txt if current DU: is E12: 12:sample.txt if current disk is E: e:sample.txt if current user is 12 e12:sample.txt 12e:sample.txt 12:e:sample.txt (Hi-Tech C format)Note that any of these forms is acceptable for program arguments, eventhose containng wildcard characters (?, *).
The case-insensitive string comparison function strcasecmp() has beenimplemented. Its function prototype is in string.h. It works just likestrcmp() except that upper- and lower-case letters are treated as identical. There is also a strncasecmp() analogue of strncmp() whichallows one to limit the comparison to a certain number of characters.stricmp is also defined as a symbol.
The functions toupper() and tolower() were implemented as macros whichadded a case-shift value to the character parameter without checking tosee if the parameter was a letter. To use these routines correctly it wasnecessary to do a range check, e.g. if (isupper(c)) c = tolower(c);These operations now invoke the correspondingly named routines in LIBC.LIBand it is no longer necessary to pre-test the character.
The stdio functions now allow files to be opened in modes "r+" and "w+" - ie, reading and writing are supported on the same file.Remember to fflush() or fseek() between a read and a write.This code is experimental.
exit(0) and _exit(0) set the CP/M 3 error code to 0.exit(n) and _exit(n) for non-zero n set the error code to 0xFF00 | (n&0x7F).The practical upshot is that exit(0) translates as "OK"; other values translate as "error". You can use this in conjunction with CP/M 3'sSUBMIT features. If the next command in a .SUB file is preceded bya : character, it will be ignored: CPROG :OTHERwill only execute OTHER if CPROG exited with the value 0.
Programs automatically check for PIPEMGR when they load, and if itis present the C streams stdin, stdout and stderr are routed to theirPIPEMGR counterparts - no modification of the source is required.The special device files (CON: LST: PUN: and RDR:) are joined by RSX: (PIPEMGR stdin/stdout streams) and ERR: (PIPEMGR stderr stream). IfPIPEMGR is not present, these files behave like CON:The variable: extern char _piped;is nonzero if PIPEMGR is present.The command FOO <CON:will behave differently if PIPEMGR is present. If it is not present,then you get line-based input from the Hi-Tech C library. If PIPEMGRis present then you get character-based input from PIPEMGR.The line-based input in the library will now return EOF if a control-Zis typed on a line by itself. Previously it would never return EOF on line-based input.Unfortunately if you're using Simeon Cran's replacement ZPM3 then itdoes not allow control-Z to be typed on an input line.I'm not yet sure how to get round this.Remember that when PIPEMGR has parsed the command line, you may have a number of blank (zero-length) arguments.
Compiled programs exit gracefully if run on an 8080 or 8086 processor,or if there is not enough memory for the program and its static data.This is done in the CRTCPM.OBJ module.
The variable extern void *_z3env;is 0 if one is not present, or its address if one is. It also passes itas a third parameter to main(): int main(int argc, char **argv, void *z3env);The Z3 environment address must be passed to the program in HL.
Under CP/M 3, getenv() uses the search path set by SETDEF to locate theENVIRON file. So if you like to keep ENVIRON on a drive that isn't A:, programs will still find it.
The header file has been changed to reflect the availablefunctions in LIBC.LIB. There are still missing routines -namely strcoll() strcspn() strpbrk() and strspn() and thesehave been commented out for now.
strchr() and strrchr()
char *strchr(char *s, int c) char *strrchr(char *s, int c)These functions - as well as index() and rindex() (which are identical)previously returned a NULL for no match. The functions now returna pointer to the character string's ending NUL character.
stricmp() and strnicmp()
char stricmp(char *s1, char *s2) char strnicmp(char *s1, char *s2, size_t n)Case-insensitive versions of strcmp() and strncmp() comparison routines.Can also be referenced as strcasecmp() and strncasecmp().
strstr(), strnstr(), stristr() and strnistr()
char *strstr(char *t, char *s) char *strnstr(char *t, char *s, unsigned int n) char *strcasestr(char *t, char *s) char *strncasestr(char *t, char *s, unsigned int n)These extra functions locate the first occurrence of string s instring t. The functions strnstr() and strcasestr() read at mostn characters from the string t. The functions strcasestr() andstrncasestr() use case insensitive comparisons.All these functions return a pointer to the first character ofthe first occurence of string s in string t if found, and NULLotherwise.
strdup()
char *strdup(char *s)Allocates a new buffer for and copies the string pointed toby s to it. Returns a pointer to the copy of the string or NULLif the memory allocation failed. The memory block can be releasedusing free().
strtok()
char *strtok(char *s, char *tok, size_t toklen, char *brk)Copies characters from s to tok until it encounters one of thecharacters in brk or until toklen-1 characters have been copied(whichever comes first). It then adds a NUL character to theend of the string. This is a non-conforming POSIX function.
Now includes a prototype for strftime() - see below.
strftime()
size_t strftime(char *s, size_t maxs, char *f, struct tm *t)Converts a time value t to a string using the format string finto the string s of size maxs (including a terminating NUL).It acts as a sprintf() function for date/time values. Thefollowing are valid in the format string - %A full weekday name (Monday) %a abbreviated weekday name (Mon) %B full month name (January) %b abbreviated month name (Jan) %c standard date and time representation %d day-of-month (01-31) %H hour (24 hour clock) (00-23) %I hour (12 hour clock) (01-12) %j day-of-year (001-366) %M minute (00-59) %m month (01-12) %p local equivalent of AM or PM %S second (00-59) %U week-of-year, first day sunday (00-53) %W week-of-year, first day monday (00-53) %w weekday (0-6, sunday is 0) %X standard time representation %x standard date representation %Y year with century %y year without century (00-99) %Z timezone name %% percent signthe standard date string is equivalent to: %a %b %d %Ythe standard time string is equivalent to: %H:%M:%Sthe standard date and time string is equivalent to: %a %b %d %H:%M:%S %Ystrftime() returns the number of characters placed in thebuffer, not including the terminating NUL, or zero if morethan maxs characters were produced.
The getenv() function was not correctly looking up the location ofthe environment file under CP/M 3 for the "default" entry in the drivesearch chain. It will now locate the ENVIRON file if you have set-upthe default search chain with a default entry. For example; Set search chain to current drive, RAMdisk, C: then A:setdef * m: c: a:in your CP/M 3 PROFILE.SUB file (or manually entered on the command line).
Andrey Nikitin has contributed the sources for the DEHUFF and ENHUFF programs that were used by HI-TECH Software to distribute the library source files. I've placed the extracted source files and the resulting binary produced by the latest compiler in the huff folder. Also, the Huffman-encoded archive containing these sources has been placed in the dist folder as HUFF.HUF. These sources may be built using the HI-TECH C compiler or using the gcc compiler under Linux or macOS. I built them natively under CP/M using -```c -O -v enhuff.c encode.c misc.cc -O -v dehuff.c decode.c misc.c```
Merged a minor change into doprnt.c so that various printf() routines can now output strings greater than 255 characters.
Included Jon Saxton's version of the PIPEMGR RSX for handling pipes under CP/M 3.This is a modified version of the original by John Elliot that's detected and used by each of the releases of HI-TECH C available from this repository.Also included is the source and executable for TEE which has the PIPEMGR RSX attached and behaves like its namesake in the Unix world, along with missing files from the original Van Nuys tools (PIPEMGR.H and PIPEMGR.C).The rest of the Van Nuys tools are available from John Elliot's original PIPEMGR page athttp://www.seasip.info/Cpm/software/Pipemgr/index.html
About
Hi-Tech C 3.09 Patched and Ready to use