Pascal Compiler for 8051 Microcontrollers
Embedded Systems
We live in a world where computer systems are inevitable. The majority of computer systems in use today are embedded in other machinery, such as vehicles, safety devices, telephones, mp3 players, USB sticks and almost all peripherals for computers. These computers are called embedded systems. Usually we don't see such embedded system as a part of some device, i.e. it is embedded with the device. An embedded system is a special computer system designed to perform one or a few specialized functions, often with real-time processing. In contrast, a general-purpose computer, such as a PC, can do many different tasks depending on programming. A general-purpose computer has its parts like keyboard, monitor, case and it is not embedded into anything. Embedded systems control a lot of common devices in use today and can be anything from very simple to extremely complex.
Embedded systems usually have no fancy user interface. Their main function is to support the main device where they are embedded. While some embedded systems are very sophisticated, many have minimal requirements for processing speed and program length, with no operating system, and low software complexity. Typical I/O devices include ADC, DAC, PWM outputs, cameras, relays, solenoids, LEDs, small or custom OLED displays, radio frequency devices, and sensors for data such as temperature, atmospheric pressure, motion, speed etc. Most such peripheral devices use I2C bus for communication with the microcontroller. Embedded systems usually have no keyboard, large screen, disks, printers, or other recognizable I/O devices of a general-purpose personal computer, and may lack human IO devices of any kind.
Microcontroller
A key part in many embedded systems is a micro-controller. A micro-controller (also MCU or uC) is a functional computer system-on-a-chip (SoC). It contains everything needed to execute programs and to interact with the world: a processor core, memory, programmable IO peripherals and in some cases also specialized blocks to perform special functions, e.g. encryption. Micro-controllers include an integrated CPU, memory (a small amount of RAM, FLASH/ROM program memory, or both) and peripherals capable of IO. Microcontrollers are used in automatically controlled products and devices, such as automobile engine control systems, various players, hand held devices, traffic control systems, industry automation, office machines, appliances, mobile phones, and consumer electronics. By reducing the cost, size, and power consumption compared to a classical design using a separate microprocessor, memory, and input/output devices, microcontrollers make it economical to electronically control many more processes. First microcontrollers were 8-bit, while today many 32-bit micro-controllers are very affordable and offer high performance. One of the still very popular 8-bit microcontrollers is Intel 8051.
8051 microcontrollers
The original 8051 microcontroller is a Harvard architecture, single chip microcontroller which was developed by Intel in 1980 for use in embedded systems. Today this architecture is used in many newer microcontrollers. Intel's original versions were popular in the 1980s and also in 1990s, but has today largely been superseded by a vast range of faster or functionally enhanced 8051-compatible microcontrollers manufactured by more than 20 independent manufacturers including Silabs (formerly Cygnal), Atmel, Infineon Technologies (formerly Siemens AG), Maxim Integrated Products (via its Dallas Semiconductor subsidiary), NXP (formerly Philips Semiconductor), Nuvoton (formerly Winbond), ST Microelectronics, TI and Cypress Semiconductor. Intel's official designation for the 8051 family of microcontrollers is MCS-51. Some advanced microcontrollers using 8051 core can achieve execution speeds close to 100 MIPS.
Newer microcontrollers with 8051 core have many interfaces like SPI, I2C or CAN implemented in hardware. However, even the oldest 8051 microcontroller that has no dedicated hardware, can use the I2C bus because it easily implemented in software. I2C specifications only define the upper speed limit so that any I2C controller can use the speed that is suitable for all slave devices on the board.
8051 Compilers
To program any microcontroller you need a compiler. Several C compilers are available for the 8051 family, most of which feature extensions that allow the programmer to specify where each variable should be stored in its six types of memory, and provide access to 8051 specific hardware features such as the multiple register banks and bit manipulation instructions. This is one of specialties of the 8051 architecture. While in some cases it offers advantage, it also means difficulty for a compiler to take into account different addressing modes.
Other high level programming languages such as Pascal, BASIC, Forth, PL/M and Modula 2 are available for the 8051 family, but they are less widely used than C and assembly language. In embedded world C is almost a standard for programming language. There are many discussions on which language is better, in particular between C and Pascal programmers. There is no clear winner. Both languages can be used to write any kind program.
C and Pascal programming languages
C programming language is a general-purpose, structured, procedural, cross-platform, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the UNIX operating system. C programming language is also standardized (ANSI C). Although C was designed for implementing operating systems and system software, it is also widely used for developing application software. It is widely used on many different software platforms and computer architectures, and several popular compilers exist. C programming language is also widely used for embedded programming. C has greatly influenced many other popular programming languages, most in particular C++, which originally began as an extension to C programming language.
Pascal programming language is an influential, imperative and procedural programming language, designed by Niklaus Wirth in late 1960s as a compact and efficient language intended to teach good programming techniques using so-called structured programming and data structuring. An extension known as Object Pascal was designed for object oriented programming. Borlad has become famous by their popular Turbo Pascal compiler for PC in early 80s. Turbo Pascal with its successors including Dephi is probably the most widely used Pascal compiler.
You should read this:
Comparison of Pascal and C (Wikipedia)
Top 10 reasons why Pascal is better than C
This tutorial is an introduction to the Pascal simple, yet complete, introduction to the Pascal programming language. It covers all of the syntax of standard Pascal, including pointers.
Pascal compiler for 8051 family
Since C programming language is widely used for embedded programming, most users of 8051 microcontrollers are using some C compiler. Keil commercially offers a complete set of tools for 8051 while SDCC is an open source C compiler for 8051.
There are a few Pascal compilers for the 8051 family of
microcontrollers, but most of them have limited usability. There is one
exception - Turbo51, a free Pascal compiler for the 8051 family of microcontrollers. Turbo51 can
generate efficient code comparable to leading C compilers.
Turbo51 uses Borland Turbo Pascal 7 syntax. It supports floating point calculations and you can mix Pascal and assembly language. Advanced multi-pass optimizer and smart linker generate high quality code in many formats: binary (.bin), Intel HEX (.hex), OMF-51 (.omf), assembler source code (.asm). Source-level debugging is also possible with extended object (OMF) file.
Optimizations for high quality code
One of the key strengths of Turbo51 are optimizations to generate high
quality code. Turbo51 uses many advanced optimization algorithms so the programmer can focus on the program itself without worrying much about code size.
Turbo51
is released as a freeware. You can download it and use it for hobby
projects or serious work. On the Turbo51 web page you will find
documentation on how to use the compiler and many code examples that show the syntax, features and
generated files. And if you are still missing some command, feature or
have a problem compiling your project you can always ask author for help.
There is also a possibility to start using Turbo51 if you have no knowledge about Pascal. If you are
already familiar with the 8051 assembly language programming you can
start with Turbo51 as 8051 assembly language compiler and then add some
Pascal statements until you become familiar with Turbo51 and Pascal
syntax. This way you can learn assembly language, get
some ideas on how to write effective code and become familiar with the
compiler. A good practice is also to compile some Pascal code and then
check generated assembler source code.
Now you can choose between plethora of good C
compilers and Turbo51 - a free Pascal compiler for 8051
microcontrollers. If you like Pascal programming language and you are programming for the 8051 microcontrollers then you will love Turbo51.
Turbo51
{ 8051 Pascal compiler } Program Turbo51; Uses FastCompiler, AdvancedOptimizations, SmartLinker, AssemblerFileGenerator; begin Download; Configure; Repeat UseIt; While ThereIsAProblem do begin CheckCode; CheckDocumentation; TyrAgain; Case ProblemSolved of True: Break; else AskForHelp; end; end; If UpdateAvailable then Update; If Satisfied then Donate ($20); until NoMoreProjects; end.