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.

Download Terminal-BASIC

See also the companion projects of Terminal Basic:

Adobe Portable Document Format - 187.02 kB - 02/16/2020 at 23:17


text-flat-xml - 244.07 kB - 02/16/2020 at 23:17


  • ESP8266 and ESPBoy port progress

    Andrey Skvortsov03/10/2020 at 22:11 0 comments

    The upcoming version of Terminal-BASIC uses SPIFFS to implement NVRAM and file system commands on esp8266:

    • SAVE
    • LOAD
    • CHAIN
    • DSAVE
    • DLOAD
    • DCHAIN
    • HEADER

    I'v test it on ESPBoy device. There is no suuport of TFT screen, buttons, sound and LED for now, but the port is fully functional, using UART.

    Sketch with data folder for SPIFFS, containing some BASIC programs: terminal-basic-2.3-a1

    DIRECTORY command shows the files list. Unfortunately, the files, written using esp8266 SPIFFS uploader have names, starting with '/'. To start AMAZING maaze generator, for example, one needs to type the command DLOAD "/AMAZIN" without BAS file extension

  • Forgotten feature

    Andrey Skvortsov02/18/2020 at 21:14 1 comment

    Eons have passed since multidimentional arrays were implemented in Terminal-BASIC, but one important feature was forgotten: arrays of strings!..

    The opcoming version 2.2-rc2 fix this issue and able to run an outstanding game of "Oregon trail":

    The modifed source for terminal-BASIC will be published after release of TB-2.2-rc2 in few days. Many thanks to RomanS for the idea.

  • Documentation

    Andrey Skvortsov02/16/2020 at 23:04 0 comments

    Terminal-BASIC has a terrible documentation. It would be great If somebody with good English skill (may be a native speaker after all...) wish to improve it.

    The source is in "fodt" format and you need LibreOffice to work with it. THe source document is placed at the main terminal-basic mercurial repositiory at Sourceforge.

  • ESP8266 port near to working status

    Andrey Skvortsov02/05/2020 at 18:07 0 comments

    Terminal-BASIC 2.2-alpha3 introduces new configuration options:

     - alignment of BASIC variables and arrays values (CONF_USE_ALIGN option in config.hpp)

     - disabling of structures packing (USE_PACKED_STRUCT option in config.h)

    Playing with these options allows me to run TB on ESP8266 nodeMCU board,

  • Towards the bytecode

    Andrey Skvortsov01/24/2020 at 00:16 0 comments

    One of the controversial features of Terminal-BASIC is the architecture of functional modules. The commands and functions defined in the modules, which are chained together in some order (except the very basic commands which are part of the language core). This simplifies language core, parser and lexer, also simplifies the creation of the new commands and functions, separates the functional groups from each other and so on. But the dark side drawback is that execution of the commands are slow and the more commands the slower it is. Moreover, the commands at the end of the chain are being executed slower then commands from the chain begin.

    In order to solve the speed issue, I introduced the command parsing step in the tokenization of the source code process. The commands calls contains the platform address of the implementation C-function. The call runs faster and no matters how many commands and modules are defined. Tokenization of the source includes change of the keyword strings by the binary KW codes, replace the number constants strings by the parsed binary numbers and now it also contains bytecode-like feature of replacing commands calling strings by the call command and the implementation address. This is optional feature, enabled by default in TB 2.2-alpha1 version.

    If the approach proves it's success, I will do the same for the functions from external modules.

  • Basic support of ESP32

    Andrey Skvortsov10/14/2019 at 22:35 0 comments

    Release 2.1.1 adds support of ESP32 platform.

    Use Arduino IDE and toolchain from

    Some configuration changes to start playing:

    1. config.hpp

    // Arduino IO module
    #define CONF_MODULE_ARDUINOIO     0
    // Input select
    #define S_INPUT SERIAL_I
    // Output select
    #define S_OUTPUT SERIAL_O

     2. config.h

     * SAVE, LOAD and CHAIN commands support
    #define USE_SAVE_LOAD        0

  • More old text games

    Andrey Skvortsov08/13/2019 at 08:25 0 comments

    Changes in upcoming 2.1 release allowed to run some text games from classic BASIC computer games book.

  • Downloads milestone

    Andrey Skvortsov06/14/2019 at 21:01 0 comments

    Just a little note.

    Last week Terminal-BASIC achieved 2000 file downloads on Sourceforge.

    Congratulations and thanks to all its users and contributors!

  • New datatypes

    Andrey Skvortsov04/30/2019 at 20:57 0 comments

    Upcoming Terminal-BASIC 2.1 introduce double precision floating point datatype on 32+ -bit platforms (Arduino DUE and PC) and changes other datatype conventions for naming the variables and arrays.

    Default type is single precision float, ! suffix - double precision float, % - 2-byte integer, %! - 4-byte integer, @ - logical, $ string:

  • Does it make sense to localize BASIC keywords?

    Andrey Skvortsov04/10/2019 at 22:03 3 comments

    As I wrote earlier, TB 2.0 (rc1 for now) has the ability to use different keyword sets in any single-byte encoding. If you are a TB user and if you consider useful some alternative keyword set in your native language, it can be included in future release of Terminal-BASIC. Now there was created a Russian keyword set, based on such, used in BASIC-6 system for БЭСМ-6 mainframe.





























    LEFT$ ЛЕВ$








    MID$ СРЕД$



























    STR$ СТР$







View all 23 project logs

Enjoy this project?



RomanS wrote 06/26/2020 at 04:47 point

still waiting for new release to play with )

  Are you sure? yes | no

ptrav wrote 01/15/2020 at 04:06 point

Could you also provide the code in BASIC for the retro games?

  Are you sure? yes | no

RomanS wrote 02/13/2020 at 14:23 point

excellent! probably the support of basic8 games soon )

  Are you sure? yes | no

ptrav wrote 01/15/2020 at 04:04 point

Good progress so far.

The code v 2.1.1. compiles and works fine on ESP32 with 2 major issues:

(1) The stuck is busted if using long reals (see Termina BASIC retro calc).

(2) The file system needs to be reworked - currently cannot compile with the SD option on.

  Are you sure? yes | no

Andrey Skvortsov wrote 02/13/2020 at 14:13 point

Branch 2.2 introduces the option CONF_USE_ALIGN, faces first issue.

The ongoing HAL library will allow use different external memory libraries for file system on different platforms.

  Are you sure? yes | no

John wrote 04/14/2019 at 13:34 point

This project looks great. I encounter difficulties to have it working properly, so here are some questions:

1. I tried to get Terminal Basic to communicate with Putty but no luck (same with Arduino IDE Serial Monitor). I get some random things when I connect the USB cable to the pc. Do I need to specify somewhere in the "config_arduino.hpp" or elsewhere the bps speed e.t.c.?

2. What values do i set in Putty for the serial communication?

3. My final aim is to make the "BASIC microcomputer" that uses Terminal-Basic (actually I put together the hardware part).  Do I need the "Ram expansion shield" or can I skip that for now?

  Are you sure? yes | no

Andrey Skvortsov wrote 04/18/2019 at 22:38 point

1 and 2: This issue looks like a baudrate mismatch of terminal and host. Please, look at the wiki page

By default TB uses USART0 on Arduino with 115200 kbps. This setting is controlled by the SERIAL_I_BR and SERIAL_O_BR parameters from config.hpp.

3. You can start without a SRAM expansion shield, using only Arduino MEGA, rca socket with 2 resistors and ps/2 connector, but you should decrease a screen resolution (TVOUT_HORIZ and TVOUT_VERT parameters from config.hpp) and memory ammount, available to BASIC programs (PROGRAMSIZE parameter in the #elif defined (__AVR_ATmega2560__) section of config_arduino.hpp).

  Are you sure? yes | no

John wrote 04/19/2019 at 18:00 point

Thanks for your advice. I managed to make it work with Arduino IDE Serial Monitor and also with Putty ! (Set to 115200bps and also followed Brian Decker's suggestion on setting: USE_TEXTATTRIBUTES 0).
I had no luck with tvout. I did set in config_arduino.hpp the USETVOUT 1 but doesn't compile. The "vt100.hpp: No such file or directory" error popped up. I have a screenshot here:
1. For my setup: a. RCA video output b. SD card board c. PS/2 keyboard input (no RAM card yet) where and what configuration values do I need to set? There are so many config files and parameters around. Could you pls provide the (configuration) files ready set for that?
2. Regarding the PROGRAMSIZE parameter, what value do I set and where?
3. What sketch do I upload to the smaller Arduino (I have a Nano) that acts as a ps/2 keyboard interface?
4. Where do I find documentation for the Terminal Basic language itself regarding, data types, commands, load, save for SD e.t.c.? Is there a manual available?

If this gets to work, it'll be a great computing experience "80's style" for my students at school. They tried TinyBasic and got hooked on BASIC so easily.

  Are you sure? yes | no

Andrey Skvortsov wrote 04/20/2019 at 14:25 point

1. File config.hpp contains 2 parameters SERIAL_I and SERIAL_O which control the input and output devices used by TB. Section " Input and output for single terminal mode" above them contains available values for these parameters and brief description ot them. To use TVOUT you should write TVOUT_O value to the parameter S_OUTPUT.

The yet unfinished Russian and English versions of reference manual are available at the TB bitbicket repository and I will publish them very soon.

A very brief manual can be found also at the sourceforge wiki

  Are you sure? yes | no

Andrey Skvortsov wrote 04/21/2019 at 06:14 point

> 3. . What sketch do I upload to the smaller Arduino (I have a Nano) that acts as a ps/2 keyboard controller?

My project of PS/2 keyboard reading library at contains an example, suitable to be used as ps2 keyboard reading for NANO/Pro mini module.

  Are you sure? yes | no

John wrote 04/24/2019 at 06:55 point

Hi there. Thanks for your support. Still trying to make this compile. Some more questions:
1. When you say "decrease a screen resolution (TVOUT_HORIZ and TVOUT_VERT parameters from config.hpp) ".......
is HORIZONTAL 120 and VERTICAL 96 small enough?
2. Also "and memory ammount, available to BASIC programs (PROGRAMSIZE parameter in the #elif defined (__AVR_ATmega2560__) section of config_arduino.hpp)." ........
there I'm not sure which "If...else..." option is valid in my setup. I did this:

#elif defined (__AVR_ATmega2560__)
#if (S_OUTPUT != TVOUT_O) && (!USE_EXTMEM) && (!USESD)
const uint16_t PROGRAMSIZE = 1024; // JOHN: was 6144;
#elif (!USE_EXTMEM) && (USESD)
const uint16_t PROGRAMSIZE = 1024; //JOHN: was other
const uint16_t PROGRAMSIZE = 900;

Is that ok?

3. I put the files in the "approprate" places but I seem to get errors (other than "not found" libraries) when trying to compile:

C:\Users\6E12~1\AppData\Local\Temp\cc07pr3A.s: Assembler messages:

C:\Users\6E12~1\AppData\Local\Temp\cc07pr3A.s:280: Error: unknown opcode `delay2'

C:\Users\6E12~1\AppData\Local\Temp\cc07pr3A.s:336: Error: unknown opcode `delay1'

C:\Users\6E12~1\AppData\Local\Temp\cc07pr3A.s:338: Error: unknown opcode `delay2'

C:\Users\6E12~1\AppData\Local\Temp\cc07pr3A.s:341: Error: unknown opcode `delay2'

C:\Users\6E12~1\AppData\Local\Temp\cc07pr3A.s:344: Error: unknown opcode `delay2'

C:\Users\6E12~1\AppData\Local\Temp\cc07pr3A.s:347: Error: unknown opcode `delay2'

C:\Users\6E12~1\AppData\Local\Temp\cc07pr3A.s:350: Error: unknown opcode `delay2'

C:\Users\6E12~1\AppData\Local\Temp\cc07pr3A.s:353: Error: unknown opcode `delay1'

C:\Users\6E12~1\AppData\Local\Temp\cc07pr3A.s:358: Error: unknown opcode `delay1'

C:\Users\6E12~1\AppData\Local\Temp\cc07pr3A.s:361: Error: unknown opcode `delay3'

lto-wrapper.exe: fatal error: C:\Users\�������\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\5.4.0-atmel3.6.1-arduino2/bin/avr-gcc returned 1 exit status

compilation terminated.

c:/users/�������/appdata/local/arduino15/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

I've been warned it's an issue of TVout library (by Brian) and also, I myself had encountered this in the past with TVout.

Thanks in advance.

  Are you sure? yes | no

Andrey Skvortsov wrote 04/24/2019 at 09:49 point

As for detailed RAM and other config parameters, I will make a working config on my own system without using of external RAM and write a short manual.

I think errors with TVOut compilation come out when I was upgrade Arduino IDE. What version do you have? But actually I use NetbeansIDE on Debian GNU/Linux, tuned for using ArduinoIDE toolchain.

  Are you sure? yes | no

Andrey Skvortsov wrote 04/25/2019 at 08:23 point

I use Netbeans to build TB and missed the problem with Arduino IDE.

I think I'v fixed build errors in 2.0.2 version, just released.

You need to replace TvOutEx library with the version, bundled with TB-2.0.2

Default config is ok, you only need to set TVOUT_O as output device.

RAM size should be decreased if, when enabling different features, Arduino IDE will say you use more then 90-92% of RAM.

Also you should disable -flto build flags in ArduinoIDE file hardware/arduino/avr/platform.txt.

In Netbeans IDE I only disable flto for TvOutEx library, but in ArduinoIDE itself it'not possible.

  Are you sure? yes | no

Brian Decker wrote 04/18/2019 at 23:58 point

One other configuration change that is helpful when using the Arduino IDE Serial Monitor is to navigate to the basic_config.h tab and set line 113 "#define USE_TEXTATTRIBUTES" to 0.  This turns off the VT100 text attributes and eliminates the formatting characters you are seeing.

  Are you sure? yes | no

John wrote 04/19/2019 at 18:02 point

Your suggestion was helpful. Thanks alot!

  Are you sure? yes | no

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