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
10 CLS
20 FOR I=1 TO 5
30 PRINT "MK90 ";I
40 BEEP
50 WAIT 8
60 NEXT I
70 ENDArithmetic and a subroutine
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 RETURNWrite and read three bytes
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 ENDGraphics and the RTC
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 ENDNested loops and conditional branching
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 ENDStructured selection and loops
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
ENDArray input from DATA
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,30Post-test loop and repeatable random numbers
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
ENDExpected results
| Example | Result |
|---|---|
| blocks.bas | Prints TOTAL 29. |
| arrays.bas | Prints SUM 60. |
| repeat.bas | Prints REPEATABLE 3. |
| hello.bas | Five MK90 lines and five short beeps. |
| math.bas | 14,-3,-2 followed by 15. |
| files.bas | Creates/replaces letters with bytes 65, 66, 67; reads and prints them. |
| screen.bas | Draws a line, displays RTC components, briefly lights a pixel and beeps. |
| loops.bas | Prints TOTAL 18. |