OT: Requesting C advice

Les hlhowell at pacbell.net
Sat May 26 17:16:10 UTC 2007


On Sat, 2007-05-26 at 08:03 -0500, Chris Schumann wrote:
> Late reply; sorry.
> 
> > Date: Thu, 24 May 2007 08:43:26 -0700
> > From: Les <hlhowell at pacbell.net>
> 
> > Embedded applications today
> > are mostly 8 bit, but many, many designers have already begun the
> > transition to 16 bit, and soon 
> > will be moving to 32 bit.  The reasons are much the same as 
> > the reasons
> > that general computing has moved from 8 to 16 to 32 and now 
> > to 64, with
> > the cutting edge already 
> > looking at 128 bit and parallel processing, along with dedicated
> > processors running 32 or 64 bit floating point math.  Also 
> > the length of
> > the integer used in C, which is a virtual 
> > machine is independent of the word length of the processor, 
> > except the C
> > language designers (originally Kernigan and Ritchie) made the language
> > somewhat flexible to simplify migration.  That is why there were some
> > undefined situations in the original specification.  Remember 
> > that C is
> > a virtual machine language, whose processor only has 24 
> > instructions (I
> > think the Ansi committee added a couple, but they have specific uses
> > that were not foreseen in the original usage of the language) 
> >  It can be
> > ported to any machine currently extant by only writing about 1K of
> > machine code, and even that can be done in another available higher
> > level language if you so desire, as long as it is compiled for
> > efficiency.
> 
> Having used C since the original K&R version, I have to ask WHAT?!?
> 
> Since when is C a virtual machine language?
> 
> The only CVM I can find is Java's JVM. They have modified gcc (a C
> compiler) to produce byte code for that JVM.
> 
> Every compiler I've used compiles C to native machine code for the
> target platform. There is no intermediate language, and that's what
> gave C its famous speed.
> 
> (and because it is a virtual machine language...)
> >     That is why even the 8 bit implementations of C used a 16 bit
> > integer.
> 
> No it's not. They used 16 bit integers because you can't do much
> of anything useful with only 8 bit integers. The compiler designers
> for those systems (like the Apple II) had to work around the 8 bit
> registers. Looking at the assembly-language source for some of the
> libraries was not pleasant.
> 
> Chris
> 
Compiled C is only about 1.8x less efficient than assembly code, so it
is difficult to obtain better through put than C by assembly.  However
for drivers and frequently used libraries, most implementors do perform
some hand assembly optimization, both to optimize the use of the
processor, and to directly address some things that C doesn't do quite
as well.  As to the integer issue, you are correct, the numerical
representation limitation was why 16 bits was chosen, and Microsoft
stayed with it far longer than other implementors.  As to the VM, while
it is not present in the actual code, I did port C in the early 80's
across a couple of processors for my own use.  It was not at all
difficult, and the standard IO library as described by K & R is written
in C, for portability.  At one time on CP/M, you could get a C compiler,
and all the utilities to bring it up on a new system on a single 5"
floppy and there was even a version released on audio cassette tape
compatible with the Tarbell interface (300 baud to a autio cassette if I
remember right.)

    It has been a long time and I may not remember this clearly.  So, I
looked and can no longer find reference to the base machine design, nor
do I have my original K&R book in my library.  It may be in storage with
my Altair.  So I will bow to your statement, because I can no longer
find the original documents which I "remember".  I put it in quotes
because apparently I am incorrect in my memory.  

    I dimly have the memory of how I ported the language a long time
ago, but apparently memory is faulty here.  

    C is a wonderful language, and I have been using it since I first
purchased a Processor Technology version, and the K & R book many
decades ago.  You have to tip your hat to K&R for a marvelous creation
that has performed so well, that nearly 40 years later it is still one
of the most efficient and powerful languages available.  One of the
highest tributes to their genius is the use of C to design and build
other languages, often with the authors describing the limitations of C
to their task.

    To your comment about the libraries, I have to point out that there
are only a few libraries that were part of the original C library
package.  A lot of the others were added by different implementers, many
of whom did not use C to develop their libraries, so their code is
indeed often difficult to read, debug, implement or port to new
systems. 

    I seem to remember that the first fully implemented VM I ever saw
was PASCAL by Kernigan and Plauger, which actually implemented a P-code
and a true VM.  

   On another note: The first commercial personal computer I ever saw
had wooden sides, a metal wrap around frame that held the motherboard
and keyboard, used a Motorola processor (6502 I think), and an RF
interface.  I helped the officer who bought it by fixing some of his
poor soldering and replacing one bad IC.  A nand gate used for selecting
RAM banks.  Care to guess what that computer was?  

    At that time I didn't own a computer, but after having seen his, I
went into Tokyo and bought some parts on the part of the Ginza that was
later to become known as Akihabara,  although I don't remember it being
called that at the time.

   I just realized that I have been at this stuff for more than 30
years.  I feel old now.  THANKS!! ;-)

regards,
Les H





More information about the users mailing list