April 30, 2012

Compilers For 8051 Microcontrollers

Most computers in use today are embedded in some electronic device, from appliances to movable devices. Such computers are called embedded systems. A key component in embedded ideas is a microcontroller. This is a microprocessor with emphasis on I/O operations. The role of microcontroller is to control electronic devices providing all valuable switching, measurements and transportation with the world. Microcontroller is the brain of the device.

The first microcontrollers emerged in 1970s. They were 8-bit devices capable of running a program from internal Rom or external Eeprom memory. One of the popular microcontrollers was Intel 8051. Intel advanced a family of microcontrollers named Mcs-51, where 8051 was probably the most popular member. It is spectacular, that this architecture is still popular today. There are many manufacturers like Atmel, Silicon Labs and Nxp that still use the 8051 core for their microcontrollers. This means that all the tools that were advanced thirty years ago can, at least in theory, be still used today to manufacture programs for 8051-compatible microcontrollers.

The 8051 family of microcontrollers is extra because it has many types of memory that need extra instructions to way it. The basic memory is located in the Data segment and most instructions can way it. The size of this memory segment is 256 bytes. The upper 128 bytes are reserved for extra Function Registers, memory mapped registers that control functions of the microcontroller. The lower half is divided into three parts. Addresses from 0 to 31 are memory addresses for registers R0 to R7 in 4 register banks (0 to 3). Addresses from 32 to 127 are general purpose memory locations with added function of addresses from 32 to 47 which are also bit-addressable. Most 8051 microcontrollers (except the customary 8051 microcontroller) have also added 128 bytes of Idata memory which is similar to Data memory but can only be accessed indirectly. It is located at addresses from 128 to 255. extra instructions are needed for this type of memory. 8051 microcontrollers keep also external memory located at Xdata segment. Its size is 64kB and can be accessed only indirectly with few extra instructions. There is also a extra bit-addressable memory where you can way private bits (256 bits in total). The first half of this bit-addressable memory is general purpose memory while the upper half maps to bit-addressable extra function registers.




This complicated memory model makes compiler construction a complicated task. But because the 8051 microcontrollers were well accepted in industry and they are also gift in many hobby projects, quite a lot of clubs decided to manufacture their own 8051 compiler. There are many commercial C compilers for 8051 microcontrollers available. Most of them are part of some commercial holder together with integrated amelioration environment (Ide), debugger and simulator. Among those the Keil Ide/compiler is probably the most popular. There is also one popular and free C compiler Sdcc (Small expedient C Compiler). Sdcc is a retargettable, optimizing Ansi - C compiler that targets the Intel 8051, Maxim 80Ds390, Zilog Z80 and the Motorola 68Hc08 based microcontrollers. Sdcc is Free Open Source Software, distributed under Gnu general group License (Gpl).

The other hemisphere in 8051 programming is Pascal. Pascal programming language was designed by Niklaus Wirth in late 1960s. Its main purpose was to teach programming. The language itself is focused on structured programming and has many constructs for data structures. Borland Turbo Pascal was probably one of the most prosperous Pascal compilers around. It was very popular in 1980s and early 1990s. Its successor was Borland Delphi which is a optical rapid application amelioration tool still in use today. Pascal is rarely used in embedded programming although there are compilers ready also for Avr, Arm and Pic microcontrollers.

There is probably only one commercial Pascal compiler for 8051 microcontrollers, the Ksc Pascal51. This clearly shows the store of C and Pascal compilers. However, there is also Turbo51, a free Pascal compiler for 8051 microcontrollers. Turbo51 is a fast particular pass optimizing compiler with Borland Turbo Pascal 7 syntax and advanced multi-pass optimizer.

Similar situation is also with other popular microcontroller families like Avr, Arm and Pic. A plethora of C compilers are ready and only a few Pascal or Basic compilers. Of course, we should not count assembly language compilers. These are the basic compilers for every processor or microcontroller. The most leading thing with compilers is the code they generate. This should be very optimized for size and speed. Comparing the code size of a program written for the same task in Sdcc and in Turbo51 we can desist that the follow is not dependent on programming language. Either C or Pascal can be used to generate a compact and optimized code. It is just the personal preference of the programmer what language he will use.

It is very tantalizing to collate generated code for some particular C or Pascal instruction, e.g. For 8051 microcontroller. We get roughly the same microcontroller instructions. This is someone else confirmation that high level language is only a tool to present the algorithm. It is the task of an optimizing compiler to generate private microcontroller instructions that do what is needed.

Microcontroller store will continue to grow. One of the most leading markets for microcontrollers is the automotive industry. It is the a driving force in the microcontroller market, especially at it's high end. Many microcontrollers were advanced specifically for automotive applications. On the other hand roughly every electrical expedient from toys to appliances uses some form of embedded system. The end is that with microcontroller store growing also the need for high-quality embedded compilers will grow. This will lead to better compilers that will generate faster and more optimized code.

Compilers For 8051 Microcontrollers

PSP USB Cable Micro USB Cable Apple TV Macbook Pro Motion Sensor