[comp.lang.c] Power C compiler review

jackm@jpl-devvax.JPL.NASA.GOV (Jack Morrison) (11/16/88)

For those who perfer counter-culture C compilers (non-Microsoft/Borland), 
here is a comparative review of DeSmet C88 and MIX Power C.

I bought DeSmet's C88 compiler several years ago because (a) it was 
inexpensive ($150 for compiler and symbolic debugger, back when most
compilers were $350 and up), (b) it *had* a symbolic debugger, and 
(c) it always did very well in comparison reviews.

Recently I've decided to try the Power C compiler (MPC) as C88 was wearing
a bit thin in some areas (outlined below), and MPC is ridiculously cheap
($20 for compiler, $10 for library source, $20 for debugger). After some
brief experience with MPC, here are some comparisons. (I've got a 
positive attitude, folks. If I say something good about one, it 
probably means the other ain't got it).

I'm not very familiar with Turbo-C or MS-C, but old friends with 
Unix (e.g. Sun) compilers. (I wasn't real thrilled with Turbo 
Pascal, so I've avoided TC even though it's priced right. Now that 
they have a debugger, it's a stronger option).

BTW, I'm using an XT clone with 640K.

Compiling Operation:
  C88 is small and fast - I keep it on a ramdisk, and it gives you the
option of using a ramdisk for temporary files. I suspect it would be a
close race with Turbo-C (*once* TC is loaded, if you like their editor :-P).
  MPC is big and slow. It yacks at you while it compiles (like Turbo?):
line numbers, function names, junk like that. Won't fit on my ramdisk.
(In fact, the debugger wouldn't run until I cut down the ramdisk size).

Generated Code:
  C88 produces pretty good code, but hardly optimal. I'd bet MSC does
much better if you asked it to (though I hear it sometimes breaks your code).
Strictly 8086/88 instructions. Floating point always through library calls.
  MPC produces clunky code, though functional (so far). Apparently, any 
conditional subexpression computes a zero or one result and then tests that;
so there was stuff like (this is from memory, don't quote me)

	MOV BX,[BP+xxx]
	CMP BX,2
	XOR AX,AX
	JLE aaa
	JMP bbb		(yikes! this is after an "optimizer" pass?)
aaa:
	INC AX
bbb:

Floating point (and all long integer!) operations generate
library calls. At least the library can sense an 80x87 and use it or
emulate it as required; C88 requires you to decide at link time which
library to load. There are compiler options for 186 and 286 instruction
generation; no 386.

Memory Models:
  C88 uses compact model (64K code, 64K data/stack/heap) only, with very
limited access to far memory. This generates fast, small objects. Overlays
(both memory and disk-based) are the only option for larger programs. 
Actually, they announced options for larger data models long ago, but 
the upgrade was not cheap enough for me ;-).
  MPC uses medium model (unlimited code [far calls], 64K data/stack/near
heap, unlimited far heap), with lots of library support for far memory.
There are compiler options for small (64K code) and large (unlimited data)
models, but they don't work (there aren't separate libraries for the 
different models, if that's a clue).

Source Code Format:
  C88 is plain 1st edition K&R, plus enums and structure assignment (the
latter is slightly buggy). Module-level static variables don't work right.
Macro invocations cannot run beyond one line (even with backslashes).
In-line assembler is supported (no, not inline machine code, Mr. Kahn).
  MPC is full ANSI - prototypes, signed and unsigned are modifiers,
#pragmas. No inline assembler, but there's a library function to which 
you can pass an array of machine code to execute. The compiler handles 
31-character external names (option for 8), but the debugger chokes on
anything over 8.

Library:
  C88 library is rather limited (e.g. no findfirst(), getenv(), strtok())
and bit non-standard (e.g. puts() does *not* add the newline :-(). The I/O
stuff was written to support DOS 1.x, and is awfully slow with stdin/stdout
(translating CR/LF and LF, and all that).
  MPC library is more standard and quite extensive, including lots of ANSI
and SysV stuff, graphics support (including hercules), etc. Supposedly
a superset of TurboC and Microsoft libraries. Source is 
available at an incredible $10 (including an assembler). Much of the library 
is written in assembly, and seems quite fast. As an example, I have a 
little untab program. The C88 version using fgets() and putchar() was so
slow, I rewrote it using read() and write() with 4K buffers. It still
takes 15 seconds to untab a 300 line file from hard disk to ramdisk. 
The original, simpler fgets/putchar version, compiled with MPC, takes
about 3 seconds (though the EXE file is larger).

Documentation:
  C88 manual is very good at explaining usage of the tools, interfacing to
assembly, compiler specifics, etc. Separate K&R required.
  MPC includes what looks like a nice C tutorial, with many examples ("looks
like" because I skimmed through it, already knowing of the ways). Even the
library function descriptions have examples. They are well aimed for new
C programmers with their thorough documentation and low price.

Utilities:
  C88 includes a very nice small, fast, stay-out-of-my-way editor (fits on
the ramdisk too), a librarian, linker, assembler, execution profiler,
and a game or two.
  MPC will sell you an editor for about $20; I didn't order it. You get
a linker, and the compiler itself has some Unix-make-ish features.

Miscellaneous Features:
  C88 has options to output preprocessor output or assembly code instead of 
object code. Great as a starting point to hand-tuned assembly functions.
  MPC always writes error messages to a file C.ERR (as well as stdout).
It can generate listings, with macros optionally expanded.

Debuggers:
  You may have guessed that this part is important to me (and a big reason
why Turbo Pascal drove me nuts).
  C88 has a nice symbolic debugger. You can step through C statements,
set breakpoints, display/change variables, flip between debug and output
screens. You can display assembly code, but not step through at that level.
  MPC has an excellent debugger. Probably compares well with the new TC
embedded debugger; maybe even the standalone one. The user interface is 
slick and powerful without being confusing. Point to a variable
and find out it's address, contents, type, size, scope, and
astrological sign. Set breakpoints and watchpoints; backtrace through
your execution, step through assembly code (with symbol names in the calls).
If the program switches to graphics mode (using the MPC library 
routines), the debugger knows it, and handles it wonderfully. 
Profiles execution counts for each line of code. Yes folks, I like it!
Again, the manual is very nice, including step-by-step tutorial.
A couple of shortcomings so far: there doesn't seem to be any easy way
to step through a function without diving into called functions (although
a single key executes to the end of a function once you get into it).
Nor can you have it compute an arbitrary expression (including function
calls) - as Unix dbx and C88's debugger can do. Finally, it's a porker
for memory.

SUMMARY

C88: fast, small, a bit odd, showing some age.
MPC: dirt cheap, slow compiling, unimpressive code generation, nice 
libraries, wonderful debugger, good documentation.

Now if I could combine the two... Actually, I may try rebuilding the 
C88 library based on the MPC library source. Then if I could just
get the MPC debugger to understand C88 symbol tables...

(did someone out there just yell "Turbo-C PRO" or "get a 386"?)
-- 
Jack C. Morrison, Jet Propulsion Laboratory
"How am I typing? Call 1-818-354-1431, or mail jackm@jpl-devvax.jpl.nasa.gov"