1
\$\begingroup\$

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

\$\endgroup\$

closed as unclear what you're asking by xnor, mbomb007, Level River St, Wheat Wizard, user42649 Apr 25 '17 at 3:38

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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\$ – Level River St Apr 25 '17 at 3:29