home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
-
-
-
-
-
-
- A
- Comparison
- of
-
-
- ===========================================================
- MM MM IIIIIII CCCC RRRRRR OOO CCCC
- M M M M I C C R R O O C C
- M M M I C R R O O C
- M M I C RRRRRR O O ----- C
- M M I C R R O O C
- M M I C C R R O O C C
- M M IIIIIII CCCC R R OOO CCCC
- ===========================================================
-
- A N D
-
- ===========================================================
- SSSSS MM MM A L L CCCC
- S S M M M M A A L L C C
- S M M M A A L L C
- SSSSS M M A A L L ----- C
- S M M AAAAAAA L L C
- S S M M A A L L C C
- SSSSS M M A A LLLLLLL LLLLLLL CCCC
- ===========================================================
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Copyright 1990,1991 Dave Dunfield
- All rights reserved
- MICRO-C .vs. SMALL-C Page: 1
-
-
- 1. INTRODUCTION
-
- The most common reaction of people hearing about MICRO-C for the
- first time is something like "Humph... Another version of the old
- SMALL-C compiler". This couldn't be further from the truth.
-
- MICRO-C IS NOT SMALL-C!!!
-
- MICRO-C is a completely new implementation of a 'C' compiler
- suitable for use on very small systems. It offers several advantages
- over SMALL-C:
-
- - It was designed from the ground up to be easily portable to
- different processors & computer platforms. Sample code generators
- are included for 8080, 8051, 80x86, 8096, 6809 and 68HC11 cpu's,
- and an entire section of the manual is devoted to porting the
- compiler.
-
- Although SMALL-C claims to be easily portable, much of it's
- arcitecture is oriented toward the original 8080 processor. For an
- example of how this affects the compiler, compare the code
- generated by the 8086 version of SMALL-C to reference stack (auto)
- variables to that produced by MICRO-C.
-
- - It is a more complete implementation of the 'C' language, see the
- features comparison later in this document.
-
- - It produces faster, more compact code. See the benchmark results
- later in this document.
-
- - MICRO-C employs a fully tokenized parser, allowing statement
- analysis to be performed on 16 bit "tokens" instead of text
- strings as is done in SMALL-C. This results in MUCH faster
- compilation.
-
- - Although it is higher in functionality than SMALL-C, the MICRO-C
- compiler is much smaller than SMALL-C (Nearly half the size). This
- allows it to run on very small computer systems.
-
- 2. DETAILED COMPARISON OF COMPILERS
-
- The following pages contain a detailed comparison of the SMALL-C
- version 2 compiler, and MICRO-C.
- MICRO-C .vs. SMALL-C Page: 2
-
-
- 2.1 'C' Implementation
- =============================================================
- Data types | SMALL-C V1 | SMALL-C V2 | MICRO-C |
- ------------------------+------------------------------------
- int | Yes | Yes | Yes |
- char | Yes | Yes | Yes |
- unsigned int | No | No | Yes |
- unsigned char | No | No | Yes |
- pointers | Yes | Yes | Yes |
- pointers to pointers | No | No | Yes |
- Single dimension arrays | Yes | Yes | Yes |
- Multi dimension arrays | No | No | Yes |
- arrays of pointers | No | No | Yes |
- Typecast | No | No | Yes |
- sizeof | No | No | Yes |
- ========================+====================================
- Control Structures | SMALL-C V1 | SMALL-C V2 | MICRO-C |
- ------------------------+------------------------------------
- if/else | Yes | Yes | Yes |
- while | Yes | Yes | Yes |
- do/while | No | Yes | Yes |
- for | No | Yes | Yes |
- switch/case | No | Yes | Yes |
- goto | No | Yes | Yes |
- Conditional Expressions | No | Yes | Yes |
- Inline assembler | Yes | Yes | Yes |
- ========================+====================================
- Pre-processor | SMALL-C V1 | SMALL-C V2 | MICRO-C |
- ------------------------+------------------------------------
- #define (basic) | Yes | Yes | Yes |
- #define (Parameterized) | No | No | Yes |
- #define (Multi-line) | No | No | Yes |
- #undef | No | No | Yes |
- #include (single level) | Yes | Yes | Yes |
- #include (nested) | No | Yes | Yes |
- #ifdef/#ifndef | No | Yes | Yes |
- ========================+====================================
- Misc features | SMALL-C V1 | SMALL-C V2 | MICRO-C |
- ------------------------+------------------------------------
- Optimization | No | Yes | Yes |
- Multiple memory models | No | No | Yes |
- Make/touch utility | No | No | Yes |
- Source linker | No | No | Yes |
- 6809 code generator | No | No | Yes |
- 68HC11 code generator | No | No | Yes |
- 8080 code generator | Yes | Yes | Yes |
- 8051 code generator | No | No | Yes |
- 8086 code generator | No | Yes | Yes |
- 8096 code generator | No | No | Yes |
- ========================+====================================
- Library features | SMALL-C V1 | SMALL-C V2 | MICRO-C |
- ------------------------+------------------------------------
- Complete standard lib | No | Yes | Yes |
- Interrupt serial I/O | No | No | Yes |
- Windowing library | No | No | Yes |
- TSR support | No | No | Yes |
- ========================+====================================
- MICRO-C .vs. SMALL-C Page: 3
-
-
- 2.2 Generated code quality
-
- To test the actual performace of code generated by MICRO-C
- against code generated by SMALL-C, I used this "Sieve of
- Eratosthenes" prime number generator program, taken from the BYTE
- benchmarks:
-
-
-
-
-
- /*
- * The classic "Sieve of Eratosthenes" prime number program.
- * from BYTE, January 1983.
- */
- #include <stdio.h>
- #include "timer.c" /* The timer subroutines */
-
- #define SIZE 8190
- #define LOOP 100
- #define TRUE 1
- #define FALSE 0
-
- char flags [SIZE + 1];
-
- main()
- {
- int i, prime, k, count, iter;
-
- printf("BYTE Sieve Benchmark - %d iterations\n",LOOP);
-
- /* Start timer and execute loop */
- startimer(timestamp);
- for(iter = 1; iter <= LOOP; ++iter) {
- count = 0; /* prime counter */
- for(i = 0; i <= SIZE; ++i) /* set all flags true */
- flags [i] = TRUE;
- for(i = 0; i <= SIZE; ++i) {
- if(flags [i]) { /* found a prime */
- prime = i + i + 3; /* twice index + 3 */
- /* printf ("\n%d", prime); */
- for(k = i + prime; k <= SIZE; k+= prime)
- flags [k] = FALSE; /* kill all multiple */
- ++count; } } } /* primes found */
- elapsed(timestamp); /* Calculate time taken */
-
- /* Report results */
- printf("%d primes.\n\n", count); /* primes found on 100th pass */
- printf("Elapsed time: %02d:%02d:%02d.%02d\n",
- timestamp[1], timestamp[0], timestamp[3], timestamp[2]);
- }
- MICRO-C .vs. SMALL-C Page: 4
-
-
- 2.3 Speed of compilation
-
- To show the relative compilation times, I wrote this simple
- MICRO-C program, using the timing routines shown below, to execute
- the compilers & report the time taken:
-
-
-
-
-
- #include <stdio.h>
- #include "timer.c" /* The timer subroutines */
-
- main()
- {
- startimer(timestamp);
- system("CC SIEVE"); /* Execute the SMALL-C compiler */
- elapsed(timestamp);
- printf("Elapsed time: %02d:%02d:%02d.%02d\n\n",
- timestamp[1], timestamp[0], timestamp[3], timestamp[2]);
-
- startimer(timestamp);
- system("MCC SIEVE.C SIEVE.ASM");/* Execute the MICRO-C compiler */
- elapsed(timestamp);
- printf("Elapsed time: %02d:%02d:%02d.%02d\n",
- timestamp[1], timestamp[0], timestamp[3], timestamp[2]);
- }
-
- NOTE: The results from the above program will include the time
- taken to load the compilers. To minimize this, all tests were run
- from a RAMdisk. This eliminates disk seek time, and reduces load
- time to the speed of a memory to memory copy.
- MICRO-C .vs. SMALL-C Page: 5
-
-
- 2.4 Timing the tests
-
- These subroutines were used to time the programs, using the
- MS-DOS internal clock which has a resolution of 1/100 of a second:
-
-
-
-
-
- char timestamp[4]; /* Stores initial timestamp */
-
- /*
- * Record system time for later calculation
- */
- startimer() asm
- {
- MOV AH,2CH ; Get time function
- INT 21H ; Ask DOS
- MOV SI,4[BP] ; Get pointer to timestamp
- MOV [SI],CX ; Record hours & minites
- MOV 2[SI],DX ; Record seconds & hundreds
- }
-
- /*
- * Calculate elapsed time since timestamp recorded
- */
- elapsed() asm
- {
- MOV AH,2CH ; Get time function
- INT 21H ; Ask DOS
- MOV SI,4[BP] ; Pointer to timestamp
- SUB DL,2[SI] ; Convert 100ths
- JNC ELAP1 ; No borrow
- ADD DL,100 ; Re-adjust
- DEC DH ; Reduce seconds
- ELAP1: MOV 2[SI],DL ; Save elapsed hundreds
- SUB DH,3[SI] ; Convert seconds
- JNS ELAP2 ; No borrow
- ADD DH,60 ; Re-adjust
- DEC CL ; Reduce minites
- ELAP2: MOV 3[SI],DH ; Save elapsed seconds
- SUB CL,[SI] ; Convert minites
- JNS ELAP3 ; No borrow
- ADD CL,60 ; Re-adjust
- DEC CH ; Adjust hours
- ELAP3: MOV [SI],CL ; Save elapsed minites
- SUB CH,1[SI] ; Convert hours
- MOV 1[SI],CH ; Save elapsed hours
- }
- MICRO-C .vs. SMALL-C Page: 6
-
-
- 2.5 Test results
-
- After compiling the programs, I ran the various tests on a
- standard 8-Mhz IBM PC/AT, with these results:
-
- E:\>dir
-
- Volume in drive E is VDISK V3.3
- Directory of E:\
-
- CC EXE 40626 9-10-90 /* SMALL-C compiler */
- MCC COM 22316 9-10-90 /* MICRO-C compiler */
- TIMER C 1094 9-10-90 /* The timer subroutines */
- TIMECOMP C 527 9-10-90 /* The compiler timer */
- SIEVE C 1149 9-10-90 /* The test program */
- SIEVE-S EXE 16946 9-10-90 /* SMALL-C produced this */
- SIEVE-M COM 1651 9-10-90 /* MICRO-C produced this */
- TIMECOMP COM 1924 9-10-90 /* Executable compiler timer */
- 8 File(s) 301056 bytes free
-
- E:\>sieve-s /* The SMALL-C version: 1 min, 28.98 secs */
- BYTE Sieve Benchmark - 100 iterations
- 1899 primes.
-
- Elapsed time: 00:01:28.98
-
- E:\>sieve-m /* The MICRO-C version: 1 min, 4.59 secs */
- BYTE Sieve Benchmark - 100 iterations
- 1899 primes.
-
- Elapsed time: 00:01:04.59
-
- E:\>
-
- **NOTE: Before running TIMECOMP, I created a "generic" STDIO.H
- file which was suitable for both compilers.
-
- E:\>timecomp /* Times to compile the program */
- Small-C Compiler, Version 2.1, (Rev. 75)
- Copyright 1982, 1983, 1985 J. E. Hendrix
- Elapsed time: 00:00:04.72 /* SMALL-C 4.72 secs */
-
- MICRO-C 2.0 Compiler
- Copyright 1988,1990 Dave Dunfield
- All rights reserved.
- Elapsed time: 00:00:01.32 /* MICRO-C 1.32 secs */
-
- E:\>
- MICRO-C .vs. SMALL-C Page: 7
-
-
- 3. OTHER ADVANTAGES OF MICRO-C
-
- In addition to being a superiour and more portable compiler, The
- MICRO-C package also offers these advantages:
-
- 3.1 Utilities
-
- MICRO-C Comes with the following utilities (all with complete
- MICRO-C source code):
-
- CC - Command Coordinator, combines pre-processor, compiler,
- optimizer, assembler and linker into a single command.
- Command line parameters allow very flexible operation.
-
- MAKE - Automates building of larger (multi module) programs.
-
- TOUCH - Set timestamp of file to current or specified date.
- (Used with MAKEs dependancy checking)
-
- SLINK - Source LINKer, Allows pre-compiled (assembler) source to
- be kept in a library and included as needed to resolve
- external references. Useful when MICRO-C is used as cross
- compiler for systems not supporting an object linker.
-
- SLIB - Utility for updating and maintaining a source library.
-
- SINDEX - Automatically indexes a source library for use by SLINK.
-
- SCONVERT- Converts assembly language source for use by SLINK.
-
- EXE2BIN - Converts MS-DOS EXE files to a binary image, useful for
- users of later versions of DOS which no longer include
- this utility.
-
- MCP - The MICRO-C Pre-processor
-
- MCC - The MICRO-C Compiler
-
- MCO - The MICRO-C Optimizer
- MICRO-C .vs. SMALL-C Page: 8
-
-
- 3.2 Example Programs
-
- MICRO-C comes with the following example programs (all with
- complete MICRO-C source code):
-
- ASM86.C An 8086 assembler
- BASIC.C A simple BASIC interpreter
- CALC.C A pop-up (TSR) calculator for programmers
- CASTLE.C A large "adventure" game
- CHATTR.C Chenges file attributes
- COMEXT.C Extracts comment from 'C' programs
- CSET.C A pop-up (TSR) PC character set
- CVTCOM.C Convert C++ style '//' comments to C's '/* - */'
- DUMP.C A HEX/OCTAL file dump utility
- EQUIP.C Displays equipment installed in your PC
- FIBO.C Calculates a fibonacci series
- FORTUNE.C Displays a "fortune cookie" message every time it is run
- GREP.C Unix like "grep" command from DECUS
- HANOI.C Solves the "towers of hanoi" program on screen
- HELLO.C Standard 'C' demo program
- HEM.C Traps hardware fault interrupts
- HEXED.C A full-screen hex file editor
- HFTEXT.C Simple Huffman encoded for text files
- INSTALL.C The Micro-Install program
- LZC.C Laser Commander - pop-up (TSR) control for laser printer
- MTERM.C A pop-up (TSR) ANSI terminal with XMODEM
- OBSCURE.C Makes a 'C' program un-readable (it still compiles)
- PPC.C Pretty-Printer for C
- PRIME.C Calculates prime numbers
- RLTEXT.C Simple Runn Length encoded for text files
- ROBOFACE.C Draws a robot face on your BC screen
- TEXTNUM.C Displays text equivalent of numbers
- TIMEIT.C Time the execution of another command
- TR.C Unix like "tr" command
- TTT3D.C Three-Dimensional Tic-Tac-Toe
- TYPE4.C Display a file with tabs at 4 character intervals
- VALIDATE.C PD version McAfee's validate program, uses dual CRC's
- WINDEMO.C MICRO-C window demonstration program
-
-
-
- MICRO-C .vs. SMALL-C
-
- TABLE OF CONTENTS
-
-
- Page
-
- 1. INTRODUCTION 1
-
-
- 2. DETAILED COMPARISON OF COMPILERS 1
-
- 2.1 'C' Implementation 2
- 2.2 Generated code quality 3
- 2.3 Speed of compilation 4
- 2.4 Timing the tests 5
- 2.5 Test results 6
-
- 3. OTHER ADVANTAGES OF MICRO-C 7
-
- 3.1 Utilities 7
- 3.2 Example Programs 8
-