BASIC for Windows

One of the nice things about MSDOS/PCDOS computers and early Windows ones was they came with a BASIC interpreter. Now BASIC isn’t a language that people admit to using; but it is a fast way of exploring or demoing something. It is a pity that it vanished at some point.

FreeBASIC

There is a modern, GPL equivalent called FreeBASIC. That seems to be feature rich and it is probably a good alternative. It is a compiler rather than an interpreter so it doesn’t have quite the same immediate feel to it as the originals but compile times are short these days so it’s worth considering anyway. It also runs on Win or Linux so that’s a plus. The one downside is, it is an 11 MB download. Whilst that’s nothing on current computers with hundreds of GB of storage, it just looks very wrong for something that was originally intended to be a simple language for teaching. (11.3 MB is for ver 1.05.0-win32.exe).

I know it is a lot better than how much you’d have to download for Visual Studio. However, there’s no chance of back-porting that much code into a 64KB CP/M system.

In my CP/M days, I mainly used Assembler or C; but BASIC must have been around. People must have been able to write BASIC interpreters or compilers that fitted in less than 64KB and left room for user programs.

In fact, many computers back then came with BASIC in ROM and would even boot to a BASIC prompt. Whatever happened to those sorts of programs – a fairly full language in 8KB or less?

XYBASIC

A good CP/M starting point seems to be XYBASIC. It originally fit in 8KB and, even with enhancements taking it to 14KB, it is a lot smaller than 11 MB. It is also Open Source. The only down side to XYBASIC is it is written in 8080 assembler and porting that to Win32 is a bigger task than feeding the source code through a Win32 C compiler. It’s worth doing, but there is a easier way to the destination – tinyBASIC.

TinyBASIC

TinyBASIC is another version of BASIC from that era. It fitted into 2KB or 3KB of ROM so it certainly is tiny. Understandably, there are tradeoffs in getting a language that small so it doesn’t do all of the things I’d like it to. However, it is still pretty impressive and it is workable. It is stated to be free software and is available in C (TinyBasic.c).

Getting TinyBASIC to run on Win32 is simply a matter of feeding the C into gcc and out pops TinyBASIC.exe.

Regrettably, the use of a modern compiler takes what used to fit in less than 4KB to almost 80KB. There must be a lot of overhead in the C startup code or library functions that get included just in case. Despite that, it is still a lot better than 11 MB. (When I use my usual -O3 and -std=c99 options, it goes up to 137KB).

There is a:
user manual with unix line endings, or TB Manual with CRLF line endings
experimenters kit with unix line endings, or TBEK with CRLF line endings

As mentioned above, there are some limitations to the language. One that I noticed fairly early on was the lack of “FOR … NEXT”. That’s pretty major but it’s also pretty easy to work around, eg:

 10 I=1
 20 IF I>5 THEN GOTO 90
 30   PRINT I
 40   I=I+1
 50 GOTO 20
 90 ...
 99 END


The experimenters kit provides a lot of useful information on doing things you wouldn’t think could be done within the language. It is surprising how much can be done in something this small.

(Note: If you download TBasm.txt from the ittybitty site and save it in the same directory as tinybasic.exe, TinyBASIC will automatically run that. That filename is hard-coded in as a program default. It’s probably a useful default for the original developer but it was more of a surprise (“What’s all that?”) for me. If you do download that one from Tom’s site, I’d suggest you keep it away from the executable, or rename it.)

For now, to get out of TinyBASIC you need to press Ctrl-C (^C).

There are some things I’d like to add to Tiny BASIC. Stay tuned …

This is part of the CP/M topic.

It's only fair to share...Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUponDigg thisPin on PinterestEmail this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *