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
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
40 X=X-1
50 UNTIL X<0

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

  • 2
    \$\begingroup\$ Hi 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 \$\endgroup\$ Commented Apr 25, 2017 at 3:29


Browse other questions tagged or ask your own question.