Tiny BASIC

Interpreter and Compiler Project

Compiling Tiny BASIC Programs under Windows

Monday, 28th October 2019

Some notes in blog post form from Damian Gareth Walker.

The manual contains an example of how to compile Tiny BASIC programs in a Unix-like environment, because that's what I have access to. After a bit of research, I've managed to gather some notes together on how you might do the same on a Windows-based computer. The notes may be imperfect, as I'm working with Wine under Linux rather than a real Windows machine.

The first thing you need is a C compiler. While looking for a suitable compiler for MS-DOS (a task that is still ongoing), I found a free C compiler for Windows that will compile the simple C programs output by the Tiny BASIC compiler. That is the Tiny C Compiler by Fabrice Bellard. The compiler is now maintained by others, but Bellard still hosts the web site.

After having installed Tiny BASIC for Windows as per the instructions on its download page, I unpacked the Tiny C Compiler archive in a directory along side it, namely C:\Users\damian\tcc. Tiny BASIC was installed in C:\Users\damian\TinyBASIC, and I worked from within Tiny BASIC's directory. First I needed to set the TBEXE variable:

set TBEXE=C:\Users\damian\tcc\i386-win32-tcc.exe -o $(TARGET).exe $(SOURCE)

Note the .exe extension on the target filename; Tiny C Compiler doesn't add that automatically. With this environment variable set, the --output=exe or -Oexe option in Tiny BASIC will work. For instance, you can compile the Lunar Lander game with the following command:

tinybasic -Oexe lander.bas

This will create the file lander.exe and, as a side effect, lander.bas.c which you can examine if you're interested.

Despite its name, Tiny C appears to be a full-featured C compiler, and creates reasonably compact executables. It may be possible to use it to recompile Tiny BASIC itself to a more reasonable size. I'll be experimenting with that over the coming weeks.

Comments

New Comment

Yes No