if i have 8051 MCU Assembler and PIC MCU Assembler how does C change same "hello word!" to different machine languages;
HOW does C language work and How ues it in different MCU??
In general different compilers are used for different platforms. A compiler is a program that compiles the C code into the machine code of a given processor or MCU.
http://en.wikipedia.org/wiki/Compiler
In the case of GCC the same compiler can be used with a variety of MCU's and CPU's. This is achieved by having a different "backend" for GCC for each MCU that GCC supports.
http://en.wikipedia.org/wiki/GNU_Compile...
In the case of MCU’s one uses a cross compiler. That is a compiler that runs on a PC but the target processor is an MCU. See
http://en.wikipedia.org/wiki/Cross_compi...
C was developed (from B -- which descended from BCPL) as a higher level language that the Unix Kernel could be rewritten in. This meant that Unix could be more easily ported to the PDP-11. C started out a language for systems programming. This also has made it a good language for embedded systems. Note the BCPL was a language specifically for developing compilers (for other languages) and it had a new feature in that the front end and back end were distinct so that only a small part of the compiler needed to be rewritten to compile code for a different processor.
http://www3.telus.net/danpeirce/c_18/
A C program for an MCU will probably have some portions that are not portable from MCU to MCU. For example for a hello world program one might need a function to open (initialize) the USART. In PIC18FXXXX MCU's (using MPlab C18) the USART (for serial communications) is the standard output device. If one put the USART initialization code in a function than it could be both that function that will need to be changed if the code is ported to a different MCU and any setup code specific to the MCU.
http://en.wikipedia.org/wiki/C_%28progra...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment