Turbo51
Developer(s)Igor Funa
Stable release
0.1.3.5 / December 3, 2009
Operating systemWin32
TypeCompiler
LicenseFreeware
Websitehttp://turbo51.com/

Turbo51 is a Pascal compiler for Intel 8051 micro-controllers. It features Borland Turbo Pascal 7 syntax, support for inline assembly code, source-level debugging, and optimizations, among others. The compiler is written in Object Pascal and produced with Delphi.

In 1980s Intel introduced the 8051 as the first member of the MCS-51 family of microcontroller. Today hundreds of cheap 8051 derivatives are available from tens of manufacturers. This makes the MCS-51 architecture so interesting for professionals and hobbyists. It is rather surprising fact that this 8-bit architecture is still in use today. In other words, 8051 microcontrollers are still very popular. Several widely used C compilers are available for the 8051, however, there are only a few Pascal compilers for the 8051 family. Turbo51 is available as freeware and was created with the goal to make a Pascal compiler for the 8051 family of microcontrollers that will be fast as Turbo Pascal, will use the same syntax and will generate high quality optimized code.

Language dialect

edit

Turbo51 uses Borland Turbo Pascal 7 dialect. The syntax was extended with some constructs to support specific features of the 8051 family.

Var   RS485_TX: Boolean absolute P3.2;
      I2C.SDA:   Boolean absolute P3.7;
      I2C.SCL:   Boolean absolute P3.4;

      EEPROM_Data:    TEEPROM_Data XDATA absolute 0;

      ModuleAddress:  Byte;
      RX_LedTimer:    Byte;
      TX_LedTimer:    Byte;

      SavedOutput:    TOutputData IDATA;
      OutputsAuxData: Array [1..8] of Byte IDATA;

Features

edit
  • Win32 console application
  • Fast single pass optimizing compiler
  • Borland Turbo Pascal 7 syntax
  • Full floating point support
  • Mixed Pascal and assembler programming
  • Full use of register banks
  • Advanced multi-pass optimizer
  • Smart linker
  • Generates compact high quality code
  • Output formats: Binary, Intel HEX, OMF51 Object Module Format
  • Assembler source code generation

"Hello World" Example

edit
Program HelloWorld;

Const
 Osc      = 22118400;
 BaudRate = 19200;

 BaudRateTimerValue = Byte (- Osc div 12 div 32 div BaudRate);

Var SerialPort: Text;

Procedure WriteToSerialPort; Assembler;
Asm
  CLR   TI
  MOV   SBUF, A
@WaitLoop:
  JNB   TI, @WaitLoop
end;

Procedure Init;
begin
  TL1  := BaudRateTimerValue;
  TH1  := BaudRateTimerValue;
  TMOD := %00100001;    { Timer1: no GATE, 8 bit timer, autoreload }
  SCON := %01010000;    { Serial Mode 1, Enable Reception }
  TI   := True;         { Indicate TX ready }
  TR1  := True;         { Enable timer 1 }

  Assign (SerialPort, WriteToSerialPort);
end;

begin
  Init;
  Writeln (SerialPort, 'Hello world!');
end.

See also

edit
edit