Language interpreter for uC-based systems

Similar projects worth following
Terminal-BASIC is an implementation of BASIC programming language, partially compliant to the standards ISO/IEC 6373:1984 and USSR/Russian ГОСТ 27787-88. It is a pure interpreter, running on the Arduino compatible boards and on linux PC, using API level emulation of the Arduino and TVOut libraries. See also the companion project of Terminal Basic SBC

  • Latest news from the Terminal-BASIC development

    Andrey Skvortsov02/15/2019 at 23:14 0 comments

    New 1.2 release adds well-known command POKE and function PEEK. On AVR mcus these features allow to work with peripheral control registers directly.

    This release will be LTS, receiving minor updates (stability and standard compliant) for many months.

    Now I'm preparing the 2.0 release, which has completely rewritten in pure C lexical analyzer. New lexer can be configured to use single byte encoding national languages keywords and identifiers. Here you can see the russian lexical variant, close to lexems, used by the Soviet language РАПИРА (rapier):

  • Upcoming refactoring

    Andrey Skvortsov01/02/2019 at 22:32 3 comments

    Some OpenSource/DIY software projects, containing legacy C code have been rewritten into C++. There is no any reasons to stay on C if C++ available on target platform. It has everything that C has and many "free" features, which cost 0 extra bytes and 0 extra instructions.

    But I think Terminal-BASIC must  go through a reverse transformation. I'm rewriting core components in pure C.

    The 8-bit AVR microcontrollers were primary target at the project starting point. G++ supports this architecture, as well as 32-bit ARM versions of Arduino DUE, etc.

    But many interesting architextures do not support C++.  I think about running Terminal-BASIC on Z80 with SDCC, PIC uCs and... SEGA Genesis consoles (MC68000 has G++ port, but  the popular SDK SGEN does not support C++).

  • One-line user defined functions

    Andrey Skvortsov11/27/2018 at 15:25 0 comments

    Terminal-BASIC 1.2rc1 finally acquires an important feature of one-line user defined functions with arbitrary number of arguments.

    This is a short example:

  • Double DUE

    Andrey Skvortsov08/24/2018 at 12:02 0 comments

    This example uses 2 arduino DUE as h/w platform for TB.

    First arduino board with SD card reader (host) runs TB with 64kb available BASIC memory.

    Second one makes VGA output using modified DUE VGA library, implementing part of the ANSI terminal control protocol and custom graphics binary protocol.

    It suffers from minor bugs and incompatabilities, but Terminal-BASIC TETRIS from SD card runs much more acceptable.

  • Some old games

    Andrey Skvortsov06/20/2018 at 22:45 0 comments

    I'v implement the ON .. GOTO control structure and fixed FOR .. LOOP details, and Terminal-BASIC made one more step towards the ANSI Minimal BASIC standart.

    BTW last features allow to run many old games from "BASIC Computer games":

  • Terminal-BASIC time-sharing mainframe

    Andrey Skvortsov12/15/2017 at 13:23 0 comments

    If the hardware platform supports multiple UARTs, like Atmega 1284/128/2560, terminal-basic can function as simple time-sharing system.

    It doesn't use any OS, even FreeRTOS. The main interpreting context object is designed as finite state machine instead, which state-chart looks like this:

    The FSM has very short step method and main loop executes many interpreters in order, thus implementing primitive non-preemptive Round-Robin scheduling algorithm.

    This time-sharing mode can be enabled by the BASIC_MULTITERMINAL option in the config_arduino.hpp or config_linux.hpp, depending on the version, being built.

    Terminal-BASIC 1.1 (link) has working implementation of this mode.

  • Terminal-BASIC on Arduino DUE with SD card

    Andrey Skvortsov11/25/2017 at 13:54 0 comments

    It seems Terminal-BASIC is ready to be used on Arduino DUE with SPI SD Card interface.

    I'v decided to write a short HOWTO about that.

    1. Hardware.

    I use an Arduino DUE compatible board with SPI SD module and old 128M SD card:

    2. Firmware
    2.1 Let's download last version of Terminal-BASIC sketch and libraries from sorceforge.
    Go to "Files" page, select latest version and download the archive. Now I'am using
    2.2 Unpack the archive. We'll have some folders: terminal-basic-<VERSION> is a main project sketch directory, others are libraries. FOr now only libsdcard needs to be installed. It is slightly modified version of standard SD library. I removed the dependency of heap management functions. On 8-bit AVR this helps to save reasonable amount of flash. Let's copy libsdcard/SDCard to ~/Arduino/libraries.
    THen open sketch in Arduino IDE, select Arduino DUE Programming port board.

    2.3 Configuration

    Select "config.hpp" file. It contains a list of condition compilation flags of different terminal-basic features. To enable option set it's value to 1, to disable - define as 0.

    Default options set is targeted against small 8-bit boards and on DUE we can enable some extra abilities.

    I will enable next options:

    USE_MATRIX (Darthmouth BASIC-like matrix operations)

    SET_PRINTZNES (On ANSI compatible terminals it will set print zones width)

    USESD (SD card commands)

    Option USE_SAVE_LOAD (SAVE, LOAD CHAIN commands which use internal EEPROM on 8-bit AVR's) should be disabled on Arduino DUE.

    On ARduino DUE default BASIC memory size is 65535 bytes (it must be less then 65536). This size can be set in file "config_arduino.hpp" under the "__SAM3X8E__" ifdef branch.

    Compile and program the board. After some warnings it should takeoff.

    2.4 SD Card preparation.

    Here you can download ANSI minimal BASIC test programs and some others.

    Copy *.BAS files in root directory under FAT16/32 formatted card.

    Insert card and plug the board to PC using Programming port. Connect terminal emulator program, using 115200 baudrate, disable local echo and local line editing - terminal-basic do it for us.

    The terminal shopuld look like this upon success:

    Let's test it.

    Type in a simple program:

    10 FOR I%=1 TO 9 : FOR J%=1 TO 9
    20 PRINT I%;J%;I%*J%
    30 NEXT J%:NEXT I%
    40 END

     Input LIST to see it's source and RUN to test. Program can be saved using DSAVE "filename w/o extension" and loaded by DLOAD "filename w/o extension". SD contents list printed on DIRECTORY command. DCHAIN "filename w/o extendion" loads new program, saving old variables.

  • DATA,READ,RESTORE implemented

    Andrey Skvortsov11/21/2017 at 10:03 0 comments

    Terminal-BASIC solved a little challenge of DATA/READ/RESTORE commands.

    The MAT READ <name> construct from Darthmouth BASIC is also implemented.

  • Classic tetris game: milestone and epic fail

    Andrey Skvortsov09/04/2017 at 21:26 0 comments

    Terminal-BASIC becomes stable and functional enough to run the program like classic tetris game. It's quite compact and runnable not only on Arduino MEGA microcomputer but even on Single chip BASIC computer. But it simply is TOO slow!.. As shown on the videos below, SDL TVout emulation is ok, but on real device with TVoutEx output it's fail.

    Arduino MEGA with 32 Kb shield:

    SDL emulation:

    Very disappointing. I will try output through the dedicated VDC, such as NGT20. After all, TVout library forms interrupt overloaded environment.

  • TVoutEx library: SDL emulation

    Andrey Skvortsov08/24/2017 at 15:35 0 comments

    SDL-based emulator helps to debug non-interrupt and non-avr specific part of the TVoutEx library

View all 12 project logs

Enjoy this project?



SirWolf wrote 03/15/2018 at 21:01 point

It would be very nice if the PS/2 keyboard could be used directly without other Arduino.

  Are you sure? yes | no

Andrey Skvortsov wrote 03/20/2018 at 13:46 point

I'v tested a configuration, based on the Dan's Atmega1284 single chip computer

Terminal-BASIC has necessary libraries and config options. This is my test video

  Are you sure? yes | no

SirWolf wrote 03/20/2018 at 15:07 point


  Are you sure? yes | no

SirWolf wrote 12/13/2017 at 12:50 point

I would like to try the Terminal-BASIC, which seems absolutely fantastic. But whatever I do, I'm getting the STATIC SEMANTIC ERROR:1.

Like this:
VERSION 1.1-rc1-144
10 print 1+1


I tried it on Arduino UNOR3 and on Arduino Mega 2560, the error is still the same.
Could it be something encoding-related?

I'm using PuTTY on WIndows 10 with local echo and local line editing disabled.

  Are you sure? yes | no

Andrey Skvortsov wrote 12/13/2017 at 20:59 point

The keywords are case-sensitive. String constants may include lower letters and single-byte encodings characters.

  Are you sure? yes | no

SirWolf wrote 03/20/2018 at 12:45 point

Thank you very much! I feel stupid :).
Are you planning to make it case insensitive in the future?
And ability to use PS/2 keyboard directly would be very nice too :).

  Are you sure? yes | no

Martian wrote 10/05/2017 at 19:19 point

This looks like a much nicer alternative than TinyBASIC, I'm going to see if I can get it running on my Arduino Due.

Great project, keep up the excellent work!

  Are you sure? yes | no

Andrey Skvortsov wrote 10/05/2017 at 21:02 point

Recently I'v spent some time to fix minor incompatabilities with Arduino DUE. Last versions should be runnable on DUE, but I'v not tested SD card support on it. Current SDCard module uses SD lib on Arduino and API level SD lib emulator on PC.

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates