Menu

Reference Log in to Edit

Andrey Skvortsov

Language reference

List of the commands

  • CHAIN load program from EEPROM, preserving the state (variables and arrays)

  • CLS clear screen and move cursor to home position

  • DUMP [ARRAYS|VARS] debug info of BASIC memory, variables and arrays

  • LIST inputed program listing

  • LOAD load program from EEPROM

  • MAT perform matrix operation

  • NEW clear BASIC memory

  • RANDOMIZE initialize pseudo-random number generator

  • RUN run stored program

  • SAVE save current program into EEPROM

Variables declaration

LET ABC = 3

declares ABC real number variable (single precision)

LET Y% = 4

declares integer variable [-32768; 32768)

LET Z1%% = 65536

declares long integer variable [-2147483648; 2147483648)

LET SS$ = "HELLO, WORLD"

declares string variable

LET RES! = A<B

declares logical variable

Aray declaration

DIM AB%(3,3,3)

declares 3 dimensional array with each dimension from 0 to 3 of integer data

Arithmetic

LET A=3.0:LET B=2.0

PRINT (A+B)^(A*B)

prints 15625.00000000

DUMP VARS

prints

A: 3.00000000

B: 2.00000000

Program, which outputs a multiplication table

10 PRINT "MULTIPLICATION TABLE"
20 FOR I%=1 TO 9 STEP 1
30 FOR J%=1 TO 9 STEP 1
40 GOSUB 100
50 NEXT J%
60 NEXT I%
70 END
100 PRINT I%,"*",J%,"=",I%*J%
110 RETURN

This short form also works

10 FOR I%=1 TO 9 : FOR J%=1 TO 9
20 PRINT I%,J%,I%*J%
30 NEXT J% : NEXT I%
40 END

Matrix operations

Matrix operations are based on the 2-dimensional arrays and the MAT keyword.
This syntax is similar to the original Darthmouth BASIC with the following restrictions:
- Matrix occupies whole array, including elements with the 0 index (i.e. DIM A(3,3) allows to use
A as 4x4 matrix).
- ZER, CON and IDN initializers can not be applied to subset of the matrix elements
- MAT PRINT command can use only one matrix identifier.

1. Initialization

MAT A = ZER

initializes elements of previously dimensioned real array A with value of 0.

MAT IA% = CON

initializes elements of previously dimensioned integer array IA% with value of 1.

MAT B = IDN

initializes array B as identity matrix

2. Output

DIM A(3,3)
...
MAT A = IDN
...
MAT PRINT A

outputs array elements in table form

1.0000000 0.0000000 0.0000000 0.0000000
0.0000000 1.0000000 0.0000000 0.0000000
0.0000000 0.0000000 1.0000000 0.0000000
0.0000000 0.0000000 0.0000000 1.0000000

3. Operations

MAT A = B

resizes matrix A to the B size and copy elements of B to A

MAT A = B+C
MAT A = A-B

performs matrix per-element addition/subtraction.

MAT ARR1 = (BVAL)*ARR2

performs scaling the elements (multiply by scalar) of the matrix ARR1 with
the real variable BVAL.
Note, that in this example
MAT A = (A)*A
two objects are affected by the operation: 2-dimensional array A, which is scaled by the real scalar variable with the same name A. Matrix can participate in both right and left parts of the asignment expression

MAT A = B*C

performs matrix product of B and C and writes the result to A. This operation requires the MNs (M - number of rows in B, N - number of columns in C, s - matrix element size) additional storage and can suffer from the lack of memory, if the operands have significant size.

MAT A = TRN(A)

does transpositions of matrix A. Operations uses additional storage of 1 element of matrix type.

MAT B = INV(B)

finds the inversion of matrix B. This operation requires the ((2+M)M)s (M - number of rows and columns in B, s - matrix element size) additional storage and can suffer from the lack of memory, if the operand have significant size. Only square matrix can be used in this opertation. If the inversion was found successfuly, global result variable is set to TRUE, otherwise to FALSE.

Example:

10 DIM A(1,1)
20 A(0,0)=1:A(0,1)=2
30 A(1,0)=3:A(1,1)=4
40 DIM  B(1,1)
50 MAT B = INV(A)
60 IF RESULT() THEN GOTO 80
70 PRINT "NO INVERSION FOR MATRIX":MAT PRINT A: GOTO 100
80 PRINT "INVERSION FOR MATRIX":MAT PRINT A:"IS"
90 MAT PRINT B
100 END

MAT DET A

computes a determinant of the matrix A and stores it in the global variable RESULT()

Example:

10 DIM A(1,1)
20 A(0,0)=1:A(0,1)=2
30 A(1,0)=3:A(1,1)=4
40 MAT DET A
50 PRINT RESULT()

outputs
-2.000000

Math module functions

  • ABS(arg) absolute value

  • ACS(arg) arccos

  • ATN(arg) atan

  • COS(arg) cos

  • COT(arg) ctg

  • EXP(arg) exponent

  • LOG(arg) natural logarithm

  • PI() return pi value

  • RND() return random number [0;1]

  • SIN(arg) sin

  • SQR(arg) square root

  • TAN(arg) tan

ArduinoIO module functions and commands

  • AREAD(<PIN>) read analog value in volts (5V ref voltage)

  • AREAD%(<PIN>) read analog value in ADC units (as in the ADC data register)

  • DREAD!(<PIN>) read digital value of pin

  • DWRITE <PIN>, <VALUE> write digital value to pin

SDCard module commands

  • DCHAIN <file name="" without="" extension=""> load program from card, preserving the state

  • DIRECTORY list files on the card

  • DSAVE <file name="" without="" extension=""> save program to card

  • DLOAD <file name="" without="" extension=""> load program from card

  • HEADER delete all files from card

  • SCRATCH <file name="" without="" extension=""> delete program file from card

Usage

Downloads section contains precompiled images for different AVR boards.
After programming the flash use following terminal settings:

  • 115200 baud rate
  • Backspace send Ctrl-H (0x08)

Related

Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.