Dec 092017
 
Newest version of SMALL C. With source files.
File SC88.ZIP from The Programmer’s Corner in
Category C Source Code
Newest version of SMALL C. With source files.
File Name File Size Zip Size Zip Type
ABS.C 128 92 deflated
ATOI.C 384 212 deflated
ATOIB.C 512 289 deflated
AVAIL.C 512 272 deflated
CALL.MAC 768 435 deflated
CALLOC.C 384 245 deflated
CC.DEF 2944 1124 deflated
CC1.C 3584 1298 deflated
CC11.C 5756 2158 deflated
CC12.C 7552 2625 deflated
CC13.C 7296 2279 deflated
CC2.C 768 399 deflated
CC21.C 4736 1833 deflated
CC22.C 7552 2243 deflated
CC3.C 512 256 deflated
CC31.C 7040 1847 deflated
CC32.C 5376 1487 deflated
CC33.C 4608 1518 deflated
CC4.C 384 203 deflated
CC41.C 6016 2135 deflated
CC42.C 5248 1093 deflated
CC86.EXE 41322 14524 deflated
CEND.MAC 640 287 deflated
CLEARERR.C 256 175 deflated
CLIB.DEF 1664 695 deflated
CLIB.LIB 33792 10371 deflated
CSEEK.C 1152 554 deflated
CSYSLIB.C 8064 2755 deflated
CTELL.C 1280 623 deflated
DTOI.C 512 259 deflated
EPILOG.H 13 13 stored
EXIT.C 640 406 deflated
FCLOSE.C 512 287 deflated
FEOF.C 384 215 deflated
FERROR.C 256 167 deflated
FGETC.C 896 429 deflated
FGETS.C 1920 648 deflated
FOPEN.C 768 393 deflated
FPRINTF.C 2432 814 deflated
FPUTC.C 640 373 deflated
FPUTS.C 384 237 deflated
FREAD.C 896 358 deflated
FREE.C 512 284 deflated
FREOPEN.C 768 368 deflated
FSCANF.C 2816 937 deflated
FWRITE.C 1024 397 deflated
GETARG.C 768 367 deflated
GETCHAR.C 256 144 deflated
ISALNUM.C 256 120 deflated
ISALPHA.C 128 106 deflated
ISASCII.C 256 131 deflated
ISATTY.C 256 116 deflated
ISCNTRL.C 256 143 deflated
ISCONS.C 256 142 deflated
ISDIGIT.C 128 97 deflated
ISGRAPH.C 128 105 deflated
ISLOWER.C 128 102 deflated
ISPRINT.C 128 107 deflated
ISPUNCT.C 256 169 deflated
ISSPACE.C 256 148 deflated
ISUPPER.C 128 104 deflated
ISXDIGIT.C 256 138 deflated
ITOA.C 512 285 deflated
ITOAB.C 512 304 deflated
ITOD.C 768 345 deflated
ITOO.C 640 310 deflated
ITOU.C 768 368 deflated
ITOX.C 640 327 deflated
LEFT.C 256 125 deflated
LEXCMP.C 1536 607 deflated
LIBMAKE.TXT 640 290 deflated
MALLOC.C 384 211 deflated
NOTICE.H 173 134 deflated
OTOI.C 384 236 deflated
PAD.C 256 168 deflated
POLL.C 384 224 deflated
PROLOG.H 256 86 deflated
PUTCHAR.C 256 150 deflated
PUTS.C 256 152 deflated
README.DOC 6216 3019 deflated
RENAME.C 768 380 deflated
REVERSE.C 256 165 deflated
REWIND.C 256 132 deflated
SIGN.C 256 109 deflated
STDIO.H 384 165 deflated
STRCAT.C 256 134 deflated
STRCHR.C 256 129 deflated
STRCMP.C 256 138 deflated
STRCPY.C 128 97 deflated
STRLEN.C 128 97 deflated
STRNCAT.C 384 175 deflated
STRNCMP.C 384 201 deflated
STRNCPY.C 384 168 deflated
STRRCHR.C 384 195 deflated
TOASCII.C 128 75 deflated
TOLOWER.C 256 111 deflated
TOUPPER.C 256 115 deflated
UNGETC.C 384 249 deflated
UNLINK.C 384 258 deflated
UTOI.C 384 237 deflated
XTOI.C 768 338 deflated

Download File SC88.ZIP Here

Contents of the README.DOC file



BYTE SMALL-C Version 1.0

Welcome:

You should find on this disk (or, in this archive) all the files you need
to get started with BYTE Small-C. Of course, I'm presuming that you have
a copy of MASM and LINK around, since BYTE Small-C emits assembly-language
source. (I don't know whether or not the output is CHASM-compatible, and
I'm CERTAIN it's not Optasm-compatible. However, a little work with the
conditional branches in the CC4*.C files should fix that.)

You should keep a few things in mind:
1) This is NOT an optimizing compiler. It THINKS it is...I left the peephole
optimizing routine -- peephole() -- alive, but it doesn't do anything. The
staging buffer is passed through unmodified, and here's where you I-live-to-
optimize gangbusters can go hog wild. I'd like to see the results.

2) This version is 8088-compatible. An 80386 version will follow shortly.

3) We'll do our best to let you know of any bug fixes via Bix and in the
magazine, but this is NOT a supported product. We've put it in the public
domain so that you can take it in whatever direction you choose.

4) If you create any worthwhile programs in BYTE Small-C, we ask that you
give conspicuous credit to "those who have gone before." Ron Cain, J.E.
Hendrix, L.E. Payne, and me -- R. E. Grehan. (If you ever use the
Mac version, don't forget Steve Williams.)

GETTING GOING

If you're just anxious to compile stuff, I've included a working executable
of the compiler -- CC86.EXE. Let's say you want to compile a file called
"hello.c". The commands you enter are:
CC86 HELLO.C
MASM HELLO.MAC;;
LINK HELLO (and when the linker asks for .LIB files, give it
CLIB.LIB)

HELLO.EXE will be created, and you're off and running. Make sure
PROLOG.H and EPILOG.H are available when you do the MASM. These
files contain segment info that HELLO.MAC needs. (I'll be many of
you see the CP/M origins of this stuff now.... ".MAC" instead of
".ASM". Well, if that bothers you, modify the compiler.)

TIDBITS

* ASSEMBLY LANGUAGE: You can drop into inline assembly language at any time
with the #asm...#endasm construct. Usually, I do this within entire
functions, like:

func(x,y)
int x,y;
{
#asm
.....assembly language code....
#endasm
}
If you do this, keep one rule in mind: ALWAYS ALWAYS MAKE CERTAIN THE CX
REGISTER IS CLEARED (ZERO) WHEN YOU LEAVE YOUR ROUTINE. This is critical
for the logical operations to work properly. Otherwise, you can use whatever
register you want (be careful with the SP, of course.)

* CALLING CONVENTIONS: All arguments are transferred on the stack in 16-bit
form. Arguments are pushed in left-to-right order, and the "topmost" entry
on the stack is the return address. You should leave the return value in
the BX register. An example might make this clearer:

fadd2(a,b) /* Add a and b, return result */
int a,b;
{
#asm
MOV BP,SP/* Get stack pointer in BP */
MOV AX,2[BP]/* Get b value */
MOV BX,4[BP] /* Get a value */
ADD BX,AX /* Add, result in BX */
#endasm
}

Also, unless you define NOCCARGC, a called function will receive an
argument count in the AL register. (This is how printf() knows how many
arguments it receives.)

* THE LIBRARY. It would be impossible for me to go through a detailed
description of all the library routines and what they do. You should be
able to get a good idea by reading the code itself. Most adhere to the
routines outlined in J.E. Hendrix's article "A New Library for Small-C".
(You can find this reprinted in DR. DOOB'S TOOLBOOK OF C -- see the
references at the end of this file.)

The big differences occur in the fileio routines, (cseek, fread, fwrite,
ctell, etc.)

Following is a list of the library routines. You can use your word
processor to cut-and-paste this list into a batch file if you want to
recreate the library CLIB.LIB. I've also included a file for rebuilding
the library -- LIBMAKE.TXT. You can hand LIBMAKE.TXT to Microsoft's
library manager (LIB). Note that there are a couple of machine-language
files (CALL.MAC, CEND.MAC -- used in by the system library) that you'll
have to pass through MASM first.

A determined programmer could probably make some substantial improvements
in the execution of library routines by simply recoding most of them
in assembly language. I'd like to see the results if you do this.

Library routine files:

ABS.C
ATOI.C
ATOIB.C
AVAIL.C
CALLOC.C
CLEARERR.C
CSEEK.C
CSYSLIB.C
CTELL.C
DTOI.C
EXIT.C
FCLOSE.C
FEOF.C
FERROR.C
FGETC.C
FGETS.C
FOPEN.C
FPRINTF.C
FPUTC.C
FPUTS.C
FREAD.C
FREE.C
FREOPEN.C
FSCANF.C
FWRITE.C
GETARG.C
GETCHAR.C
ISALNUM.C
ISALPHA.C
ISASCII.C
ISATTY.C
ISCNTRL.C
ISCONS.C
ISDIGIT.C
ISGRAPH.C
ISLOWER.C
ISPRINT.C
ISPUNCT.C
ISSPACE.C
ISUPPER.C
ISXDIGIT.C
ITOA.C
ITOAB.C
ITOD.C
ITOO.C
ITOU.C
ITOX.C
LEFT.C
LEXCMP.C
MALLOC.C
OTOI.C
PAD.C
POLL.C
PUTCHAR.C
PUTS.C
RENAME.C

REVERSE.C
REWIND.C
SIGN.C
STRCAT.C
STRCHR.C
STRCMP.C
STRCPY.C
STRLEN.C
STRNCAT.C
STRNCMP.C
STRNCPY.C
STRRCHR.C
TOASCII.C
TOLOWER.C
TOUPPER.C
UNGETC.C
UNLINK.C
UTOI.C
XTOI.C


Of course, the Small-C compiler itself is in files:

CC*.C


FINALLY:

You'll probably get a better picture of Small-C if you locate the BYTE
benchmark programs and examine the code there (not that those programs
are any lustrous programming examples). Particularly if you're interested
in doing floating-point stuff, you should look for SCFMXX.C, the floating-
point support files. There are also support routines for most of the
video adapters in the VIDEO benchmark routines.

Good luck. Let me know what you think of all this.

--Rick Grehan
BYTE Magazine
Bix: rick_g
Compuserve: 76224,13

REFERENCES

Hendrix, J.E. The Small-C Handbook. Reston, VA: Reston Publishing
Company, 1984.

Dr. Dobb's Toolbook of C. New York, NY: Prentice-Hall, 1986.

Williams, Steve. Programming the Macintosh in Assembly Language.
Berkeley, CA: Sybex, 1986.



 December 9, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)