Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Tiny BASIC
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Implementation in a virtual machine=== The Design Note specified a [[virtual machine]], in which the Tiny BASIC [[interpreter (computing)|interpreter]] is itself run on a virtual machine interpreter. The designer's idea to use an application virtual machine goes back to Val Schorre (with [[META II]], 1964) and Glennie (Syntax Machine). The choice of a virtual machine approach economized on memory space and implementation effort, although the BASIC programs run thereon were executed somewhat slowly.<ref>{{cite journal|last1=Allen|first1=Dennis|title=TINY BASIC|journal=People's Computer Company|volume= 4|issue= 3}}</ref> Dialects that used the virtual machine included Tiny BASIC Extended, [[Tom Pittman (computer scientist)|Tom Pittman]]'s Tiny BASIC<ref>{{cite web|last1=Veit|first1=Holger|title=Tom Pittman's 6800 tiny BASIC|url=http://www.ittybittycomputers.com/IttyBitty/TinyBasic/TB_6800.asm|access-date=2 May 2017}}</ref> and NIBL. Other dialects such as Denver Tiny BASIC (DTB) and Palo Alto Tiny BASIC were direct interpreters. Some programmers, such as Fred Greeb with DTB, treated the IL (Interpretive Language) program as [[pseudocode]] for the [[algorithm]] to implement in assembly language; Denver Tiny BASIC did not use a virtual machine, but it did closely follow the IL program. This is a representative excerpt from the 120-line IL program: <syntaxhighlight lang="nasm"> S1: TST S3,'GO' ;GOTO OR GOSUB? TST S2,'TO' ;YES...TO, OR...SUB CALL EXPR ;GET LABEL DONE ;ERROR IF CR NOT NEXT XFER ;SET UP AND JUMP S3: TST S8,'PRINT' ;PRINT. </syntaxhighlight> A common pattern in the program is to test for a keyword or part of a keyword, then act on that information. Each test is an assertion as to what is next in the line buffer. If the assertion fails, control jumps to a subsequent label (usually looking for a new keyword or token). Here the system advances its buffer cursor over any spaces and tests for {{mono|GO}} and if it fails to find it then jumps to line {{mono|S3}}. If it finds it, execution continues with the next IL command. In this case, the system next tests for {{mono|TO}}, skipping to line {{mono|S2}} if it fails (a test for {{mono|SUB}}, to see if this is instead a {{mono|GOSUB}} command). If it passes, control continues; in this case, calling an IL subroutine that starts at label {{mono|EXPR}}, which parses an expression. In Tiny BASIC, {{code|GOTO X*10+100}} (a computed GO TO) is as legal as {{code|GOTO 100}} and is the alternative to the ON-GOTO of larger BASIC implementations. The subroutine {{mono|EXPR}} pushes the result of the expression onto the arithmetic stack (in this case, the line number). {{mono|DONE}} verifies no other text follows the expression and gives an error if it does. {{mono|XFER}} pops the number from the stack and transfers execution (GOes TO) the corresponding line number, if it exists. The following table gives a partial list of the 32 commands of the virtual machine in which the first Tiny BASIC interpreter was written.<ref>''Dr. Dobb's Journal'', Volume 1, Number 1, 1976, p. 12.</ref> ; {{mono|TST ''lbl'', ''string''}} : If ''string'' matches the BASIC line, advance cursor over {{mono|''string''}} and execute the next IL instruction; if the test fails, execute the IL instruction at the label ''lbl'' ; {{mono|CALL ''lbl''}} : Execute the IL subroutine starting at {{mono|''lbl''}}; save the IL address following the CALL on the control stack ; {{mono|DONE}} : Report a syntax error if after deleting leading blanks the cursor is not positioned to reach a carriage return ; {{mono|XFER}} : Test value at the top of the AE stack to be within range. If not, report an error. If so, attempt to position cursor at that line. If it exists, begin interpretation there; if not, report an error. ; {{mono|JUMP ''lbl''}} : Continue execution of the IL at the label specified ; {{mono|RTN}} : Return to the IL location specified at the top of the control stack ; {{mono|PRS}} : Print characters from the BASIC text up to but not including the closing quotation mark ; {{mono|PRN}} : Print number obtained by popping the top of the expression stack ; {{mono|SPC}} : Insert spaces to move the print head to next zone ; {{mono|NLINE}} : Output a CRLF<ref>The <code>CRLF</code> there symbolizes a carriage return followed by a [[line feed]].</ref> to the printer [[Tom Pittman (computer scientist)|Tom Pittman]], discussing the IL, says: "The TINY BASIC interpreter was designed by Dennis Allison as a [[recursive descent parser]]. Some of the elegant simplicity of this design was lost in the addition of syntactical sugar to the language but the basic form remains. The IL is especially suited to Recursive Descent parsing of TINY BASIC because of the general recursive nature of its procedures and the simplicity of the TINY BASIC tokens. The IL language is effectively optimized for the interpretation of TINY. Experience has shown that the difficulty of adding new features to the language is all out of proportion with the nature of the features. Usually it is necessary to add additional machine language subroutines to support the new features. Often the difficulty outweighs the advantages."<ref>{{cite web| url=http://www.ittybittycomputers.com/IttyBitty/TinyBasic/TBEK.txt | title=Tiny BASIC Experimenter's Kit | last=Pittman | first=Tom | access-date=August 9, 2020}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)