{"id":2154,"date":"2018-05-28T11:18:59","date_gmt":"2018-05-28T11:18:59","guid":{"rendered":"http:\/\/www.sydneysmith.com\/wordpress\/?p=2154"},"modified":"2018-05-28T11:18:59","modified_gmt":"2018-05-28T11:18:59","slug":"basic-for-windows","status":"publish","type":"post","link":"https:\/\/www.sydneysmith.com\/wordpress\/2154\/basic-for-windows\/","title":{"rendered":"BASIC for Windows"},"content":{"rendered":"<p>One of the nice things about MSDOS\/PCDOS computers and early Windows ones was they came with a BASIC interpreter. Now BASIC isn&#8217;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. <!--more--><\/p>\n<h2>FreeBASIC<\/h2>\n<p>There is a modern, GPL equivalent called <a href=\"https:\/\/www.freebasic.net\/\" rel=\"noopener\" target=\"_blank\">FreeBASIC<\/a>. That seems to be feature rich and it is probably a good alternative. It is a compiler rather than an interpreter so it doesn&#8217;t have quite the same immediate feel to it as the originals but compile times are short these days so it&#8217;s worth considering anyway. It also runs on Win or Linux so that&#8217;s a plus. The one downside is, it is an 11 MB download. Whilst that&#8217;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).<\/p>\n<p>I know it is a lot better than how much you&#8217;d have to download for Visual Studio. However, there&#8217;s no chance of back-porting that much code into a 64KB CP\/M system.<\/p>\n<p>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.<\/p>\n<p>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 &#8211; a fairly full language in 8KB or less?<\/p>\n<h2>XYBASIC<\/h2>\n<p>A good CP\/M starting point seems to be <a href=\"http:\/\/www.nesssoftware.com\/home\/mwc\/XYBASIC.php\" rel=\"noopener\" target=\"_blank\">XYBASIC<\/a>. 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&#8217;s worth doing, but there is a easier way to the destination &#8211; tinyBASIC.<\/p>\n<h2>TinyBASIC<\/h2>\n<p><a href=\"http:\/\/www.ittybittycomputers.com\/IttyBitty\/TinyBasic\/\" rel=\"noopener\" target=\"_blank\">TinyBASIC<\/a> 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&#8217;t do all of the things I&#8217;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 (<a href=\"http:\/\/www.ittybittycomputers.com\/IttyBitty\/TinyBasic\/TinyBasic.c\" rel=\"noopener\" target=\"_blank\">TinyBasic.c<\/a>).<\/p>\n<p>Getting TinyBASIC to run on Win32 is simply a matter of feeding the C into gcc and out pops <a href=\"http:\/\/www.sydneysmith.com\/products\/TinyBASIC\/downloads\/tinybasic.exe\">TinyBASIC.exe<\/a>.<\/p>\n<p>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).<\/p>\n<p>There is a:<br \/>\n&#8211; <a href=\"http:\/\/www.ittybittycomputers.com\/IttyBitty\/TinyBasic\/TBuserMan.txt\" rel=\"noopener\" target=\"_blank\">user manual<\/a> with unix line endings, or <a href=\"http:\/\/www.sydneysmith.com\/products\/TinyBASIC\/TBuserMan.txt\" rel=\"noopener\" target=\"_blank\">TB Manual with CRLF line endings<\/a><br \/>\n&#8211; <a href=\"http:\/\/www.ittybittycomputers.com\/IttyBitty\/TinyBasic\/TBEK.txt\" rel=\"noopener\" target=\"_blank\">experimenters kit<\/a> with unix line endings, or <a href=\"http:\/\/www.sydneysmith.com\/products\/TinyBASIC\/TBEK.txt\" rel=\"noopener\" target=\"_blank\">TBEK with CRLF line endings<\/a><\/p>\n<p>As mentioned above, there are some limitations to the language. One that I noticed fairly early on was the lack of &#8220;FOR &#8230; NEXT&#8221;. That&#8217;s pretty major but it&#8217;s also pretty easy to work around, eg:<br \/>\n<code><\/p>\n<pre>\r\n 10 I=1\r\n 20 IF I>5 THEN GOTO 90\r\n 30   PRINT I\r\n 40   I=I+1\r\n 50 GOTO 20\r\n 90 ...\r\n 99 END\r\n<\/pre>\n<p><\/code><br \/>\nThe experimenters kit provides a lot of useful information on doing things you wouldn&#8217;t think could be done within the language. It is surprising how much can be done in something this small.<\/p>\n<p>(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&#8217;s probably a useful default for the original developer but it was more of a surprise (&#8220;What&#8217;s all that?&#8221;) for me. If you do download that one from Tom&#8217;s site, I&#8217;d suggest you keep it away from the executable, or rename it.)<\/p>\n<p>For now, to get out of TinyBASIC you need to press Ctrl-C (^C).<\/p>\n<p>There are some things I&#8217;d like to add to Tiny BASIC. Stay tuned &#8230;<\/p>\n<p>This is part of the <a href=\"http:\/\/www.sydneysmith.com\/wordpress\/cpm-programs\/\">CP\/M topic<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the nice things about MSDOS\/PCDOS computers and early Windows ones was they came with a BASIC interpreter. Now BASIC isn&#8217;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.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16,59],"tags":[],"_links":{"self":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/2154"}],"collection":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/comments?post=2154"}],"version-history":[{"count":2,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/2154\/revisions"}],"predecessor-version":[{"id":2156,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/2154\/revisions\/2156"}],"wp:attachment":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/media?parent=2154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/categories?post=2154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/tags?post=2154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}