Sunday 27 April 2008

Compilers

A compiler is a high level language translator that combines the
programming ease of an interpreter with greater speed. This is
accomplished by translating the program (on a host machine such as a
desktop PC) directly into machine language. The machine language
program is then burned onto an EPROM or downloaded directly to the
microcontroller. The microcontroller then executes the translated
program directly, without having to interpret first.


The most popular microcontroller compilers are C and BASIC. PL/M,
from Intel, also has some popular support due to that company's
extensive use of that language.

Due to both its popularity and its slow speed, it was only logical
that BASIC would appear as a compiled language. A few companies
supply a BASIC compiler for several of the more popular
microcontrollers. Execution speed is drastically increased over
interpreted BASIC since the microcontroller is freed from the task of
interpreting the statements as the program runs.

While interpreted Forth approaches (and sometimes surpasses) the
speed of many compilers, compiled Forth screams along. Today there
are many high performance optimizing native code Forth compilers, and
there are also lots of very cheap or free public domain Forths. Some
of them like Tom Almy's ForthCMP produces optimized native code with
less overhead and better performance than just about anything else
out there. Of course it still has compactness and more elegant
factoring of functionality than in most languages.

C is now the language of choice for the entire universe. C is used
on computers from the tiny microcontroller up to the largest Cray
supercomputer. Although a C program can be a bit tedious at times to
read (due to the terse programming style followed by many C
programmers), it is a powerful and flexible development tool.
Although a high level language, it also gives the developer access to
the underlying machine. There are several very good and cheap C
compilers available for the more popular microcontrollers. It is
widely used, available, supported, and produces fairly efficient code
(fast and compact).

Read More......

Assembly language

Machine language is the program representation as the microcontroller
understands it. It is not easy for humans to read and is a common
cause of migraine headaches. Assembly language is a human-readable
form of machine language which makes it much easier for us flesh and
bone types to deal with. Each assembly language statement
corresponds to one machine language statement (not counting macros).


An assembly/machine language program is fast and small. This is
because you are in complete charge of what goes into the program. Of
course, if you write a slow, large, stupid program, then it will run
slowly, be too big, and be stupid. Assembly language (assembler)
can't correct stupidity - although sometimes I wish it could ;-).

If you are starting out learning about microcontrollers, it would be
worth your while first learning assembler. By programming in
assembler, you master the underlying architecture of the chip, which
is important if you intend to do anything significant with your
microcontroller.

Read More......