mk90.basic

Example programs

Complete listings for arithmetic, control flow, files, display and timing.

Using the examples

The HTML package includes eight complete ASCII BAS files under examples/. They illustrate the supported dialect and may be compiled once present on a writable MKS2 volume. The manual archive itself is not an SMP filesystem image.

The boot ROM includes its own demo.bas, so the first trial needs no file-transfer utility. For entering operators directly on the MK90, see keyboard punctuation. This release does not have a UART transfer command.

Count and beep

Download hello.bas

10 CLS
20 FOR I=1 TO 5
30 PRINT "MK90 ";I
40 BEEP
50 WAIT 8
60 NEXT I
70 END

Arithmetic and a subroutine

Download math.bas

10 A=2+3*4
20 B=-17/5
30 C=-17 MOD 5
40 PRINT A;",";B;",";C
50 GOSUB 80
60 PRINT A
70 END
80 A=A+1
90 RETURN

Write and read three bytes

Download files.bas

10 OPEN "letters",OUTPUT,3
20 PUT 65:PUT 66:PUT 67
30 CLOSE
40 OPEN "letters",INPUT
50 IF EOF THEN 90
60 GET A
70 PRINT A
80 GOTO 50
90 CLOSE
100 END

Graphics and the RTC

Download screen.bas

10 CLS
20 LINE 0,12,119,12
30 LOCATE 0,0
40 PRINT "TIME ";HOUR;":";MINUTE;":";SECOND
50 PSET 60,40
60 WAIT 16
70 PRESET 60,40
80 BEEP
90 END

Nested loops and conditional branching

Download loops.bas

10 A=0
20 FOR I=1 TO 3
30 FOR J=2 TO 1 STEP -1
40 A=A+I*J
50 NEXT J
60 NEXT I
70 IF A=18 THEN 100
80 PRINT "UNEXPECTED"
90 END
100 PRINT "TOTAL ";A
110 END

Structured selection and loops

Download blocks.bas

A=0
B=0
WHILE A<5
A=A+1
IF A MOD 2 THEN
B=B+A
ELSE
B=B+10
ENDIF
WEND
PRINT "TOTAL ";B
END

Array input from DATA

Download arrays.bas

DIM A(2)
READ A(0),A(1),A(2)
B=0
FOR I=0 TO 2
B=B+A(I)
NEXT I
PRINT "SUM ";B
END
DATA 10,20,30

Post-test loop and repeatable random numbers

Download repeat.bas

A=0
REPEAT
A=A+1
UNTIL A=3
RANDOMIZE 123
B=RND(100)
RANDOMIZE 123
C=RND(100)
IF B=C THEN
PRINT "REPEATABLE ";A
ENDIF
END

Expected results

ExampleResult
blocks.basPrints TOTAL 29.
arrays.basPrints SUM 60.
repeat.basPrints REPEATABLE 3.
hello.basFive MK90 lines and five short beeps.
math.bas14,-3,-2 followed by 15.
files.basCreates/replaces letters with bytes 65, 66, 67; reads and prints them.
screen.basDraws a line, displays RTC components, briefly lights a pixel and beeps.
loops.basPrints TOTAL 18.