{"id":2157,"date":"2018-05-28T14:07:52","date_gmt":"2018-05-28T14:07:52","guid":{"rendered":"http:\/\/www.sydneysmith.com\/wordpress\/?p=2157"},"modified":"2018-06-28T08:02:18","modified_gmt":"2018-06-28T08:02:18","slug":"basic1","status":"publish","type":"post","link":"https:\/\/www.sydneysmith.com\/wordpress\/2157\/basic1\/","title":{"rendered":"BASIC1"},"content":{"rendered":"<p>I&#8217;ve recently been looking at BASIC for Windows. What I wanted was something that captured the simplicity of CP\/M or early MSDOS days, was small in size and had a reasonably useful set of functionality. TinyBASIC was a fairly good compromise but it lacked a few things &#8230; <!--more--><\/p>\n<p>My main regret with TinyBASIC was the lack of LOAD and SAVE commands. Without those, you&#8217;re not far from a programmable calculator with volatile memory. You have to type your program in every time.<\/p>\n<p>Another sore point was needing to use Ctrl-C to get out of the program. It&#8217;s not a big issue; but it&#8217;s not a great look either.<\/p>\n<p>A little more functionality and a little more of the language would be nice. I think I did see a comment at some point that some implementations of TinyBASIC did include LOAD \/ SAVE so others must have thought the same.<\/p>\n<h2>BASIC to Assembler and Binary<\/h2>\n<p>The idea of functionality brought up the question of, &#8220;what is the standard for BASIC?&#8221; i.e, &#8220;what functionality should be in it?&#8221; Fortunately, I came across a compiler by John Gatewood Ham on <a href=\"http:\/\/buraphakit.sourceforge.net\/BASIC.shtml\" rel=\"noopener\" target=\"_blank\">sourceforge.net<\/a> and he&#8217;d spent some time researching the language and then implementing it. It is a very good page for both the language and for the trials that arise when implementing one. One of the jewels was the story of ECMA-55 which is the only publicly available standard for the language of the late 1970s. He has links to the document of his site.<\/p>\n<p>ECMA-55 is an interesting standard. It explains a lot of what we saw that was common across the different dialects of BASIC. If you were using BASIC in those days, you&#8217;ll no doubt remember that every version of BASIC was different and you had to choose which flavour of BASIC to write for each time. Whenever a new BASIC compiler or interpreter was released, it would differ in some way from all of its predecessors. The positive to that was &#8220;bigger and better&#8221;. The negative was, your old programs wouldn&#8217;t run. ECMA-55 was the missing link (for me at the time) that explained what the essence of BASIC actually was.<\/p>\n<p>It wasn&#8217;t closely followed as many had slight variations to core functionality and many added things to the core; but it does show what they were all hovering around. It is a good read and is fairly short.<\/p>\n<h2>A Standards Compliant BASIC Interpreter<\/h2>\n<p>John mentions on the sourceforge page that there is a recent implementation of the as-defined language in <a href=\"http:\/\/jorgicor.sdfeu.org\/bas55\/\" rel=\"noopener\" target=\"_blank\">bas55<\/a>. That one is neat, compact and comprehensive. The executable is only 75 KB which is very good.<\/p>\n<p>If you look through the source code for bas55, you&#8217;ll see that it used Bison or a later derivative to translate the BASIC grammar into a series of tables that the program then uses. It is a good approach and tools like that result in significant savings in development time and also produce fast compilers \/ interpreters. For John&#8217;s purposes, he wanted to avoid teaching additional tools and allow his students to focus on how simple compilers work. Both approaches have their merits.<\/p>\n<h2>Basic1<\/h2>\n<p><a href=\"http:\/\/www.sydneysmith.com\/wordpress\/wp-content\/uploads\/2018\/05\/basic1.png\"><img loading=\"lazy\" src=\"http:\/\/www.sydneysmith.com\/wordpress\/wp-content\/uploads\/2018\/05\/basic1-300x203.png\" alt=\"\" width=\"300\" height=\"203\" class=\"alignnone size-medium wp-image-2158\" srcset=\"https:\/\/www.sydneysmith.com\/wordpress\/wp-content\/uploads\/2018\/05\/basic1-300x203.png 300w, https:\/\/www.sydneysmith.com\/wordpress\/wp-content\/uploads\/2018\/05\/basic1.png 460w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>I wanted something that came close to the standard; but would be fairly easily extended.<\/p>\n<p>I wanted both the simplicity and development speed of a tool generated grammar recogniser; but also the simplicity of &#8220;pure code&#8221; so I could see what was being done, instead of just staring dumbly at a page of state \/ transition numbers.<\/p>\n<p>After about two weeks of pretty busy evenings and weekends, I am pleased to provide another (mostly) ECMA-55 compliant BASIC interpreter. My grammar code is less efficient that Jorge&#8217;s bas55 so my executable is 120 KB. It&#8217;s probably also slower but it should serve as a good starting point for adding features. It&#8217;s not perfect but I think you&#8217;ll like it. It does have some additions already; such as: TRON \/ TROFF and a simple immediate mode (? expr) so you can try things out whilst thinking through the next line of code. I also like how smoothly the HELP system turned out.<\/p>\n<p>You can download a copy of <a href=\"http:\/\/www.sydneysmith.com\/download\/2157\/basic1\/basic1-0.00.zip\">basic1<\/a>. It is free to use and doesn&#8217;t have any time limits on it. Whilst my executable is 120 KB, the download includes the help file too and so, as a single ZIP file, the download is only 40 KB in total!<\/p>\n<p>It is version 0.00 for now. You should see the version number go up over the next few weeks as I add things. It does already have the ability to load and run a BASIC program directly from the OS prompt (see HELP STARTUP).<\/p>\n<p>*** Update 10 Jun 2018 ***<br \/>\n<a href=\"http:\/\/www.sydneysmith.com\/download\/2157\/basic1\/basic1-0.02.zip\">Basic1 version 0.02<\/a> has been done. This corrects a few more things and adds most of the functions that were prevalent in the late 1970s and early 1980s. It now successfully runs a number of programs from that era with minimal tweaks. See HELP CHANGES for more info.  <\/p>\n<p>*** Update 03 Jun 2018 ***<br \/>\n<a href=\"http:\/\/www.sydneysmith.com\/download\/2157\/basic1\/basic1-0.01.zip\">Basic1 version 0.01<\/a> has been done. This makes variable names case-insensitive and corrects the grammar to make subtraction left-to-right associative (10-2-1 now =7, like it should). There are a number of other additions, see HELP CHANGES for more info.  <\/p>\n<p>This is part of the <a href=\"http:\/\/www.sydneysmith.com\/wordpress\/cpm-programs\/\">CP\/M topic<\/a>.<br \/>\nSee the <a href=\"http:\/\/www.sydneysmith.com\/wordpress\/basic1\/\">Basic1<\/a> page for the latest and other versions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve recently been looking at BASIC for Windows. What I wanted was something that captured the simplicity of CP\/M or early MSDOS days, was small in size and had a reasonably useful set of functionality. TinyBASIC was a fairly good compromise but it lacked a few things &#8230;<\/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\/2157"}],"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=2157"}],"version-history":[{"count":7,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/2157\/revisions"}],"predecessor-version":[{"id":2186,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/2157\/revisions\/2186"}],"wp:attachment":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/media?parent=2157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/categories?post=2157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/tags?post=2157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}