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: Crusty Curmudgeon
Subject: Re: To C or not to C
X-Newsreader: Forte Agent 1.9/32.560
Date: Fri, 03 Jan 2003 23:14:09 -0600
NNTP-Posting-Date: Fri, 03 Jan 2003 23:13:03 CST
I prefer assembly over C because I have a lot more control over what my design
is doing. But if pressed for time, or if I expect to have to do a lot of
revisions due to customers changing their requirements, C is the way to go.
That extra code you see in a C program output is mostly stack and buffer space
handling for all the functions the C compiler thinks you must have.
Some C compilers are smart enough to pare away all but what you really need,
others you have to beat over the head. Look for a C compiler that allows 'inline
assembly'. This breaks ansi compliance, but it's worth it if you come up against
a speed/size limit.
Some tips: Avoid using printf(). This is a very powerful function but comes at
a high code size cost. Use puts() instead if you can. Also watch using includes.
Many standard includes, like math.h, predefine a ton of constants and variable
names, all of which the compiler will have to allocate resource space for. ...
don't use alloc() and it's kin. Use static string arrays instead and do your own
book-keeping of what's where.
On Sat, 4 Jan 2003 11:06:02 +1100, "Michael Culley"
>Thanks to everyone's help here my small project has progressed well. I now
>had a completed (although very messy) prototype. For those who 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 minor differences. I can see 2 problems with using
>C. First, there is alot 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 getting 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.
Go Back To The Cyber-Spy.Com
Usenet Web Archive Index Of
The sci.electronics.design Newsgroup