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: "Steve Andrew"
References: <firstname.lastname@example.org> <email@example.com>
Subject: Re: To C or not to C
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
Date: Sat, 04 Jan 2003 20:36:39 GMT
NNTP-Posting-Date: Sun, 05 Jan 2003 07:36:39 EST
Organization: BigPond Internet Services (http://www.bigpond.net.au)
> "Michael Culley" wrote in message
>> Thanks to everyone's help here my small project has progressed
>> I now had a completed (although very messy) prototype. For those
>> didn't read my previous thread it is using an 8051 and a max232 to
>> connect to a serial port. I'm doing this project with a friend and
>> he prefers to use C while I prefer to use assembler. We have both
>> written the software and both versions work the same with only
>> differences. I can see 2 problems with using C. First, there is
>> of extra assembly code added in that we don't know what it does, if
>> this produces a bug it could be hard to track down. Second, it
>> appears to use alot more of the rom. The assembler version is 757
>> bytes and the C version is 1508 bytes. About 350 bytes is text in
>> both, so the C code is almost 3 times larger than the assembler
>> version. The C version has had quite a few hours spent on it
>> it down to 1500 bytes where the assembler version hasn't been
>> optimised. 1500 bytes seams like a huge waste when we only have 2k.
>> What does everyone think, which is better C or assembler? We are
>> using SDCC.
> Hi, only a 3:1 increase count yourself lucky it's usually much worse
> than that. As for all the "extra unused code" people keep going on
> about, your compiler should not add any code that you do not use.
Extra fat is usually a function of library granularity and not a
reflection of the efficiency of the language. For example, some comms
libraries will include all comms functions in a single object file so
you are stuck with the overhead of functions that are unused. Other
comms libraries will compile each function into a separate object
file, linking only the functions that are required. Most compilers
will include library source code and it is not uncommon for C
programmers to tweak and re-compile libraries to increase granularity.
Checking the map file is a good way of seeing what un-used functions
are being linked into the project.
In addition, there is usually a fixed overhead associated with C in
terms of start-up code. The code will usually be around the same size,
irrespective of the amount of project code. In a simple "Hello World"
programme, the start-up code could well account for 50% or more of the
total code generated. Check the generated assembler listing to see
what code can be cut out.
>I personally have yet to see an instance where its worth running C on
> 8051. As you have done the job both ways you should be able to
> the performance diffences for yourself and make your own judgement.
> the 8051 is an assembly programers dream, easy instuctions simple
> straight forward, if you were trying it on a pentium that would be a
> different story.
Go Back To The Cyber-Spy.Com
Usenet Web Archive Index Of
The sci.electronics.design Newsgroup