Ever since starting writing small BASIC programs on my first computer (an ABC80) I've always wanted to write a really small BASIC interpreter. So I sat down for an hour or two, during one of the sessions at ACM/Usenix MobiSys 2006, and did it.

The (non-interactive) uBASIC interpreter supports only the most basic BASIC functionality: if/then/else, for/next, let, goto, gosub, print, and mathematical expressions. There is only support for integer variables and the variables can only have single character names. I have added an API that allows for the program that uses the uBASIC interpreter to get and set BASIC variables, so it might be possible to actually use the uBASIC code for something useful (e.g. a small scripting language for an application that has to be really small).

My intention with this program is to be able to use it for adding a simple scripting language to severely memory-constrained applications or systems (e.g. a scripting language to the web server applications in uIP or Contiki). While I secretly hope that the uBASIC code may be useful to someone, it currently is a really quick hack made primarily for personal enjoyment. However, if you are interested in looking at how a really small BASIC interpreter can be written, go ahead and take a look at the code!


The code is available at github: https://github.com/adamdunkels/ubasic.




uBASIC is released under an open source 3-clause BSD-style license. The full license text is here.