The Cyber-Spy.Com Usenet Archive Feeds Directly
From The Open And Publicly Available Newsgroup
This Group And Thousands Of Others Are Available
On Most IS NNTP News Servers On Port 119.
Cyber-Spy.Com Is NOT Responsible For Any Topic,
Opinions Or Content Posted To This Or Any Other
Newsgroup. This Web Archive Of The Newsgroup And
Posts Are For Informational Purposes Only.
From: "D Poinsett"
Subject: Re: To C or not to C
Date: Sat, 4 Jan 2003 12:45:36 -0500
Organization: Posted via Supernews, http://www.supernews.com
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
Don't give up on C yet especially if you are writing several thousand lines
of assembler. The only way to determine if the C code will be fast enough is
to evaluate the timing constraints in the critical sections. If you have any
user interface stuff in your code, those sections will likely occupy a major
portion of the program. Here, C is often a attractive delight because the
higher level language makes it much easier to manage these parts of the code
than if assembler was used. I know there are folks out there who live and
breath assembler and they may well be the exception to what I'm saying but
most of us are not in that camp.
Often only a few, if any, sections of code need blazing speed. In these
cases you can break out of C into inline assembly and have the best of both
worlds. Why code in assembler when most of the program really needs easy
management and efficient development rather than speed?
Products involving 100K units (or more) may benefit from the added labor to
trim every penny from the material costs in the final product and products
that are so simple that they run on literally a few lines of code may
justify assembler but for most of us, the benefits of C and assembler
together are an attractive solution.
I noticed the comment on the 1:3 ratio of assembled coded to compiled code.
This sounds reasonable. Generally, the smaller the program, the bigger the
difference because of the fixed library size. With some of the newer chips
designed to work with stack intensive languages like C, the difference in
code size is not so great if the compiler takes advantage of the chip
features. Consider that for all but the most cost sensitive products, code
storage space (EPROM, FLASH, etc.) is cheap these days while program
creation/management effort and time-to-market can be the more cost-critical
"Dr.Bob" wrote in message
> "Michael Culley" wrote in message
> > Thanks to everyone's help here my small project has progressed well. I
> > had a completed (although very messy) prototype. For those who didn't
> > my previous thread it is using an 8051 and a max232 to connect to a
> > port. I'm doing this project with a friend and he prefers to use C while
> > prefer to use assembler. We have both written the software and both
> > work the same with only minor differences. I can see 2 problems with
> > C. First, there is alot of extra assembly code added in that we don't
> > what it does, if this produces a bug it could be hard to track down.
> > it appears to use alot more of the rom. The assembler version is 757
> > and the C version is 1508 bytes. About 350 bytes is text in both, so the
> > code is almost 3 times larger than the assembler version. The C version
> > had quite a few hours spent on it getting it down to 1500 bytes where
> > assembler version hasn't been optimised. 1500 bytes seams like a huge
> > when we only have 2k.
> > What does everyone think, which is better C or assembler? We are using
> > --
> > Michael Culley
> That's very interesting. I've always heard that assembly language would
> produce a shorter more succinct and faster running code than code compiled
> from C. Your experience confirms that view at least in your small program.
> But, I never figured that the difference would be as geat as you've found,
> to1 that's amazing and almost scary. I'm writing a MIDI controller that is
> several thousand lines long and the program will have to bomb through it
> a very fast rate to keep up with the MIDI commands. It's for a pipe organ.
> I'm working in assemby and am glad I didn't even think of doing it in C.
> Based on your experience it dosen't look like code compiled from C could
> fast enough to do my job. Thanks for the insight.
Go Back To The Cyber-Spy.Com
Usenet Web Archive Index Of
The sci.electronics.design Newsgroup