This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Keil C vs. Bascom basic compiler

Hello !

I have a problem which I can't resolve. I wrote program for 89C2051 for one of my friend in Basom Basic compiler (http://www.mcselec.com). Compiled code was about 1945 bytes. Since I prefer C, I transalte Bascom basic to C. But when I compile, generated code was 2313. I try to change optimization parameters, but generated code never go below 2313. Even bigger. Where am I wrong ?
Is it possible that stupid Basic make smaller code tne best C compiler ? Then I find out that this code:
while (1) {
printf ("Hello World\n");
}
generate fully 1093 bytes (!) for Atmel 89C2051. 1093 bytes???? Three lines? Same program in Bascom generate only 154 (!) bytes.
When I remove all "printf" from my C code, generated code was arond 2200 byte. But, with same action in Basic code (remove all "print") 1340 bytes long code. Exactly same program in Keil C and Bascom basic generate 860 byte smaller code !
I don't belive this. Do I have to program in (stupid) Basic if I want smaller code ?
I still belive I did mistake somewhere, so I need help.
I will send both C and basic code for interested people.

With best regards !

Parents
  • Erik,

    1) Sure, that's been on the go for years. Bjarne claims it would have been funnier if he'd written it but I doubt that somehow.

    2) Indeed. However, I feel the same way when someone states that something is the wrong choice in all situations because that is equally false.

    3) I do use C++ on the PC and I don't use C++ on the 8051. However, I also use C and very rarely assembler on the PC, and I would be interested to try the C++ implementation on the 8051. Tell me, have you actually tried it? If not, have you read any report by anyone who has actually tried it?

    Stefan

Reply
  • Erik,

    1) Sure, that's been on the go for years. Bjarne claims it would have been funnier if he'd written it but I doubt that somehow.

    2) Indeed. However, I feel the same way when someone states that something is the wrong choice in all situations because that is equally false.

    3) I do use C++ on the PC and I don't use C++ on the 8051. However, I also use C and very rarely assembler on the PC, and I would be interested to try the C++ implementation on the 8051. Tell me, have you actually tried it? If not, have you read any report by anyone who has actually tried it?

    Stefan

Children
  • C++ compilers are very useful for embedded design. This is true even if you write using only C constructs. The primary benefit I find is that they can help remove type errors not caught by C compilers.

    When selecting a language and compiler, you need to weigh the cost of the options afforded you.