??? 12/14/04 14:30 Read: times |
#83067 - 8051 vs C - answer is wrong Responding to: ???'s previous message |
They suppose, that 8051 architecture is very BAD for C-programming. Not really very bad, but it imposes some challenges! 1)The main reason is, probably, DPTR feature. Compilers generate very large and very slow code for simple operations with large amount of data. No. The main problem is the lack of any significant stack space. This is why Keil et al (and PL/M before it) have to do all that messing about with overlaying, resulting in inherently non-reentrant functions. The DPTR has nothing specifically to do with 'C' - it takes the same number of machine instructions to accesses an XDATA byte whether you code in 'C' or assembler. 2) In my opinion it's so conveniently to use C-structures (sometimes nested). But when I compile with keil such a string:
X->Y->z = ...; i have sometimes over 30 assembler instructions as a result. It's very,very bad. That is not the fault of the compiler nor even the language - that is the programmer's fault for writing "inefficient" code! Going through so many levels of indirection will be "inefficient" on any processor. The problem here is the use of pointers; not structures per se; the following would take no more code than a simple variable assignment: X.Y.z = ...;Again, if you tried to write the equivalent in assembler, it would almost certainly end up taking just as much code: think about it - how would you write that statement in assembler? Could you do better that the compiler? So, there are many problems with C-programming for x51 mcu. None of this has anything specifically to do with 'C' - it is all about poor use of the tools, and failure to understand the underlying architecture. It is impossible to write efficient code in any language without a thorough understanding of the underlying architecture. |
Topic | Author | Date |
asm vs C | 01/01/70 00:00 | |
HLL | 01/01/70 00:00 | |
asm vs C | 01/01/70 00:00 | |
C and other HLLs | 01/01/70 00:00 | |
modern - productive | 01/01/70 00:00 | |
Lunch | 01/01/70 00:00 | |
Speed writing vs speed running. | 01/01/70 00:00 | |
C | 01/01/70 00:00 | |
Belt or suspenders? | 01/01/70 00:00 | |
Learn C Then... | 01/01/70 00:00 | |
beware | 01/01/70 00:00 | |
This advice is great | 01/01/70 00:00 | |
I love C !!! | 01/01/70 00:00 | |
Easy migration | 01/01/70 00:00 | |
3rd party | 01/01/70 00:00 | |
Having recently started converting... | 01/01/70 00:00 | |
Learning C for tte 8051 and 8-bit uC | 01/01/70 00:00 | |
Obviously there is a reason... | 01/01/70 00:00 | |
as to reasons | 01/01/70 00:00 | |
Obviously there is a reason... | 01/01/70 00:00 | |
8051 vs C :) | 01/01/70 00:00 | |
8051 efficiency | 01/01/70 00:00 | |
a 51 for handling large amount of data | 01/01/70 00:00 | |
8051 vs C - answer is wrong | 01/01/70 00:00 | |
addendum to post Andys above | 01/01/70 00:00 | |
asm.vs.C forever | 01/01/70 00:00 | |
click, click, click | 01/01/70 00:00 | |
Eh?? | 01/01/70 00:00 | |
8051 vs C - answer is wrong | 01/01/70 00:00 | |
Don't believe all you hear! | 01/01/70 00:00 | |
the C myth | 01/01/70 00:00 | |
myth | 01/01/70 00:00 | |
Then Don't Do that | 01/01/70 00:00 | |
Exactly! | 01/01/70 00:00 | |
why only? | 01/01/70 00:00 | |
Right tool for the Job | 01/01/70 00:00 | |
asm VS C | 01/01/70 00:00 | |
Which C? | 01/01/70 00:00 | |
? | 01/01/70 00:00 | |
Handly, But | 01/01/70 00:00 | |
Both i think | 01/01/70 00:00 | |
Neither! | 01/01/70 00:00 | |
Compiler on a floppy? | 01/01/70 00:00 | |
Why do people use C? | 01/01/70 00:00 | |
Code Complete | 01/01/70 00:00 | |
Ironic | 01/01/70 00:00 | |
Re: asm VS C | 01/01/70 00:00 | |
re:asm vs C | 01/01/70 00:00 | |
derivatives of same | 01/01/70 00:00 | |
portability | 01/01/70 00:00 | |
re: portability | 01/01/70 00:00 | |
(non-)portability | 01/01/70 00:00 | |
re: | 01/01/70 00:00 | |
re:![]() | 01/01/70 00:00 | |
What do you want? | 01/01/70 00:00 | |
HLL | 01/01/70 00:00 | |
Personal dislike... | 01/01/70 00:00 | |
A comment to ASM versus C | 01/01/70 00:00 |