Rewrite the Tiny BASIC IL program to support 7 changes to BASIC

1

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.

Grammar revisions:

(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:

  1. Make the “LET” keyword optional (prevent overbyte! e.g., X = X + 1 no longer has to be LET X = X +1).
  2. Make the “THEN” keyword optional (e.g., IF X=21 PRINT “BLACKJACK!” becomes valid).
  3. Support the “REM” remark statement for those people who upgraded their RAM and can waste memory with comments.
  4. If an INPUT statement starts with a string, output that string as a prompt (e.g., INPUT “AGE?”, A).
  5. If a PRINT statement ends with a semicolon (“;”) then suppress the carriage return.
  6. Implement a DO-WHILE loop.
  7. Implement a DO-UNTIL loop.

Sample 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  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).

Jeffrey Henning

Posted 2017-04-25T02:11:11.963

Reputation: 11

Question was closed 2017-04-25T03:38:39.447

2Hi Jeffrey, welcome to PPCG. "no one has an IL assembler handy" I think we need an implementation of the IL to test our code on, otherwise its going to be very difficult to determine if an answer is valid. Languages are defined by implementation here. Also (before someone else says it) normally we score by bytes but in this case I understand a "line" of code means one of the 33 IL instructions. Close voting as I understand no IL assembler is available – Level River St – 2017-04-25T03:29:21.570

No answers