Re: Microcontroller Project



Keith wrote:
On Mon, 27 Mar 2006 14:33:03 -0800, David L. Jones wrote:

Keith wrote:
In article <1143494228.117311.162780@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
altzone@xxxxxxxxx says...
Keith wrote:
In article <1143447041.276029.172680@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
altzone@xxxxxxxxx says...
Keith wrote:
On Sun, 26 Mar 2006 17:28:03 -0800, David L. Jones wrote:

akshaychander@xxxxxxxxx wrote:
Sorry for the late reply.

Yes, I have to do the project in 8051. I have studied the theory of
8051, but have very little practical experience.

As far as languages are concerned, there is no restriction. I am
planning on using C.

In that case a good C compiler will take care of most of the low level
8051 stuff for you.

I disagree! A C compiler will just mask the nonsense underneath. It
*will* come back to bite you (think "stack").

Ok, I'm not an 8051 guy, so I'll take your word there is a potential
issue here.

I looked into various compilers when I did a major (~25kloc) 8051
project a decade ago. The only one that didn't mask the
limitations (and even advantages) of of the 8051 was PL/M51.

I'd then suggst you take a look at some more modern compilers perhaps.
Countless people use C on the 8051, I'm sure it's not that bad.

The point is that one is *necessarily* doing bit-banging on the
hardware (the whole point of a uC). C doesn't give much advantage
and a _lot_ of headaches.

*snip*

I see no advantage in using C. Portability isn't an issue since
hardware is the name of the game with uCs. Any abstraction will
lead to resource conflicts. No, actually, I haven't been bitten by
stack issues because I've used assembler. I don't let the compiler
assign *anything*; not even what byte the bits go in.

*snip*

I disagree. C has no advantage over a half-decent macro assembler
and a MAKE utility. Abstraction has a *lot* of disadvantages when
you're severely hardware constrained. Sure, people use C on 8051s,
but I suspect for many C is the only tool in their shed.

Why do you snip anything you've said? Are you trying to be cute, or win
an argument without posting your thoughts?

The argument was (and is) going nowhere.

Ok, it looks like this one could never end. You are pro-assmebler, I'm
pro-C.

For microcontrollers, you bet! C is a waste of resuorces, kinda like
WinBlows.

Your choice, and that's fine. I'd rather halve my development time than
save a few bytes of RAM.
A heck of a lot of poeple will use C on micros because it provides many
advantages.

I used to do all my work in assembler unless I started using C and then
never looked back. I still do some inline assembler where it's called
for, but that's it.

It *is* called for with these tinker-toys. If you're embedding a real
processor, I might have a different opinion.

Assembler is NOT required for a microcontroller.
Thousands of embedded engineers who use C almost exclusively will tell
you the same thing.

There are *massive* advanatges to using C (or another high level
language) on a micro - speed of development, platform portability (which
is a BIG requirement for some people), ease of peer review, ease of
maintenance, easier code-reuse, easier model migration, better code
visibility to name a few. This is why C compilers are immensely popular
these days.

Ok, you say there are "*massive* advantages", I don't buy it. I've told
you why I don't buy C for an 8051 for anyone other than a one-trick-pony.
Pony up!

If you cannot see how C can potentially offer the improvements I have
listed (plus many others), then you are either not familiar enough with
it to comment, or you simply don't know much about real practical
embedded programming meeting tight deadlines and providing maintainable
and peer reviewable code, or you are simply one of those
stuck-in-your-ways assembler guys. I suspect the later, it's a
relatively common affliction.

LOTS of embedded engineers use C on 8 bit micros and there ARE very
good reasons for it as I've listed. That might not be the case for you
and your situtation, and that's understandable. Just don't try and push
that one-sided view on others who are able to gain these big
advantages.

Yes, there are advantages to assembler as well (and disadvantages to C),
that's why I like many others use the best of both worlds. Making a
blanket statement like there are *no* advantages to using C is just
plain rubbish.

You've not offered one, other than some assinine statement
about "portability". Please! Even you don't believe this.

I've listed many advantages. I didn't just make these up, they are well
known advantages of using a high level language on embdedd micros.

I don't know about you, but every project I've ever worked on is maybe
5% low level I/O and register stuff (which assembler does well, but so
does C too), and 95% procesing and control (floating point, long int
math, string control etc) stuff which assembler sucks at and C does
well. Pretty obvious why I choose to use C.

Dave :)

.



Relevant Pages

  • Re: cheapest microcontroller for a noob with high level programming language skills?
    ... most micros can be programmed in C often the compiler is free/cheap ... if you want to learn assembler go with the AVR ... them some pattern, ...
    (sci.electronics.basics)
  • Re: What micros do you actually hate to work with?
    ... with less than tiny asm ... hassle to work with 32 bit longs in assembler for an 8 bit uP, ... Microchip's C compiler tools and their assembly under MPLAB. ... is that other programmers for C are easier to find. ...
    (comp.arch.embedded)
  • Re: The Promise of Forth
    ... Declare variables, declare locals, let the compiler do the work ... Forth could be considered the assembler for a simplified virtual ... If you use locals then you have to initialise them each time. ... there are likely to be libraries that could be profitably used within ...
    (comp.lang.forth)
  • The never ending assembly vs. HLL war
    ... > branch instruction excluded is not particularly effective optimization. ... > CPU, chances are pretty good it *won't* be optimal on a different CPU. ... > discussing the futility of optimizing it in *assembler* when the ... careful and consider the code the compiler is emitting (and adjust your ...
    (comp.lang.asm.x86)
  • Re: the quality of assembly language code
    ... Intel's compiler is supposed to ... I have found that I prefer 'C' and assembler roughly in inverse ... >> code than human beings writing raw assembly language. ... > assembly programmers and compilers. ...
    (comp.lang.asm.x86)