ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Pascal Compiler for 8051 Microcontrollers

Updated on April 2, 2012

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 Board
Embedded Board

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.

Learn Pascal


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.


Turbo51 integrated with PSPad
Turbo51 integrated with PSPad

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.

Comments

Submit a Comment

No comments yet.

working

This website uses cookies

As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://hubpages.com/privacy-policy#gdpr

Show Details
Necessary
HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
LoginThis is necessary to sign in to the HubPages Service.
Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
AkismetThis is used to detect comment spam. (Privacy Policy)
HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
Features
Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
MavenThis supports the Maven widget and search functionality. (Privacy Policy)
Marketing
Google AdSenseThis is an ad network. (Privacy Policy)
Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
Index ExchangeThis is an ad network. (Privacy Policy)
SovrnThis is an ad network. (Privacy Policy)
Facebook AdsThis is an ad network. (Privacy Policy)
Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
AppNexusThis is an ad network. (Privacy Policy)
OpenxThis is an ad network. (Privacy Policy)
Rubicon ProjectThis is an ad network. (Privacy Policy)
TripleLiftThis is an ad network. (Privacy Policy)
Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
Statistics
Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)