Difference between revisions of "MESCC"
(Created page with "'''MESCC''' Mike's Enhanced Small C Compiler for Z80 and CP/M. '''OVERVIEW''' MESCC is a subset of the standard C language. It was based on the version 1.7 (Oct. 1985) of...") |
|||
(5 intermediate revisions by one other user not shown) | |||
Line 16: | Line 16: | ||
char 1 byte. | char 1 byte. | ||
− | + | Can be signed (-128 to 127) or unsigned (0 to 255). | |
− | + | By default is signed. | |
int 2 bytes. | int 2 bytes. | ||
− | + | Can be signed (-32768 to 32767) or unsigned (0 to 65535). | |
− | + | By default is signed. | |
Pointers 2 bytes. | Pointers 2 bytes. | ||
Arrays Size of type * number of items. | Arrays Size of type * number of items. | ||
− | + | Arrays of pointers are not supported. | |
'''CONSTANTS''' | '''CONSTANTS''' | ||
Line 39: | Line 39: | ||
Examples: "This is a text" | Examples: "This is a text" | ||
− | + | "Text with a newline\n" | |
'''NAMES''' | '''NAMES''' | ||
Line 54: | Line 54: | ||
Can be included in character constants or strings. | Can be included in character constants or strings. | ||
− | \n Newline, 10 decimal. | + | \n Newline, 10 decimal. |
− | \t Tab, 9 decimal. | + | \t Tab, 9 decimal. |
− | \r Carriage line, 13 decimal. | + | \r Carriage line, 13 decimal. |
− | \b Backspace, 8 decimal. | + | \b Backspace, 8 decimal. |
− | \a Alarm, 7 decimal. | + | \a Alarm, 7 decimal. |
− | \f Formfeed, 12 decimal. | + | \f Formfeed, 12 decimal. |
− | \0 Null, 0 decimal. | + | \0 Null, 0 decimal. |
'''SUPPORTED STATEMENTS''' | '''SUPPORTED STATEMENTS''' | ||
− | for(init, cond, incr) statement; | + | for(init, cond, incr) statement; |
− | while(cond) statement; | + | while(cond) statement; |
− | do statement; while(cond); | + | do statement; while(cond); |
− | switch(cond) case statements; | + | switch(cond) case statements; |
− | if(cond) statement; else statement; | + | if(cond) statement; else statement; |
− | continue; | + | continue; |
− | break; | + | break; |
− | return; | + | return; |
− | return expr; | + | return expr; |
'''OPERATORS AND PRECEDENCE''' | '''OPERATORS AND PRECEDENCE''' | ||
− | ! ~ ++ -- - * & right to left | + | ! ~ ++ -- - * & right to left |
− | * / % | + | * / % left to right |
− | + - | + | + - 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 | + | = -= += *= %= right to left |
− | /= &= ^= |= | + | /= &= ^= |= |
'''PREPROCESSOR''' | '''PREPROCESSOR''' | ||
− | #define name string | + | #define name string |
− | #undef name | + | #undef name |
− | #include filename | + | #include filename |
− | #if value | + | #if value |
− | #ifdef name | + | #ifdef name |
− | #ifndef name | + | #ifndef name |
− | #else | + | #else |
− | #endif | + | #endif |
− | #asm | + | #asm |
− | #endasm | + | #endasm |
'''ABOUT THE SOURCE CODE OF MESCC''' | '''ABOUT THE SOURCE CODE OF MESCC''' | ||
Line 118: | Line 118: | ||
'''LIBRARIES''' | '''LIBRARIES''' | ||
− | mescc.h | + | mescc.h Runtime. All programs must include this file first. |
− | alloc.h | + | alloc.h Memory allocation functions. |
− | clock.h | + | clock.h Date & time functions for CP/M Plus. |
− | conio.h | + | conio.h Console I/O functions. |
− | cpm.h | + | cpm.h CP/M specific functions. |
− | ctype.h | + | ctype.h Test and character conversion functions. |
− | fileio.h Stream file I/O functions. | + | fileio.h Stream file I/O functions. |
− | fprintf.h Formatted output to file. | + | fprintf.h Formatted output to file. |
− | mem.h | + | mem.h Memory functions. |
− | printf.h Formatted output to console. | + | printf.h Formatted output to console. |
− | rand.h | + | rand.h Pseudo-random number generation. |
− | sprintf.h Formatted output to memory. | + | setjmp.h Long jumps support. |
− | string.h String functions. | + | sprintf.h Formatted output to memory. |
− | xprintf.h Support library for printf, fprintf and sprintf. | + | string.h String functions. |
− | z80.h | + | xprintf.h Support library for printf, fprintf and sprintf. |
+ | z80.h Z80 specific functions. | ||
'''COPYRIGHT''' | '''COPYRIGHT''' | ||
Line 143: | Line 144: | ||
− | http://www.floppysoftware. | + | http://www.floppysoftware.es |
+ | |||
+ | |||
+ | [[Category:C]] [[Category:Programming]] [[Category:Programming_software]] [[Category:CrossDev]] |
Latest revision as of 07:38, 11 March 2018
MESCC
Mike's Enhanced Small C Compiler for Z80 and CP/M.
OVERVIEW
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.
SUPPORTED TYPES
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.
CONSTANTS
Decimal integer Examples: 32, -1, 456.
Hexadecimal integer Examples: 0x12, 0xF3, 0xAA34
Character constants Examples: 'A', '12', '\t'
STRINGS
Examples: "This is a text"
"Text with a newline\n"
NAMES
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.
ESCAPE SEQUENCES
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.
SUPPORTED STATEMENTS
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 /= &= ^= |=
PREPROCESSOR
#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.
LIBRARIES
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. setjmp.h Long jumps support. sprintf.h Formatted output to memory. string.h String functions. xprintf.h Support library for printf, fprintf and sprintf. z80.h Z80 specific functions.
COPYRIGHT
MESCC is copyright by Miguel Garcia / FloppySoftware, and is released under the GPL license.
DOWNLOAD