Circa 1976. With the success of the Tiny BASIC Design Note, a variety of Tiny BASIC IL implementations now span a range of microcomputers. The time has come to expand the Tiny BASIC standard.
(LET) var = expression INPUT (string ,) var-list PRINT expr-list (;) IF expression relop expression (THEN) statement DO WHILE expression UNTIL expression REM any-text
Please rewrite the Tiny BASIC program in its IL to support the revised grammar above:
- Make the “LET” keyword optional (prevent overbyte! e.g., X = X + 1 no longer has to be LET X = X +1).
- Make the “THEN” keyword optional (e.g., IF X=21 PRINT “BLACKJACK!” becomes valid).
- Support the “REM” remark statement for those people who upgraded their RAM and can waste memory with comments.
- If an INPUT statement starts with a string, output that string as a prompt (e.g., INPUT “AGE?”, A).
- If a PRINT statement ends with a semicolon (“;”) then suppress the carriage return.
- Implement a DO-WHILE loop.
- Implement a DO-UNTIL loop.
10 X=10 20 DO 30 PRINT X 40 X=X-1 50 UNTIL X<0 60 REM "WHILE X>=0" WOULD ALSO HAVE WORKED 70 PRINT "BLASTOFF!"
I've lightly edited the Tiny BASIC IL Reference and program here to make both easier to follow.
This is atomic-code-golf so shortest code wins, but - since no one has an IL assembler handy and since encoding of op-codes varied anyway - in this case, the fewest lines of code wins (not counting blank lines or lines with only comments; no penalty here for readability).