avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Question about gcc preprocessing andport/pinassignmen


From: Ben L. Titzer
Subject: Re: [avr-gcc-list] Question about gcc preprocessing andport/pinassignments
Date: Thu, 9 Dec 2004 10:20:03 -0800


On Dec 9, 2004, at 10:01 AM, Jeff Barlow wrote:

"Graham Davies" <address@hidden>  wrote:

It would be easier to write in assembly in the first place.

That was pretty much my point.

Perhaps you are saying that my
approach to programming is not suitable for embedded systems.

That's correct. Likewise low level driver code on larger systems. (I've
been doing both since the early seventies.)

I personally believe that significant portability can be achieved
with proper high level language support.

I agree. One can write code that's about 99% portable. So I write that
99% in C and the other 1% in assembly and spend the time I save doing
something fun. Life is too short to waste time fighting with
recalcitrant compilers.


One can wish there was a better way, and that someone at the language level could make your life much easier by changing the programming paradigm slightly to accommodate your situation. If there are recurrent themes in your (any many other people's) code that could be better implemented with a language construct, then perhaps it would save everyone the time and effort if there was a simple mechanism with simple semantics that both compilers and developers could agree on.

In this situation, I believe it goes back to the fact that at the hardware level you are manipulating the logical level of a pin--there is no corollary for this in C. If there were a way to address individual pins and manipulate their values, then this might be a good way to go.

For example:

pin OUTPUT_PIN = 27, INPUT_PIN = 31;
boolean STATE;

if ( INPUT_PIN && STATE )
  OUTPUT_PIN = true;
else
  OUTPUT_PIN = false;

It could then be the compiler's job to take the higher level concept of a "pin" and translate it into the correct, atomic instructions necessary to set the logical values, given a description of the device that contains information about how the state of pins is accessible through hardware registers.

-B

========================================================
One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man.
--Elbert Hubbard



reply via email to

[Prev in Thread] Current Thread [Next in Thread]