Turbo51

Turbo51
DeveloperIgor Funa
Stable release
0.1.3.12 / February 1, 2012; 14 years ago (2012-02-01)
Operating systemWin32
TypeCompiler
LicenseFreeware
Websiteturbo51.com

Turbo51 is a compiler for the programming language Pascal, for the Intel MCS-51 (8051) family of microcontrollers. 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 the 1980s, Intel introduced the 8051 as the first member of the MCS-51 processor family. Today, numerous low-cost derivatives are available from numerous manufacturers. This has contributed to the architecture's continued use. The architecture is still in use today, and keeps a presence in embedded systems. Among compilers targeting the 8051 architecture, several C compilers exist, but fewer Pascal compilers are available. Turbo51 is available as freeware and was developed to make a Pascal compiler for MCS-51 processors that will be as fast as Turbo Pascal, will use the same syntax and will generate optimized machine code.

Language dialect

Turbo51 uses Borland Turbo Pascal 7 dialect. The syntax was extended with some constructs to support specific features of MCS-51 processors.

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

"Hello World" example

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