Mike's Enhanced Small C Compiler for Z80 and CP/M.
MESCC is a subset of the standard C language.
It was based on the version 1.7 (Oct. 1985) of Small C by Ron Cain, Mike Bernson's and John Hill, but now only a small portion of the original source code is present.
This compiler can be compiled by itself.
char 1 byte.
Can be signed (-128 to 127) or unsigned (0 to 255). By default is signed.
int 2 bytes.
Can be signed (-32768 to 32767) or unsigned (0 to 65535). By default is signed.
Pointers 2 bytes.
Arrays Size of type * number of items.
Arrays of pointers are not supported.
Decimal integer Examples: 32, -1, 456. Hexadecimal integer Examples: 0x12, 0xF3, 0xAA34 Character constants Examples: 'A', '12', '\t'
Examples: "This is a text"
"Text with a newline\n"
Variables and function names should consist of not more than 11 alpha-numeric characters.
The '_' character is considered an alphabetic character, and the first character can't be numeric.
Can be included in character constants or strings.
\n Newline, 10 decimal. \t Tab, 9 decimal. \r Carriage line, 13 decimal. \b Backspace, 8 decimal. \a Alarm, 7 decimal. \f Formfeed, 12 decimal. \0 Null, 0 decimal.
for(init, cond, incr) statement; while(cond) statement; do statement; while(cond); switch(cond) case statements; if(cond) statement; else statement; continue; break; return; return expr;
OPERATORS AND PRECEDENCE
! ~ ++ -- - * & right to left * / % left to right + - left to right << >> left to right < <= > >= left to right == != left to rigth & left to rigth ^ left to right | left to right && left to right || left to right ?: right to left = -= += *= %= right to left /= &= ^= |=
#define name string #undef name #include filename #if value #ifdef name #ifndef name #else #endif #asm #endasm
ABOUT THE SOURCE CODE OF MESCC
The source code of MESCC is written in MESCC code. That's is: A subset of C language in Kernighan & Ritchie style, not ANSI.
It can be compiled by itself.
The source code uses some extern library functions as fopen, fgetchar, etc., that are available as part of standard library of MESCC.
mescc.h Runtime. All programs must include this file first. alloc.h Memory allocation functions. clock.h Date & time functions for CP/M Plus. conio.h Console I/O functions. cpm.h CP/M specific functions. ctype.h Test and character conversion functions. fileio.h Stream file I/O functions. fprintf.h Formatted output to file. mem.h Memory functions. printf.h Formatted output to console. rand.h Pseudo-random number generation. sprintf.h Formatted output to memory. string.h String functions. xprintf.h Support library for printf, fprintf and sprintf. z80.h Z80 specific functions.
MESCC is copyright by Miguel Garcia / FloppySoftware, and is released under the GPL license.