- Introduction
- Variables
- Mathematical Operators
- Logical Operators
- Control Flow
- PEEK-POKE
- Additional Commands
- Examples
- Configuring uBASIC
- Compiling and Building uBASIC
Veecom uBASIC is a derivative of the uBASIC interpreter originally authored by Adam Dunkels. This version of uBASIC has been improved to be made fully interactive, with the incorporation of additional commands and performance optimizations.
The interpreter provides flexibility in input methods, allowing users to either write commands directly or use line numbers.
PRINT "HELLO, WORLD!"
10 PRINT "HELLO, WORLD!"
20 END
Direct commands are executed right away, whereas Line-Numbered commands require the execution of the RUN
command afterward.
There is only support for integer variables and the variables can only have single character names (A-Z).
10 LET A = 10
20 LET B = 2 * A
30 LET C = B - A
10 LET CE = 9
20 LET A = 2.4
LET N = 10 + 6
LET N = 10 - 6
LET N = 10 * 6
LET N = 10 / 6
LET N = 10 % 6
LET N = 10 & 6
LET N = 10 | 6
IF A < B THEN ...
IF A > B THEN ...
IF A = B THEN ...
IF A < B THEN PRINT "A IS LESS"
10 FOR I = 1 TO 3
20 PRINT I * I
30 NEXT I
40 END
1
4
9
10 PRINT "HELLO, WORLD!"
20 GOTO 10
HELLO, WORLD!
HELLO, WORLD!
HELLO, WORLD!
HELLO, WORLD!
HELLO, WORLD!
...
10 GOSUB 100
20 PRINT "RETURNED FROM SUBROUTINE"
30 END
100 PRINT "SUBROUTINE"
110 RETURN
SUBROUTINE
RETURNED FROM SUBROUTINE
A
is assigned to the value held at address 65535
PEEK 65535, A
Variables can be used to hold addresses
10 LET A = 65532
20 PEEK A, B
The memory address is assigned to the value held by A
10 LET A = 72
20 POKE 65534, A
The RUN
is used to start the execution of Line-Numbered programs
10 PRINT "HELLO, WORLD!"
20 GOTO 10
RUN
HELLO, WORLD!
HELLO, WORLD!
HELLO, WORLD!
...
The LIST
command is used to view the lines of uBASIC code that you have entered into the computer.
10 PRINT "HELLO, WORLD!"
20 FOR I = 1 TO 10
30 PRINT I
40 NEXT I
20 FOR I = 1 TO 10
10 PRINT "HELLO, WORLD!"
20 FOR I = 1 TO 10
30 PRINT I
30 PRINT I
40 NEXT I
20 FOR I = 1 TO 10
30 PRINT I
40 NEXT I
The NEW
command erases the content of uBASIC program memory
LIST
10 PRINT "HELLO, WORLD!"
READY.
NEW
READY.
LIST
READY.
The FRE
command displays the remaining bytes available for the uBASIC program
FRE
2100 uBASIC BYTES FREE
REM SET VARIABLE A TO THE ADDRESS OF PORT A OUTPUT (PAO)
10 LET A = 65528
20 FOR I = 65 TO 90
30 POKE A, I | 128
40 POKE A, 0
50 NEXT I
60 POKE A, 10
70 POKE A, 0
80 END
REM CONFIGURE AND START THE TIMER IN ONE-SHOT MODE
10 LET C = 1
20 POKE 65535, C
30 PEEK 65534, T
40 PRINT T
50 GOTO 30
When A
equal to 6
10 LET A = 6
20 IF A % 2 = 0 THEN GOTO 50
30 PRINT "A IS ODD"
40 END
50 PRINT "A IS EVEN"
60 END
When A
equal to 9
10 LET A = 9
...
Veecom uBASIC can be customized from the ubasic_config.h
file.
You'll need a RISC-V C/C++ compiler, I personally use this one for my windows machine.
Download and install risc-v-gcc10.1.0.exe
and leave things to defaults.
Open the terminal, navigate to Veecom-uBASIC
folder and type make
.
From logisim load the final.bin
file into Veecoms' main memory module.